classes/submission/reviewer/ReviewerSubmissionDAO.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00016 //$Id$
00017 
00018 import('submission.reviewer.ReviewerSubmission');
00019 
00020 class ReviewerSubmissionDAO extends DAO {
00021    var $paperDao;
00022    var $authorDao;
00023    var $userDao;
00024    var $reviewAssignmentDao;
00025    var $editAssignmentDao;
00026    var $paperFileDao;
00027    var $suppFileDao;
00028    var $paperCommentDao;
00029 
00033    function ReviewerSubmissionDAO() {
00034       parent::DAO();
00035       $this->paperDao =& DAORegistry::getDAO('PaperDAO');
00036       $this->authorDao =& DAORegistry::getDAO('AuthorDAO');
00037       $this->userDao =& DAORegistry::getDAO('UserDAO');
00038       $this->reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
00039       $this->editAssignmentDao =& DAORegistry::getDAO('EditAssignmentDAO');
00040       $this->paperFileDao =& DAORegistry::getDAO('PaperFileDAO');
00041       $this->suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
00042       $this->paperCommentDao =& DAORegistry::getDAO('PaperCommentDAO');
00043    }
00044 
00051    function &getReviewerSubmission($reviewId) {
00052       $primaryLocale = AppLocale::getPrimaryLocale();
00053       $locale = AppLocale::getLocale();
00054       $result =& $this->retrieve(
00055          'SELECT  p.*, r.*,
00056             r2.review_revision,
00057             u.first_name,
00058             u.last_name,
00059             COALESCE(ttl.setting_value, ttpl.setting_value) AS track_title,
00060             COALESCE(tal.setting_value, tapl.setting_value) AS track_abbrev
00061          FROM  papers p
00062             LEFT JOIN review_assignments r ON (p.paper_id = r.paper_id)
00063             LEFT JOIN tracks t ON (t.track_id = p.track_id)
00064             LEFT JOIN users u ON (r.reviewer_id = u.user_id)
00065             LEFT JOIN review_stages r2 ON (p.paper_id = r2.paper_id AND r.stage = r2.stage)
00066             LEFT JOIN track_settings ttpl ON (t.track_id = ttpl.track_id AND ttpl.setting_name = ? AND ttpl.locale = ?)
00067             LEFT JOIN track_settings ttl ON (t.track_id = ttl.track_id AND ttl.setting_name = ? AND ttl.locale = ?)
00068             LEFT JOIN track_settings tapl ON (t.track_id = tapl.track_id AND tapl.setting_name = ? AND tapl.locale = ?)
00069             LEFT JOIN track_settings tal ON (t.track_id = tal.track_id AND tal.setting_name = ? AND tal.locale = ?)
00070          WHERE r.review_id = ?',
00071          array(
00072             'title',
00073             $primaryLocale,
00074             'title',
00075             $locale,
00076             'abbrev',
00077             $primaryLocale,
00078             'abbrev',
00079             $locale,
00080             $reviewId
00081          )
00082       );
00083 
00084       $returner = null;
00085       if ($result->RecordCount() != 0) {
00086          $returner =& $this->_returnReviewerSubmissionFromRow($result->GetRowAssoc(false));
00087       }
00088 
00089       $result->Close();
00090       unset($result);
00091 
00092       return $returner;
00093    }
00094 
00100    function &_returnReviewerSubmissionFromRow(&$row) {
00101       $reviewerSubmission = new ReviewerSubmission();
00102 
00103       // Director Assignment
00104       $editAssignments =& $this->editAssignmentDao->getEditAssignmentsByPaperId($row['paper_id']);
00105       $reviewerSubmission->setEditAssignments($editAssignments->toArray());
00106 
00107       // Files
00108       $reviewerSubmission->setSubmissionFile($this->paperFileDao->getPaperFile($row['submission_file_id']));
00109       $reviewerSubmission->setRevisedFile($this->paperFileDao->getPaperFile($row['revised_file_id']));
00110       $reviewerSubmission->setSuppFiles($this->suppFileDao->getSuppFilesByPaper($row['paper_id']));
00111       $reviewerSubmission->setReviewFile($this->paperFileDao->getPaperFile($row['review_file_id']));
00112       $reviewerSubmission->setReviewerFile($this->paperFileDao->getPaperFile($row['reviewer_file_id']));
00113       $reviewerSubmission->setReviewerFileRevisions($this->paperFileDao->getPaperFileRevisions($row['reviewer_file_id']));
00114 
00115       // Comments
00116       $reviewerSubmission->setMostRecentPeerReviewComment($this->paperCommentDao->getMostRecentPaperComment($row['paper_id'], COMMENT_TYPE_PEER_REVIEW, $row['review_id']));
00117 
00118       // Director Decisions
00119       for ($i = 1; $i <= $row['current_stage']; $i++) {
00120          $reviewerSubmission->setDecisions($this->getDirectorDecisions($row['paper_id'], $i), $i);
00121       }
00122 
00123       // Review Assignment 
00124       $reviewerSubmission->setReviewId($row['review_id']);
00125       $reviewerSubmission->setReviewerId($row['reviewer_id']);
00126       $reviewerSubmission->setReviewerFullName($row['first_name'].' '.$row['last_name']);
00127       $reviewerSubmission->setRecommendation($row['recommendation']);
00128       $reviewerSubmission->setDateAssigned($this->datetimeFromDB($row['date_assigned']));
00129       $reviewerSubmission->setDateNotified($this->datetimeFromDB($row['date_notified']));
00130       $reviewerSubmission->setDateConfirmed($this->datetimeFromDB($row['date_confirmed']));
00131       $reviewerSubmission->setDateCompleted($this->datetimeFromDB($row['date_completed']));
00132       $reviewerSubmission->setDateAcknowledged($this->datetimeFromDB($row['date_acknowledged']));
00133       $reviewerSubmission->setDateDue($this->datetimeFromDB($row['date_due']));
00134       $reviewerSubmission->setDeclined($row['declined']);
00135       $reviewerSubmission->setReplaced($row['replaced']);
00136       $reviewerSubmission->setCancelled($row['cancelled']==1?1:0);
00137       $reviewerSubmission->setReviewerFileId($row['reviewer_file_id']);
00138       $reviewerSubmission->setQuality($row['quality']);
00139       $reviewerSubmission->setStage($row['stage']);
00140       $reviewerSubmission->setReviewFileId($row['review_file_id']);
00141       $reviewerSubmission->setReviewRevision($row['review_revision']);
00142 
00143       // Paper attributes
00144       $this->paperDao->_paperFromRow($reviewerSubmission, $row);
00145 
00146       HookRegistry::call('ReviewerSubmissionDAO::_returnReviewerSubmissionFromRow', array(&$reviewerSubmission, &$row));
00147 
00148       return $reviewerSubmission;
00149    }
00150 
00155    function updateReviewerSubmission(&$reviewerSubmission) {
00156       return $this->update(
00157          sprintf('UPDATE review_assignments
00158             SET   paper_id = ?,
00159                reviewer_id = ?,
00160                stage = ?,
00161                recommendation = ?,
00162                declined = ?,
00163                replaced = ?,
00164                cancelled = ?,
00165                date_assigned = %s,
00166                date_notified = %s,
00167                date_confirmed = %s,
00168                date_completed = %s,
00169                date_acknowledged = %s,
00170                date_due = %s,
00171                reviewer_file_id = ?,
00172                quality = ?
00173             WHERE review_id = ?',
00174             $this->datetimeToDB($reviewerSubmission->getDateAssigned()), $this->datetimeToDB($reviewerSubmission->getDateNotified()), $this->datetimeToDB($reviewerSubmission->getDateConfirmed()), $this->datetimeToDB($reviewerSubmission->getDateCompleted()), $this->datetimeToDB($reviewerSubmission->getDateAcknowledged()), $this->datetimeToDB($reviewerSubmission->getDateDue())),
00175          array(
00176             $reviewerSubmission->getPaperId(),
00177             $reviewerSubmission->getReviewerId(),
00178             $reviewerSubmission->getStage(),
00179             $reviewerSubmission->getRecommendation(),
00180             $reviewerSubmission->getDeclined(),
00181             $reviewerSubmission->getReplaced(),
00182             $reviewerSubmission->getCancelled(),
00183             $reviewerSubmission->getReviewerFileId(),
00184             $reviewerSubmission->getQuality(),
00185             $reviewerSubmission->getReviewId()
00186          )
00187       );
00188    }
00189 
00197    function &getReviewerSubmissionsByReviewerId($reviewerId, $schedConfId, $active = true, $rangeInfo = null) {
00198       $primaryLocale = AppLocale::getPrimaryLocale();
00199       $locale = AppLocale::getLocale();
00200       $result =& $this->retrieveRange(
00201          'SELECT  p.*,
00202             r.*,
00203             r2.review_revision,
00204             u.first_name,
00205             u.last_name,
00206             COALESCE(ttl.setting_value, ttpl.setting_value) AS track_title,
00207             COALESCE(tal.setting_value, tapl.setting_value) AS track_abbrev
00208          FROM papers p
00209             LEFT JOIN review_assignments r ON (p.paper_id = r.paper_id)
00210             LEFT JOIN tracks t ON (t.track_id = p.track_id)
00211             LEFT JOIN users u ON (r.reviewer_id = u.user_id)
00212             LEFT JOIN review_stages r2 ON (r.paper_id = r2.paper_id AND r.stage = r2.stage)
00213             LEFT JOIN track_settings ttpl ON (t.track_id = ttpl.track_id AND ttpl.setting_name = ? AND ttpl.locale = ?)
00214             LEFT JOIN track_settings ttl ON (t.track_id = ttl.track_id AND ttl.setting_name = ? AND ttl.locale = ?)
00215             LEFT JOIN track_settings tapl ON (t.track_id = tapl.track_id AND tapl.setting_name = ? AND tapl.locale = ?)
00216             LEFT JOIN track_settings tal ON (t.track_id = tal.track_id AND tal.setting_name = ? AND tal.locale = ?)
00217          WHERE p.sched_conf_id = ? AND
00218             r.reviewer_id = ? AND
00219             r.date_notified IS NOT NULL' .
00220             ($active?
00221                ' AND r.date_completed IS NULL AND r.declined <> 1 AND (r.cancelled = 0 OR r.cancelled IS NULL)':
00222                ' AND (r.date_completed IS NOT NULL OR r.cancelled = 1 OR r.declined = 1)'
00223             ),
00224          array(
00225             'title',
00226             $primaryLocale,
00227             'title',
00228             $locale,
00229             'abbrev',
00230             $primaryLocale,
00231             'abbrev',
00232             $locale,
00233             $schedConfId,
00234             $reviewerId
00235          ),
00236          $rangeInfo
00237       );
00238 
00239 
00240       $returner = new DAOResultFactory($result, $this, '_returnReviewerSubmissionFromRow');
00241       return $returner;
00242    }
00243 
00249    function getSubmissionsCount($reviewerId, $schedConfId) {
00250       $submissionsCount = array();
00251       $submissionsCount[0] = 0;
00252       $submissionsCount[1] = 0;
00253 
00254       $sql = '
00255          SELECT r.date_completed, r.declined, r.cancelled
00256          FROM papers a
00257             LEFT JOIN review_assignments r ON (a.paper_id = r.paper_id)
00258             LEFT JOIN tracks t ON (t.track_id = a.track_id)
00259             LEFT JOIN users u ON (r.reviewer_id = u.user_id)
00260             LEFT JOIN review_stages r2 ON (r.paper_id = r2.paper_id AND r.stage = r2.stage)
00261          WHERE a.sched_conf_id = ? AND r.reviewer_id = ? AND r.date_notified IS NOT NULL';
00262 
00263       $result =& $this->retrieve($sql, array($schedConfId, $reviewerId));
00264 
00265       while (!$result->EOF) {
00266          if ($result->fields['date_completed'] == null && $result->fields['declined'] != 1 && $result->fields['cancelled'] != 1) {
00267             $submissionsCount[0] += 1;
00268          } else {
00269             $submissionsCount[1] += 1;
00270          }
00271          $result->moveNext();
00272       }
00273 
00274       $result->Close();
00275       unset($result);
00276 
00277       return $submissionsCount;
00278    }
00279 
00285    function getDirectorDecisions($paperId, $stage = null) {
00286       $decisions = array();
00287 
00288       $args = array($paperId);
00289       if($stage) {
00290          $args[] = $stage;
00291       }
00292 
00293       $result =& $this->retrieve('
00294          SELECT edit_decision_id, director_id, decision, date_decided
00295          FROM edit_decisions
00296          WHERE paper_id = ?'
00297             . ($stage?' AND stage = ?':'')
00298          . ' ORDER BY edit_decision_id ASC',
00299          count($args)==1?shift($args):$args);
00300 
00301       while (!$result->EOF) {
00302          $decisions[] = array(
00303             'editDecisionId' => $result->fields['edit_decision_id'],
00304             'directorId' => $result->fields['director_id'],
00305             'decision' => $result->fields['decision'],
00306             'dateDecided' => $this->datetimeFromDB($result->fields['date_decided'])
00307          );
00308          $result->moveNext();
00309       }
00310 
00311       $result->Close();
00312       unset($result);
00313 
00314       return $decisions;
00315    }
00316 }
00317 
00318 ?>

Generated on 25 Jul 2013 for Open Conference Systems by  doxygen 1.4.7