Open Journal Systems  3.0.0
 All Classes Namespaces Functions Variables Groups Pages
EditDecisionDAO.inc.php
1 <?php
2 
16 // Bring in editor decision constants
17 // FIXME: These should be standardized into lib-pkp.
18 import('classes.workflow.EditorDecisionActionsManager');
19 
20 class EditDecisionDAO extends DAO {
24  function EditDecisionDAO() {
25  parent::DAO();
26  }
27 
34  function updateEditorDecision($submissionId, $editorDecision, $stageId = null, $reviewRound = null) {
35  if ($editorDecision['editDecisionId'] == null) {
36  $this->update(
37  sprintf(
38  'INSERT INTO edit_decisions
39  (submission_id, review_round_id, stage_id, round, editor_id, decision, date_decided)
40  VALUES (?, ?, ?, ?, ?, ?, %s)',
41  $this->datetimeToDB($editorDecision['dateDecided'])
42  ),
43  array(
44  (int) $submissionId,
45  is_a($reviewRound, 'ReviewRound') ? (int) $reviewRound->getId() : 0,
46  is_a($reviewRound, 'ReviewRound') ? $reviewRound->getStageId() : (int) $stageId,
47  is_a($reviewRound, 'ReviewRound') ? (int) $reviewRound->getRound() : REVIEW_ROUND_NONE,
48  (int) $editorDecision['editorId'],
49  $editorDecision['decision']
50  )
51  );
52  }
53  }
54 
59  function deleteDecisionsBySubmissionId($submissionId) {
60  return $this->update(
61  'DELETE FROM edit_decisions WHERE submission_id = ?',
62  (int) $submissionId
63  );
64  }
65 
72  function getEditorDecisions($submissionId, $stageId = null, $round = null) {
73  $params = array((int) $submissionId);
74  if ($stageId) $params[] = (int) $stageId;
75  if ($round) $params[] = (int) $round;
76 
77  $result = $this->retrieve(
78  'SELECT edit_decision_id, editor_id, decision,
79  date_decided, review_round_id, stage_id, round
80  FROM edit_decisions
81  WHERE submission_id = ?
82  ' . ($stageId?' AND stage_id = ?':'') . '
83  ' . ($round?' AND round = ?':'') . '
84  ORDER BY date_decided ASC',
85  $params
86  );
87 
88  $decisions = array();
89  while (!$result->EOF) {
90  $decisions[] = array(
91  'editDecisionId' => $result->fields['edit_decision_id'],
92  'reviewRoundId' => $result->fields['review_round_id'],
93  'stageId' => $result->fields['stage_id'],
94  'round' => $result->fields['round'],
95  'editorId' => $result->fields['editor_id'],
96  'decision' => $result->fields['decision'],
97  'dateDecided' => $this->datetimeFromDB($result->fields['date_decided'])
98  );
99  $result->MoveNext();
100  }
101  $result->Close();
102  return $decisions;
103  }
104 
110  function transferEditorDecisions($oldUserId, $newUserId) {
111  $this->update(
112  'UPDATE edit_decisions SET editor_id = ? WHERE editor_id = ?',
113  array((int) $newUserId, (int) $oldUserId)
114  );
115  }
116 }
117 
118 ?>
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:30
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:84
deleteDecisionsBySubmissionId($submissionId)
transferEditorDecisions($oldUserId, $newUserId)
updateEditorDecision($submissionId, $editorDecision, $stageId=null, $reviewRound=null)
Operations for retrieving and modifying editor decisions.
getEditorDecisions($submissionId, $stageId=null, $round=null)
datetimeToDB($dt)
Definition: DAO.inc.php:293
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:208