ocs  2.3.6
About: OCS (Open Conference System) is a Web publishing tool that will create a complete Web presence for your scholarly conference.
  Fossies Dox: ocs-2.3.6.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

ReviewerSubmissionDAO.inc.php
Go to the documentation of this file.
1 <?php
2 
16 //$Id$
17 
18 import('submission.reviewer.ReviewerSubmission');
19 
20 class ReviewerSubmissionDAO extends DAO {
21  var $paperDao;
23  var $userDao;
29 
33  function ReviewerSubmissionDAO() {
34  parent::DAO();
35  $this->paperDao =& DAORegistry::getDAO('PaperDAO');
36  $this->authorDao =& DAORegistry::getDAO('AuthorDAO');
37  $this->userDao =& DAORegistry::getDAO('UserDAO');
38  $this->reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
39  $this->editAssignmentDao =& DAORegistry::getDAO('EditAssignmentDAO');
40  $this->paperFileDao =& DAORegistry::getDAO('PaperFileDAO');
41  $this->suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
42  $this->paperCommentDao =& DAORegistry::getDAO('PaperCommentDAO');
43  }
44 
51  function &getReviewerSubmission($reviewId) {
52  $primaryLocale = AppLocale::getPrimaryLocale();
53  $locale = AppLocale::getLocale();
54  $result =& $this->retrieve(
55  'SELECT p.*, r.*,
56  r2.review_revision,
57  u.first_name,
58  u.last_name,
59  COALESCE(ttl.setting_value, ttpl.setting_value) AS track_title,
60  COALESCE(tal.setting_value, tapl.setting_value) AS track_abbrev
61  FROM papers p
62  LEFT JOIN review_assignments r ON (p.paper_id = r.paper_id)
63  LEFT JOIN tracks t ON (t.track_id = p.track_id)
64  LEFT JOIN users u ON (r.reviewer_id = u.user_id)
65  LEFT JOIN review_stages r2 ON (p.paper_id = r2.paper_id AND r.stage = r2.stage)
66  LEFT JOIN track_settings ttpl ON (t.track_id = ttpl.track_id AND ttpl.setting_name = ? AND ttpl.locale = ?)
67  LEFT JOIN track_settings ttl ON (t.track_id = ttl.track_id AND ttl.setting_name = ? AND ttl.locale = ?)
68  LEFT JOIN track_settings tapl ON (t.track_id = tapl.track_id AND tapl.setting_name = ? AND tapl.locale = ?)
69  LEFT JOIN track_settings tal ON (t.track_id = tal.track_id AND tal.setting_name = ? AND tal.locale = ?)
70  WHERE r.review_id = ?',
71  array(
72  'title',
73  $primaryLocale,
74  'title',
75  $locale,
76  'abbrev',
77  $primaryLocale,
78  'abbrev',
79  $locale,
80  $reviewId
81  )
82  );
83 
84  $returner = null;
85  if ($result->RecordCount() != 0) {
86  $returner =& $this->_returnReviewerSubmissionFromRow($result->GetRowAssoc(false));
87  }
88 
89  $result->Close();
90  unset($result);
91 
92  return $returner;
93  }
94 
101  $reviewerSubmission = new ReviewerSubmission();
102 
103  // Director Assignment
104  $editAssignments =& $this->editAssignmentDao->getEditAssignmentsByPaperId($row['paper_id']);
105  $reviewerSubmission->setEditAssignments($editAssignments->toArray());
106 
107  // Files
108  $reviewerSubmission->setSubmissionFile($this->paperFileDao->getPaperFile($row['submission_file_id']));
109  $reviewerSubmission->setRevisedFile($this->paperFileDao->getPaperFile($row['revised_file_id']));
110  $reviewerSubmission->setSuppFiles($this->suppFileDao->getSuppFilesByPaper($row['paper_id']));
111  $reviewerSubmission->setReviewFile($this->paperFileDao->getPaperFile($row['review_file_id']));
112  $reviewerSubmission->setReviewerFile($this->paperFileDao->getPaperFile($row['reviewer_file_id']));
113  $reviewerSubmission->setReviewerFileRevisions($this->paperFileDao->getPaperFileRevisions($row['reviewer_file_id']));
114 
115  // Comments
116  $reviewerSubmission->setMostRecentPeerReviewComment($this->paperCommentDao->getMostRecentPaperComment($row['paper_id'], COMMENT_TYPE_PEER_REVIEW, $row['review_id']));
117 
118  // Director Decisions
119  for ($i = 1; $i <= $row['current_stage']; $i++) {
120  $reviewerSubmission->setDecisions($this->getDirectorDecisions($row['paper_id'], $i), $i);
121  }
122 
123  // Review Assignment
124  $reviewerSubmission->setReviewId($row['review_id']);
125  $reviewerSubmission->setReviewerId($row['reviewer_id']);
126  $reviewerSubmission->setReviewerFullName($row['first_name'].' '.$row['last_name']);
127  $reviewerSubmission->setRecommendation($row['recommendation']);
128  $reviewerSubmission->setDateAssigned($this->datetimeFromDB($row['date_assigned']));
129  $reviewerSubmission->setDateNotified($this->datetimeFromDB($row['date_notified']));
130  $reviewerSubmission->setDateConfirmed($this->datetimeFromDB($row['date_confirmed']));
131  $reviewerSubmission->setDateCompleted($this->datetimeFromDB($row['date_completed']));
132  $reviewerSubmission->setDateAcknowledged($this->datetimeFromDB($row['date_acknowledged']));
133  $reviewerSubmission->setDateDue($this->datetimeFromDB($row['date_due']));
134  $reviewerSubmission->setDeclined($row['declined']);
135  $reviewerSubmission->setReplaced($row['replaced']);
136  $reviewerSubmission->setCancelled($row['cancelled']==1?1:0);
137  $reviewerSubmission->setReviewerFileId($row['reviewer_file_id']);
138  $reviewerSubmission->setQuality($row['quality']);
139  $reviewerSubmission->setStage($row['stage']);
140  $reviewerSubmission->setReviewFileId($row['review_file_id']);
141  $reviewerSubmission->setReviewRevision($row['review_revision']);
142 
143  // Paper attributes
144  $this->paperDao->_paperFromRow($reviewerSubmission, $row);
145 
146  HookRegistry::call('ReviewerSubmissionDAO::_returnReviewerSubmissionFromRow', array(&$reviewerSubmission, &$row));
147 
148  return $reviewerSubmission;
149  }
150 
155  function updateReviewerSubmission(&$reviewerSubmission) {
156  return $this->update(
157  sprintf('UPDATE review_assignments
158  SET paper_id = ?,
159  reviewer_id = ?,
160  stage = ?,
161  recommendation = ?,
162  declined = ?,
163  replaced = ?,
164  cancelled = ?,
165  date_assigned = %s,
166  date_notified = %s,
167  date_confirmed = %s,
168  date_completed = %s,
169  date_acknowledged = %s,
170  date_due = %s,
171  reviewer_file_id = ?,
172  quality = ?
173  WHERE review_id = ?',
174  $this->datetimeToDB($reviewerSubmission->getDateAssigned()), $this->datetimeToDB($reviewerSubmission->getDateNotified()), $this->datetimeToDB($reviewerSubmission->getDateConfirmed()), $this->datetimeToDB($reviewerSubmission->getDateCompleted()), $this->datetimeToDB($reviewerSubmission->getDateAcknowledged()), $this->datetimeToDB($reviewerSubmission->getDateDue())),
175  array(
176  $reviewerSubmission->getPaperId(),
177  $reviewerSubmission->getReviewerId(),
178  $reviewerSubmission->getStage(),
179  $reviewerSubmission->getRecommendation(),
180  $reviewerSubmission->getDeclined(),
181  $reviewerSubmission->getReplaced(),
182  $reviewerSubmission->getCancelled(),
183  $reviewerSubmission->getReviewerFileId(),
184  $reviewerSubmission->getQuality(),
185  $reviewerSubmission->getReviewId()
186  )
187  );
188  }
189 
197  function &getReviewerSubmissionsByReviewerId($reviewerId, $schedConfId, $active = true, $rangeInfo = null) {
198  $primaryLocale = AppLocale::getPrimaryLocale();
199  $locale = AppLocale::getLocale();
200  $result =& $this->retrieveRange(
201  'SELECT p.*,
202  r.*,
203  r2.review_revision,
204  u.first_name,
205  u.last_name,
206  COALESCE(ttl.setting_value, ttpl.setting_value) AS track_title,
207  COALESCE(tal.setting_value, tapl.setting_value) AS track_abbrev
208  FROM papers p
209  LEFT JOIN review_assignments r ON (p.paper_id = r.paper_id)
210  LEFT JOIN tracks t ON (t.track_id = p.track_id)
211  LEFT JOIN users u ON (r.reviewer_id = u.user_id)
212  LEFT JOIN review_stages r2 ON (r.paper_id = r2.paper_id AND r.stage = r2.stage)
213  LEFT JOIN track_settings ttpl ON (t.track_id = ttpl.track_id AND ttpl.setting_name = ? AND ttpl.locale = ?)
214  LEFT JOIN track_settings ttl ON (t.track_id = ttl.track_id AND ttl.setting_name = ? AND ttl.locale = ?)
215  LEFT JOIN track_settings tapl ON (t.track_id = tapl.track_id AND tapl.setting_name = ? AND tapl.locale = ?)
216  LEFT JOIN track_settings tal ON (t.track_id = tal.track_id AND tal.setting_name = ? AND tal.locale = ?)
217  WHERE p.sched_conf_id = ? AND
218  r.reviewer_id = ? AND
219  r.date_notified IS NOT NULL' .
220  ($active?
221  ' AND r.date_completed IS NULL AND r.declined <> 1 AND (r.cancelled = 0 OR r.cancelled IS NULL) AND p.status = ' . STATUS_QUEUED:
222  ' AND (r.date_completed IS NOT NULL OR r.cancelled = 1 OR r.declined = 1 OR p.status <> ' . STATUS_QUEUED . ')'
223  ),
224  array(
225  'title',
226  $primaryLocale,
227  'title',
228  $locale,
229  'abbrev',
230  $primaryLocale,
231  'abbrev',
232  $locale,
233  $schedConfId,
234  $reviewerId
235  ),
236  $rangeInfo
237  );
238 
239 
240  $returner = new DAOResultFactory($result, $this, '_returnReviewerSubmissionFromRow');
241  return $returner;
242  }
243 
249  function getSubmissionsCount($reviewerId, $schedConfId) {
250  $submissionsCount = array();
251  $submissionsCount[0] = 0;
252  $submissionsCount[1] = 0;
253 
254  $sql = '
255  SELECT r.date_completed, r.declined, r.cancelled, a.status
256  FROM papers a
257  LEFT JOIN review_assignments r ON (a.paper_id = r.paper_id)
258  LEFT JOIN tracks t ON (t.track_id = a.track_id)
259  LEFT JOIN users u ON (r.reviewer_id = u.user_id)
260  LEFT JOIN review_stages r2 ON (r.paper_id = r2.paper_id AND r.stage = r2.stage)
261  WHERE a.sched_conf_id = ? AND r.reviewer_id = ? AND r.date_notified IS NOT NULL';
262 
263  $result =& $this->retrieve($sql, array($schedConfId, $reviewerId));
264 
265  while (!$result->EOF) {
266  if ($result->fields['date_completed'] == null && $result->fields['declined'] != 1 && $result->fields['cancelled'] != 1 && $result->fields['status'] == STATUS_QUEUED) {
267  $submissionsCount[0] += 1;
268  } else {
269  $submissionsCount[1] += 1;
270  }
271  $result->moveNext();
272  }
273 
274  $result->Close();
275  unset($result);
276 
277  return $submissionsCount;
278  }
279 
285  function getDirectorDecisions($paperId, $stage = null) {
286  $decisions = array();
287 
288  $args = array($paperId);
289  if($stage) {
290  $args[] = $stage;
291  }
292 
293  $result =& $this->retrieve('
294  SELECT edit_decision_id, director_id, decision, date_decided
295  FROM edit_decisions
296  WHERE paper_id = ?'
297  . ($stage?' AND stage = ?':'')
298  . ' ORDER BY edit_decision_id ASC',
299  count($args)==1?shift($args):$args);
300 
301  while (!$result->EOF) {
302  $decisions[] = array(
303  'editDecisionId' => $result->fields['edit_decision_id'],
304  'directorId' => $result->fields['director_id'],
305  'decision' => $result->fields['decision'],
306  'dateDecided' => $this->datetimeFromDB($result->fields['date_decided'])
307  );
308  $result->moveNext();
309  }
310 
311  $result->Close();
312  unset($result);
313 
314  return $decisions;
315  }
316 }
317 
318 ?>
const STATUS_QUEUED
Definition: Paper.inc.php:26
config TEMPLATE inc php
Definition: config.inc.php:4
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:30
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:62
const COMMENT_TYPE_PEER_REVIEW
& retrieveRange($sql, $params=false, $dbResultRange=null, $callHooks=true)
Definition: DAO.inc.php:152
getDirectorDecisions($paperId, $stage=null)
& getReviewerSubmissionsByReviewerId($reviewerId, $schedConfId, $active=true, $rangeInfo=null)
datetimeFromDB($dt)
Definition: DAO.inc.php:276
Wrapper around ADORecordSet providing "factory" features for generating objects from DAOs.
& getDAO($name, $dbconn=null)
ReviewerSubmission class.
updateReviewerSubmission(&$reviewerSubmission)
Operations for retrieving and modifying ReviewerSubmission objects.
call($hookName, $args=null)
getSubmissionsCount($reviewerId, $schedConfId)
datetimeToDB($dt)
Definition: DAO.inc.php:258
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:186