18 import(
'lib.pkp.classes.reviewForm.ReviewForm');
29 function getById($reviewFormId, $assocType =
null, $assocId =
null) {
30 $params = array((
int) $reviewFormId);
32 $params[] = (int) $assocType;
33 $params[] = (int) $assocId;
38 SUM(CASE WHEN ra.date_completed IS NOT NULL THEN 1 ELSE 0 END) AS complete_count,
39 SUM(CASE WHEN ra.review_id IS NOT NULL AND ra.date_completed IS NULL THEN 1 ELSE 0 END) AS incomplete_count
41 LEFT JOIN review_assignments ra ON (ra.review_form_id = rf.review_form_id AND ra.declined<>1)
42 WHERE rf.review_form_id = ? AND rf.assoc_type = ? AND rf.assoc_id = ?
43 GROUP BY rf.review_form_id',
48 if ($result->RecordCount() != 0) {
49 $returner = $this->
_fromRow($result->GetRowAssoc(
false));
71 $reviewForm->setId($row[
'review_form_id']);
72 $reviewForm->setAssocType($row[
'assoc_type']);
73 $reviewForm->setAssocId($row[
'assoc_id']);
74 $reviewForm->setSequence($row[
'seq']);
75 $reviewForm->setActive($row[
'is_active']);
76 $reviewForm->setCompleteCount($row[
'complete_count']);
77 $reviewForm->setIncompleteCount($row[
'incomplete_count']);
79 $this->
getDataObjectSettings(
'review_form_settings',
'review_form_id', $row[
'review_form_id'], $reviewForm);
95 'SELECT COUNT(*) FROM review_forms WHERE review_form_id = ? AND assoc_type = ? AND assoc_id = ?',
96 array((
int) $reviewFormId, (
int) $assocType, (
int) $assocId)
98 $returner = isset($result->fields[0]) && $result->fields[0] == 1 ? true :
false;
109 return array(
'title',
'description');
118 'review_form_id' => $reviewForm->getId()
128 'INSERT INTO review_forms
129 (assoc_type, assoc_id, seq, is_active)
133 (
int) $reviewForm->getAssocType(),
134 (
int) $reviewForm->getAssocId(),
135 $reviewForm->getSequence() ==
null ? 0 : (
float) $reviewForm->getSequence(),
136 $reviewForm->getActive()?1:0
143 return $reviewForm->getId();
151 $returner = $this->
update(
158 WHERE review_form_id = ?',
160 (
int) $reviewForm->getAssocType(),
161 (
int) $reviewForm->getAssocId(),
162 (
float) $reviewForm->getSequence(),
163 $reviewForm->getActive()?1:0,
164 (
int) $reviewForm->getId()
178 return $this->
deleteById($reviewForm->getId());
187 $reviewFormElementDao->deleteByReviewFormId($reviewFormId);
189 $this->
update(
'DELETE FROM review_form_settings WHERE review_form_id = ?', (
int) $reviewFormId);
190 $this->
update(
'DELETE FROM review_forms WHERE review_form_id = ?', (
int) $reviewFormId);
199 $reviewForms = $this->
getByAssocId($assocType, $assocId);
201 while ($reviewForm = $reviewForms->next()) {
216 SUM(CASE WHEN ra.date_completed IS NOT NULL THEN 1 ELSE 0 END) AS complete_count,
217 SUM(CASE WHEN ra.review_id IS NOT NULL AND ra.date_completed IS NULL THEN 1 ELSE 0 END) AS incomplete_count
219 LEFT JOIN review_assignments ra ON (ra.review_form_id = rf.review_form_id AND ra.declined<>1)
220 WHERE rf.assoc_type = ? AND rf.assoc_id = ?
221 GROUP BY rf.review_form_id
223 array((
int) $assocType, (
int) $assocId), $rangeInfo
239 SUM(CASE WHEN ra.date_completed IS NOT NULL THEN 1 ELSE 0 END) AS complete_count,
240 SUM(CASE WHEN ra.review_id IS NOT NULL AND ra.date_completed IS NULL THEN 1 ELSE 0 END) AS incomplete_count
242 LEFT JOIN review_assignments ra ON (ra.review_form_id = rf.review_form_id AND ra.declined<>1)
243 WHERE rf.assoc_type = ? AND rf.assoc_id = ? AND rf.is_active = 1
244 GROUP BY rf.review_form_id
246 array((
int) $assocType, (
int) $assocId), $rangeInfo
260 $reviewForm = $this->
getById($reviewFormId, $assocType, $assocId);
261 if (!$reviewForm)
return false;
262 if ($reviewForm->getCompleteCount()!=0 || $reviewForm->getIncompleteCount()!=0)
return false;
273 'SELECT review_form_id FROM review_forms WHERE assoc_type = ? AND assoc_id = ? ORDER BY seq',
274 array((
int) $assocType, (
int) $assocId)
277 for ($i=1; !$result->EOF; $i++) {
278 list($reviewFormId) = $result->fields;
280 'UPDATE review_forms SET seq = ? WHERE review_form_id = ?',
297 return $this->
_getInsertId(
'review_forms',
'review_form_id');