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)  

ReviewAssignmentDAO.inc.php
Go to the documentation of this file.
1 <?php
2 
16 //$Id$
17 
18 import('submission.reviewAssignment.ReviewAssignment');
19 
20 class ReviewAssignmentDAO extends DAO {
21  var $userDao;
25 
29  function ReviewAssignmentDAO() {
30  parent::DAO();
31  $this->userDao =& DAORegistry::getDAO('UserDAO');
32  $this->paperFileDao =& DAORegistry::getDAO('PaperFileDAO');
33  $this->suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
34  $this->paperCommentDao =& DAORegistry::getDAO('PaperCommentDAO');
35  }
36 
44  function &getReviewAssignment($paperId, $reviewerId, $stage) {
45  $result =& $this->retrieve(
46  'SELECT r.*, r2.review_revision, a.review_file_id, u.first_name, u.last_name FROM review_assignments r LEFT JOIN users u ON (r.reviewer_id = u.user_id) LEFT JOIN review_stages r2 ON (r.paper_id = r2.paper_id AND r.stage = r2.stage) LEFT JOIN papers a ON (r.paper_id = a.paper_id) WHERE r.paper_id = ? AND r.reviewer_id = ? AND r.cancelled <> 1 AND r.stage = ?',
47  array((int) $paperId, (int) $reviewerId, (int) $stage)
48  );
49 
50  $returner = null;
51  if ($result->RecordCount() != 0) {
52  $returner =& $this->_returnReviewAssignmentFromRow($result->GetRowAssoc(false));
53  }
54 
55  $result->Close();
56  unset($result);
57 
58  return $returner;
59  }
60 
66  function &getReviewAssignmentById($reviewId) {
67  $result =& $this->retrieve(
68  'SELECT r.*, r2.review_revision, a.review_file_id, u.first_name, u.last_name FROM review_assignments r LEFT JOIN users u ON (r.reviewer_id = u.user_id) LEFT JOIN review_stages r2 ON (r.paper_id = r2.paper_id AND r.stage = r2.stage) LEFT JOIN papers a ON (r.paper_id = a.paper_id) WHERE r.review_id = ?',
69  (int) $reviewId
70  );
71 
72  $returner = null;
73  if ($result->RecordCount() != 0) {
74  $returner =& $this->_returnReviewAssignmentFromRow($result->GetRowAssoc(false));
75  }
76 
77  $result->Close();
78  unset($result);
79 
80  return $returner;
81  }
82 
89  function &getReviewIndexesForStage($paperId, $stage) {
90  $returner = array();
91  $index = 0;
92  $result =& $this->retrieve(
93  'SELECT review_id FROM review_assignments WHERE paper_id = ? AND stage = ? AND (cancelled = 0 OR cancelled IS NULL) ORDER BY review_id',
94  array((int) $paperId, (int) $stage)
95  );
96 
97  while (!$result->EOF) {
98  $row = $result->GetRowAssoc(false);
99  $returner[$row['review_id']] = $index++;
100  $result->MoveNext();
101  }
102 
103  $result->Close();
104  unset($result);
105 
106  return $returner;
107  }
108 
109 
116  $reviewAssignments = array();
117 
118  $result =& $this->retrieve(
119  'SELECT r.*, r2.review_revision, a.review_file_id, u.first_name, u.last_name FROM review_assignments r LEFT JOIN users u ON (r.reviewer_id = u.user_id) LEFT JOIN review_stages r2 ON (r.paper_id = r2.paper_id AND r.stage = r2.stage) LEFT JOIN papers a ON (r.paper_id = a.paper_id) WHERE (r.cancelled IS NULL OR r.cancelled = 0) AND r.date_notified IS NOT NULL AND r.date_completed IS NULL ORDER BY r.paper_id'
120  );
121 
122  while (!$result->EOF) {
123  $reviewAssignments[] =& $this->_returnReviewAssignmentFromRow($result->GetRowAssoc(false));
124  $result->MoveNext();
125  }
126 
127  $result->Close();
128  unset($result);
129 
130  return $reviewAssignments;
131  }
132 
138  function &getReviewAssignmentsByPaperId($paperId, $stage = null) {
139  $reviewAssignments = array();
140 
141  $args = array((int) $paperId);
142  if ($stage) $args[] = (int) $stage;
143 
144  $result =& $this->retrieve('
145  SELECT r.*,
146  r2.review_revision,
147  a.review_file_id,
148  u.first_name,
149  u.last_name
150  FROM review_assignments r
151  LEFT JOIN users u ON (r.reviewer_id = u.user_id)
152  LEFT JOIN review_stages r2 ON (r.paper_id = r2.paper_id AND r.stage = r2.stage)
153  LEFT JOIN papers a ON (r.paper_id = a.paper_id)
154  WHERE r.paper_id = ? '
155  . ($stage ? ' AND r.stage = ?':'')
156  . ' ORDER BY ' . ($stage?'':' stage,') . 'review_id',
157  $args
158  );
159 
160  while (!$result->EOF) {
161  $reviewAssignments[] =& $this->_returnReviewAssignmentFromRow($result->GetRowAssoc(false));
162  $result->MoveNext();
163  }
164 
165  $result->Close();
166  unset($result);
167 
168  return $reviewAssignments;
169  }
170 
176  function &getReviewAssignmentsByUserId($userId) {
177  $reviewAssignments = array();
178 
179  $result =& $this->retrieve(
180  'SELECT r.*,
181  r2.review_revision,
182  a.review_file_id,
183  u.first_name,
184  u.last_name
185  FROM review_assignments r
186  LEFT JOIN users u ON (r.reviewer_id = u.user_id)
187  LEFT JOIN review_stages r2 ON (r.paper_id = r2.paper_id AND r.stage = r2.stage)
188  LEFT JOIN papers a ON (r.paper_id = a.paper_id) WHERE r.reviewer_id = ?
189  ORDER BY stage, review_id',
190  (int) $userId
191  );
192 
193  while (!$result->EOF) {
194  $reviewAssignments[] =& $this->_returnReviewAssignmentFromRow($result->GetRowAssoc(false));
195  $result->MoveNext();
196  }
197 
198  $result->Close();
199  unset($result);
200 
201  return $reviewAssignments;
202  }
203 
209  function &getReviewAssignmentsByReviewFormId($reviewFormId) {
210  $reviewAssignments = array();
211 
212  $result =& $this->retrieve(
213  'SELECT r.*, r2.review_revision, a.review_file_id, u.first_name, u.last_name FROM review_assignments r LEFT JOIN users u ON (r.reviewer_id = u.user_id) LEFT JOIN review_stages r2 ON (r.paper_id = r2.paper_id AND r.stage = r2.stage) LEFT JOIN papers a ON (r.paper_id = a.paper_id) WHERE r.review_form_id = ? ORDER BY stage, review_id',
214  (int) $reviewFormId
215  );
216 
217  while (!$result->EOF) {
218  $reviewAssignments[] =& $this->_returnReviewAssignmentFromRow($result->GetRowAssoc(false));
219  $result->MoveNext();
220  }
221 
222  $result->Close();
223  unset($result);
224 
225  return $reviewAssignments;
226  }
227 
233  function &getReviewFilesByStage($paperId) {
234  $returner = array();
235 
236  $result =& $this->retrieve('
237  SELECT a.*,
238  r.stage as stage
239  FROM review_stages r,
240  paper_files a,
241  papers art
242  WHERE art.paper_id=r.paper_id
243  AND r.paper_id=?
244  AND r.paper_id=a.paper_id
245  AND a.file_id=art.review_file_id
246  AND a.revision=r.review_revision
247  AND a.paper_id=r.paper_id',
248  (int) $paperId
249  );
250 
251  while (!$result->EOF) {
252  $row = $result->GetRowAssoc(false);
253  $returner[$row['stage']] =& $this->paperFileDao->_returnPaperFileFromRow($row);
254  $result->MoveNext();
255  }
256 
257  $result->Close();
258  unset($result);
259 
260  return $returner;
261  }
262 
268  function &getAuthorViewableFilesByStage($paperId) {
269  $files = array();
270 
271  $result =& $this->retrieve(
272  'SELECT f.*, a.reviewer_id AS reviewer_id
273  FROM review_assignments a,
274  paper_files f
275  WHERE reviewer_file_id = file_id
276  AND viewable = 1
277  AND a.paper_id = ?
278  ORDER BY a.stage, a.reviewer_id, a.review_id',
279  array((int) $paperId)
280  );
281 
282  while (!$result->EOF) {
283  $row = $result->GetRowAssoc(false);
284  if (!isset($files[$row['stage']]) || !is_array($files[$row['stage']])) {
285  $files[$row['stage']] = array();
286  $thisReviewerId = $row['reviewer_id'];
287  $reviewerIndex = 0;
288  }
289  else if ($thisReviewerId != $row['reviewer_id']) {
290  $thisReviewerId = $row['reviewer_id'];
291  $reviewerIndex++;
292  }
293 
294  $thisPaperFile =& $this->paperFileDao->_returnPaperFileFromRow($row);
295  $files[$row['stage']][$reviewerIndex][] = $thisPaperFile;
296  $result->MoveNext();
297  }
298 
299  $result->Close();
300  unset($result);
301 
302  return $files;
303  }
304 
311  function &getLastModifiedByStage($paperId) {
312  $returner = array();
313 
314  $result =& $this->retrieve(
315  'SELECT stage, MAX(last_modified) as last_modified FROM review_assignments WHERE paper_id=? GROUP BY stage',
316  array((int) $paperId)
317  );
318 
319  while (!$result->EOF) {
320  $row = $result->GetRowAssoc(false);
321  $returner[$row['stage']] = $this->datetimeFromDB($row['last_modified']);
322  $result->MoveNext();
323  }
324 
325  $result->Close();
326  unset($result);
327 
328  return $returner;
329  }
330 
337  function &getEarliestNotificationByStage($paperId) {
338  $returner = array();
339 
340  $result =& $this->retrieve(
341  'SELECT stage, MIN(date_notified) as earliest_date FROM review_assignments WHERE paper_id=? GROUP BY stage',
342  array((int) $paperId)
343  );
344 
345  while (!$result->EOF) {
346  $row = $result->GetRowAssoc(false);
347  $returner[$row['stage']] = $this->datetimeFromDB($row['earliest_date']);
348  $result->MoveNext();
349  }
350 
351  $result->Close();
352  unset($result);
353 
354  return $returner;
355  }
356 
362  function &getCancelsAndRegrets($paperId) {
363  $reviewAssignments = array();
364 
365  $result =& $this->retrieve(
366  'SELECT r.*, r2.review_revision, a.review_file_id, u.first_name, u.last_name FROM review_assignments r LEFT JOIN users u ON (r.reviewer_id = u.user_id) LEFT JOIN review_stages r2 ON (r.paper_id = r2.paper_id AND r.stage = r2.stage) LEFT JOIN papers a ON (r.paper_id = a.paper_id) WHERE r.paper_id = ? AND (r.cancelled = 1 OR r.declined = 1) ORDER BY stage, review_id',
367  (int) $paperId
368  );
369 
370  while (!$result->EOF) {
371  $reviewAssignments[] =& $this->_returnReviewAssignmentFromRow($result->GetRowAssoc(false));
372  $result->MoveNext();
373  }
374 
375  $result->Close();
376  unset($result);
377 
378  return $reviewAssignments;
379  }
380 
387  $reviewAssignment = new ReviewAssignment();
388  $reviewAssignment->setId($row['review_id']);
389  $reviewAssignment->setPaperId($row['paper_id']);
390  $reviewAssignment->setReviewerId($row['reviewer_id']);
391  $reviewAssignment->setReviewerFullName($row['first_name'].' '.$row['last_name']);
392  $reviewAssignment->setRecommendation($row['recommendation']);
393  $reviewAssignment->setDateAssigned($this->datetimeFromDB($row['date_assigned']));
394  $reviewAssignment->setDateNotified($this->datetimeFromDB($row['date_notified']));
395  $reviewAssignment->setDateConfirmed($this->datetimeFromDB($row['date_confirmed']));
396  $reviewAssignment->setDateCompleted($this->datetimeFromDB($row['date_completed']));
397  $reviewAssignment->setDateAcknowledged($this->datetimeFromDB($row['date_acknowledged']));
398  $reviewAssignment->setDateDue($this->datetimeFromDB($row['date_due']));
399  $reviewAssignment->setLastModified($this->datetimeFromDB($row['last_modified']));
400  $reviewAssignment->setDeclined($row['declined']);
401  $reviewAssignment->setReplaced($row['replaced']);
402  $reviewAssignment->setCancelled($row['cancelled']);
403  $reviewAssignment->setReviewerFileId($row['reviewer_file_id']);
404  $reviewAssignment->setQuality($row['quality']);
405  $reviewAssignment->setDateRated($this->datetimeFromDB($row['date_rated']));
406  $reviewAssignment->setDateReminded($this->datetimeFromDB($row['date_reminded']));
407  $reviewAssignment->setReminderWasAutomatic($row['reminder_was_automatic']);
408  $reviewAssignment->setStage($row['stage']);
409  $reviewAssignment->setReviewFileId($row['review_file_id']);
410  $reviewAssignment->setReviewRevision($row['review_revision']);
411  $reviewAssignment->setReviewFormId($row['review_form_id']);
412 
413  // Files
414  $reviewAssignment->setReviewFile($this->paperFileDao->getPaperFile($row['review_file_id'], $row['review_revision']));
415  $reviewAssignment->setReviewerFile($this->paperFileDao->getPaperFile($row['reviewer_file_id']));
416  $reviewAssignment->setReviewerFileRevisions($this->paperFileDao->getPaperFileRevisions($row['reviewer_file_id']));
417  $reviewAssignment->setSuppFiles($this->suppFileDao->getSuppFilesByPaper($row['paper_id']));
418 
419 
420  // Comments
421  $reviewAssignment->setMostRecentPeerReviewComment($this->paperCommentDao->getMostRecentPaperComment($row['paper_id'], COMMENT_TYPE_PEER_REVIEW, $row['review_id']));
422 
423  HookRegistry::call('ReviewAssignmentDAO::_returnReviewAssignmentFromRow', array(&$reviewAssignment, &$row));
424 
425  return $reviewAssignment;
426  }
427 
432  function insertReviewAssignment(&$reviewAssignment) {
433  $this->update(
434  sprintf('INSERT INTO review_assignments
435  (paper_id, reviewer_id, stage, recommendation, declined, replaced, cancelled, date_assigned, date_notified, date_confirmed, date_completed, date_acknowledged, date_due, reviewer_file_id, quality, date_rated, last_modified, date_reminded, reminder_was_automatic, review_form_id)
436  VALUES
437  (?, ?, ?, ?, ?, ?, ?, %s, %s, %s, %s, %s, %s, ?, ?, %s, %s, %s, ?, ?)',
438  $this->datetimeToDB($reviewAssignment->getDateAssigned()), $this->datetimeToDB($reviewAssignment->getDateNotified()), $this->datetimeToDB($reviewAssignment->getDateConfirmed()), $this->datetimeToDB($reviewAssignment->getDateCompleted()), $this->datetimeToDB($reviewAssignment->getDateAcknowledged()), $this->datetimeToDB($reviewAssignment->getDateDue()), $this->datetimeToDB($reviewAssignment->getDateRated()), $this->datetimeToDB($reviewAssignment->getLastModified()), $this->datetimeToDB($reviewAssignment->getDateReminded())),
439  array(
440  (int) $reviewAssignment->getPaperId(),
441  (int) $reviewAssignment->getReviewerId(),
442  max((int) $reviewAssignment->getStage(), 1),
443  $reviewAssignment->getRecommendation(),
444  (int) $reviewAssignment->getDeclined(),
445  (int) $reviewAssignment->getReplaced(),
446  (int) $reviewAssignment->getCancelled(),
447  $reviewAssignment->getReviewerFileId(),
448  $reviewAssignment->getQuality(),
449  $reviewAssignment->getReminderWasAutomatic(),
450  $reviewAssignment->getReviewFormId()
451  )
452  );
453 
454  $reviewAssignment->setId($this->getInsertReviewId());
455  return $reviewAssignment->getId();
456  }
457 
462  function updateReviewAssignment(&$reviewAssignment) {
463  return $this->update(
464  sprintf('UPDATE review_assignments
465  SET paper_id = ?,
466  reviewer_id = ?,
467  stage = ?,
468  recommendation = ?,
469  declined = ?,
470  replaced = ?,
471  cancelled = ?,
472  date_assigned = %s,
473  date_notified = %s,
474  date_confirmed = %s,
475  date_completed = %s,
476  date_acknowledged = %s,
477  date_due = %s,
478  reviewer_file_id = ?,
479  quality = ?,
480  date_rated = %s,
481  last_modified = %s,
482  date_reminded = %s,
483  reminder_was_automatic = ?,
484  review_form_id = ?
485  WHERE review_id = ?',
486  $this->datetimeToDB($reviewAssignment->getDateAssigned()), $this->datetimeToDB($reviewAssignment->getDateNotified()), $this->datetimeToDB($reviewAssignment->getDateConfirmed()), $this->datetimeToDB($reviewAssignment->getDateCompleted()), $this->datetimeToDB($reviewAssignment->getDateAcknowledged()), $this->datetimeToDB($reviewAssignment->getDateDue()), $this->datetimeToDB($reviewAssignment->getDateRated()), $this->datetimeToDB($reviewAssignment->getLastModified()), $this->datetimeToDB($reviewAssignment->getDateReminded())),
487  array(
488  (int) $reviewAssignment->getPaperId(),
489  (int) $reviewAssignment->getReviewerId(),
490  (int) $reviewAssignment->getStage(),
491  $reviewAssignment->getRecommendation(),
492  (int) $reviewAssignment->getDeclined(),
493  (int) $reviewAssignment->getReplaced(),
494  (int) $reviewAssignment->getCancelled(),
495  $reviewAssignment->getReviewerFileId(),
496  $reviewAssignment->getQuality(),
497  $reviewAssignment->getReminderWasAutomatic(),
498  $reviewAssignment->getReviewFormId(),
499  (int) $reviewAssignment->getId()
500  )
501  );
502  }
503 
508  function deleteReviewAssignmentById($reviewId) {
509  $reviewFormResponseDao =& DAORegistry::getDAO('ReviewFormResponseDAO');
510  $reviewFormResponseDao->deleteByReviewId($reviewId);
511 
512  return $this->update(
513  'DELETE FROM review_assignments WHERE review_id = ?',
514  (int) $reviewId
515  );
516  }
517 
523  function deleteReviewAssignmentsByPaper($paperId) {
524  $returner = false;
525  $result =& $this->retrieve(
526  'SELECT review_id FROM review_assignments WHERE paper_id = ?',
527  (int) $paperId
528  );
529 
530  while (!$result->EOF) {
531  $row = $result->GetRowAssoc(false);
532  $reviewId = $row['review_id'];
533 
534  $this->update('DELETE FROM review_form_responses WHERE review_id = ?', $reviewId);
535  $this->update('DELETE FROM review_assignments WHERE review_id = ?', $reviewId);
536 
537  $result->MoveNext();
538  $returner = true;
539  }
540  $result->Close();
541  return $returner;
542  }
543 
548  function getInsertReviewId() {
549  return $this->getInsertId('review_assignments', 'review_id');
550  }
551 
556  function getAverageQualityRatings($schedConfId) {
557  $averageQualityRatings = Array();
558  $result =& $this->retrieve(
559  'SELECT R.reviewer_id, AVG(R.quality) AS average, COUNT(R.quality) AS count FROM review_assignments R, papers A WHERE R.paper_id = A.paper_id AND A.sched_conf_id = ? GROUP BY R.reviewer_id',
560  (int) $schedConfId
561  );
562 
563  while (!$result->EOF) {
564  $row = $result->GetRowAssoc(false);
565  $averageQualityRatings[$row['reviewer_id']] = array('average' => $row['average'], 'count' => $row['count']);
566  $result->MoveNext();
567  }
568 
569  $result->Close();
570  unset($result);
571 
572  return $averageQualityRatings;
573  }
574 
579  function getCompletedReviewCounts($schedConfId) {
580  $returner = Array();
581  $result =& $this->retrieve(
582  'SELECT r.reviewer_id, COUNT(r.review_id) AS count FROM review_assignments r, papers a WHERE r.paper_id = a.paper_id AND a.sched_conf_id = ? AND r.date_completed IS NOT NULL AND r.cancelled = 0 GROUP BY r.reviewer_id',
583  (int) $schedConfId
584  );
585 
586  while (!$result->EOF) {
587  $row = $result->GetRowAssoc(false);
588  $returner[$row['reviewer_id']] = $row['count'];
589  $result->MoveNext();
590  }
591 
592  $result->Close();
593  unset($result);
594 
595  return $returner;
596  }
597 }
598 
599 ?>
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
updateReviewAssignment(&$reviewAssignment)
getInsertId($table='', $id='', $callHooks=true)
Definition: DAO.inc.php:225
const COMMENT_TYPE_PEER_REVIEW
& getReviewIndexesForStage($paperId, $stage)
& getReviewAssignment($paperId, $reviewerId, $stage)
datetimeFromDB($dt)
Definition: DAO.inc.php:276
& getReviewAssignmentsByPaperId($paperId, $stage=null)
getAverageQualityRatings($schedConfId)
& getDAO($name, $dbconn=null)
getCompletedReviewCounts($schedConfId)
& getEarliestNotificationByStage($paperId)
insertReviewAssignment(&$reviewAssignment)
call($hookName, $args=null)
datetimeToDB($dt)
Definition: DAO.inc.php:258
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:186
& getReviewAssignmentsByReviewFormId($reviewFormId)
Describes review assignment properties.
Class for DAO relating reviewers to papers.