Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
SeriesEditorSubmissionDAO.inc.php
1 <?php
2 
18 import('classes.submission.seriesEditor.SeriesEditorSubmission');
19 import('classes.monograph.MonographDAO');
20 
21 // Bring in editor decision constants
22 import('classes.submission.reviewer.ReviewerSubmission');
23 
25  var $authorDao;
26  var $userDao;
27  var $reviewAssignmentDao;
28  var $submissionFileDao;
29  var $signoffDao;
30  var $submissionEmailLogDao;
31  var $submissionCommentDao;
32  var $reviewRoundDao;
33 
38  parent::MonographDAO();
39  $this->authorDao = DAORegistry::getDAO('AuthorDAO');
40  $this->userDao = DAORegistry::getDAO('UserDAO');
41  $this->reviewAssignmentDao = DAORegistry::getDAO('ReviewAssignmentDAO');
42  $this->submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO');
43  $this->signoffDao = DAORegistry::getDAO('SignoffDAO');
44  $this->submissionEmailLogDao = DAORegistry::getDAO('SubmissionEmailLogDAO');
45  $this->submissionCommentDao = DAORegistry::getDAO('SubmissionCommentDAO');
46  $this->reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO');
47  }
48 
54  function getById($monographId) {
55  $primaryLocale = AppLocale::getPrimaryLocale();
56  $locale = AppLocale::getLocale();
57  $result = $this->retrieve(
58  'SELECT m.*, ps.date_published,
59  COALESCE(stl.setting_value, stpl.setting_value) AS series_title,
60  COALESCE(sal.setting_value, sapl.setting_value) AS series_abbrev
61  FROM submissions m
62  LEFT JOIN published_submissions ps ON (ps.submission_id = m.submission_id)
63  LEFT JOIN series s ON (s.series_id = m.series_id)
64  LEFT JOIN series_settings stpl ON (s.series_id = stpl.series_id AND stpl.setting_name = ? AND stpl.locale = ?)
65  LEFT JOIN series_settings stl ON (s.series_id = stl.series_id AND stl.setting_name = ? AND stl.locale = ?)
66  LEFT JOIN series_settings sapl ON (s.series_id = sapl.series_id AND sapl.setting_name = ? AND sapl.locale = ?)
67  LEFT JOIN series_settings sal ON (s.series_id = sal.series_id AND sal.setting_name = ? AND sal.locale = ?)
68  WHERE m.submission_id = ?',
69  array(
70  'title', $primaryLocale, // Series title
71  'title', $locale, // Series title
72  'abbrev', $primaryLocale, // Series abbreviation
73  'abbrev', $locale, // Series abbreviation
74  (int) $monographId
75  )
76  );
77 
78  $returner = null;
79  if ($result->RecordCount() != 0) {
80  $returner = $this->_fromRow($result->GetRowAssoc(false));
81  }
82 
83  $result->Close();
84  return $returner;
85  }
86 
91  function newDataObject() {
92  return new SeriesEditorSubmission();
93  }
94 
100  function _fromRow($row) {
101  // Populate the monograph parts of the object
102  $seriesEditorSubmission = parent::_fromRow($row);
103 
104  // Editor Decisions
105  $reviewRounds = $this->reviewRoundDao->getBySubmissionId($row['submission_id']);
106  $editDecisionDao = DAORegistry::getDAO('EditDecisionDAO');
107  while ($reviewRound = $reviewRounds->next()) {
108  $stageId = $reviewRound->getStageId();
109  $round = $reviewRound->getRound();
110  $seriesEditorSubmission->setDecisions(
111  $editDecisionDao->getEditorDecisions($row['submission_id'], $stageId, $round),
112  $stageId,
113  $round
114  );
115  }
116 
117  // Comments
118  $seriesEditorSubmission->setMostRecentEditorDecisionComment($this->submissionCommentDao->getMostRecentSubmissionComment($row['submission_id'], COMMENT_TYPE_EDITOR_DECISION, $row['submission_id']));
119  $seriesEditorSubmission->setMostRecentCopyeditComment($this->submissionCommentDao->getMostRecentSubmissionComment($row['submission_id'], COMMENT_TYPE_COPYEDIT, $row['submission_id']));
120  $seriesEditorSubmission->setMostRecentLayoutComment($this->submissionCommentDao->getMostRecentSubmissionComment($row['submission_id'], COMMENT_TYPE_LAYOUT, $row['submission_id']));
121  $seriesEditorSubmission->setMostRecentProofreadComment($this->submissionCommentDao->getMostRecentSubmissionComment($row['submission_id'], COMMENT_TYPE_PROOFREAD, $row['submission_id']));
122 
123  // Review Assignments
124  $reviewRounds = $this->reviewRoundDao->getBySubmissionId($row['submission_id']);
125  while ($reviewRound = $reviewRounds->next()) {
126  $stageId = $reviewRound->getStageId();
127  $round = $reviewRound->getRound();
128  $seriesEditorSubmission->setReviewAssignments(
129  $this->reviewAssignmentDao->getBySubmissionId($row['submission_id'], $reviewRound->getId()),
130  $stageId,
131  $round
132  );
133  }
134 
135  HookRegistry::call('SeriesEditorSubmissionDAO::_fromRow', array(&$seriesEditorSubmission, &$row));
136 
137  return $seriesEditorSubmission;
138  }
139 
144  function updateSeriesEditorSubmission(&$seriesEditorSubmission) {
145  $monographId = $seriesEditorSubmission->getId();
146 
147  // Get all submission editor decisions.
148  $editorDecisions = $seriesEditorSubmission->getDecisions();
149 
150  // Update review stages editor decisions.
151  $reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO'); /* @var $reviewRoundDao ReviewRoundDAO */
152  $reviewRounds = $reviewRoundDao->getBySubmissionId($monographId);
153 
154  $editDecisionDao = DAORegistry::getDAO('EditDecisionDAO');
155  while ($reviewRound = $reviewRounds->next()) {
156  $stageId = $reviewRound->getStageId();
157  $round = $reviewRound->getRound();
158  $reviewStageEditorDecisions = array();
159  if (isset($editorDecisions[$stageId][$round])) {
160  $reviewStageEditorDecisions = $editorDecisions[$stageId][$round];
161  unset($editorDecisions[$stageId][$round]);
162  }
163  foreach ($reviewStageEditorDecisions as $editorDecision) {
164  $editDecisionDao->updateEditorDecision($monographId, $editorDecision, $stageId, $reviewRound);
165  }
166  }
167 
168  // Update the remaining stages editor decisions.
169  foreach ($editorDecisions as $stageId => $stageEditorDecision) {
170  if (isset($stageEditorDecision[REVIEW_ROUND_NONE])) {
171  foreach ($stageEditorDecision[REVIEW_ROUND_NONE] as $editorDecision) {
172  $editDecisionDao->updateEditorDecision($monographId, $editorDecision, $stageId);
173  }
174  }
175  }
176 
177  // update review assignments
178  $removedReviewAssignments =& $seriesEditorSubmission->getRemovedReviewAssignments();
179 
180  unset($reviewRounds);
181  $reviewRounds =& $reviewRoundDao->getBySubmissionId($monographId);
182 
183  while ($reviewRound = $reviewRounds->next()) {
184  $stageId = $reviewRound->getStageId();
185  $round = $reviewRound->getRound();
186  foreach ($seriesEditorSubmission->getReviewAssignments($stageId, $round) as $reviewAssignment) {
187  if (isset($removedReviewAssignments[$reviewAssignment->getId()])) continue;
188 
189  if ($reviewAssignment->getId() > 0) {
190  $this->reviewAssignmentDao->updateObject($reviewAssignment);
191  } else {
192  $this->reviewAssignmentDao->insertObject($reviewAssignment);
193  }
194  }
195  }
196 
197  // Remove deleted review assignments
198  foreach ($removedReviewAssignments as $removedReviewAssignmentId) {
199  $this->reviewAssignmentDao->deleteById($removedReviewAssignmentId);
200  }
201 
202  // Update monograph
203  if ($seriesEditorSubmission->getId()) {
204  $monograph = parent::getById($monographId);
205 
206  // Only update fields that can actually be edited.
207  $monograph->setSeriesId($seriesEditorSubmission->getSeriesId());
208  $monograph->setStatus($seriesEditorSubmission->getStatus());
209  $monograph->setDateStatusModified($seriesEditorSubmission->getDateStatusModified());
210  $monograph->setLastModified($seriesEditorSubmission->getLastModified());
211  $monograph->setCommentsStatus($seriesEditorSubmission->getCommentsStatus());
212 
213  parent::updateObject($monograph);
214  }
215  }
216 }
217 
218 ?>
static & getDAO($name, $dbconn=null)
static getPrimaryLocale()
Operations for retrieving and modifying SeriesEditorSubmission objects. FIXME #5557: We need a genera...
Operations for retrieving and modifying Monograph objects.
SeriesEditorSubmission class.
static getLocale()
static call($hookName, $args=null)
updateSeriesEditorSubmission(&$seriesEditorSubmission)