classes/submission/editAssignment/EditAssignmentDAO.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00016 //$Id$
00017 
00018 import('submission.editAssignment.EditAssignment');
00019 
00020 class EditAssignmentDAO extends DAO {
00026    function &getEditAssignment($editId) {
00027       $result =& $this->retrieve(
00028          'SELECT e.*,
00029             u.first_name,
00030             u.last_name,
00031             u.email,
00032             u.initials,
00033             r.role_id AS director_role_id
00034          FROM papers p
00035             LEFT JOIN edit_assignments e ON (e.paper_id = p.paper_id)
00036             LEFT JOIN users u ON (e.director_id = u.user_id)
00037             LEFT JOIN roles r ON (r.user_id = e.director_id AND r.role_id = ' . ROLE_ID_DIRECTOR . ' AND r.sched_conf_id = p.sched_conf_id)
00038          WHERE e.edit_id = ? AND p.paper_id = e.paper_id',
00039          $editId
00040          );
00041 
00042       $returner = null;
00043       if ($result->RecordCount() != 0) {
00044          $returner =& $this->_returnEditAssignmentFromRow($result->GetRowAssoc(false));
00045       }
00046 
00047       $result->Close();
00048       unset($result);
00049 
00050       return $returner;
00051    }
00052 
00058    function &getEditAssignmentsByPaperId($paperId) {
00059       $result =& $this->retrieve(
00060          'SELECT e.*, u.first_name, u.last_name, u.email, u.initials, r.role_id AS director_role_id
00061          FROM papers p
00062             LEFT JOIN edit_assignments e ON (p.paper_id = e.paper_id)
00063             LEFT JOIN users u ON (e.director_id = u.user_id)
00064             LEFT JOIN roles r ON (r.user_id = e.director_id AND r.role_id = ' . ROLE_ID_DIRECTOR . ' AND r.sched_conf_id = p.sched_conf_id)
00065          WHERE e.paper_id = ? AND p.paper_id = e.paper_id ORDER BY e.date_notified ASC',
00066          $paperId
00067          );
00068 
00069       $returner = new DAOResultFactory($result, $this, '_returnEditAssignmentFromRow');
00070       return $returner;
00071    }
00072 
00078    function &getDirectorAssignmentsByPaperId($paperId) {
00079       $result =& $this->retrieve(
00080          'SELECT e.*, u.first_name, u.last_name, u.email, u.initials, r.role_id AS director_role_id FROM papers a, edit_assignments e, users u, roles r WHERE r.user_id = e.director_id AND r.role_id = ' . ROLE_ID_DIRECTOR . ' AND e.paper_id = ? AND r.sched_conf_id = a.sched_conf_id AND a.paper_id = e.paper_id AND e.director_id = u.user_id ORDER BY e.date_notified ASC',
00081          $paperId
00082          );
00083 
00084       $returner = new DAOResultFactory($result, $this, '_returnEditAssignmentFromRow');
00085       return $returner;
00086    }
00087 
00094    function &getTrackDirectorAssignmentsByPaperId($paperId) {
00095       $result =& $this->retrieve(
00096          'SELECT e.*, u.first_name, u.last_name, u.email, u.initials, r.role_id AS director_role_id
00097          FROM papers p
00098             LEFT JOIN edit_assignments e ON (p.paper_id = e.paper_id)
00099             LEFT JOIN users u ON (e.director_id = u.user_id)
00100             LEFT JOIN roles r ON (r.user_id = e.director_id AND r.role_id = ' . ROLE_ID_DIRECTOR . ' AND r.sched_conf_id = p.sched_conf_id)
00101          WHERE e.paper_id = ? AND p.paper_id = e.paper_id AND r.role_id IS NULL ORDER BY e.date_notified ASC',
00102          $paperId
00103          );
00104 
00105       $returner = new DAOResultFactory($result, $this, '_returnEditAssignmentFromRow');
00106       return $returner;
00107    }
00108 
00114    function &getEditAssignmentsByUserId($userId) {
00115       $result =& $this->retrieve(
00116          'SELECT e.*, u.first_name, u.last_name, u.email, u.initials, r.role_id AS director_role_id
00117          FROM papers p
00118             LEFT JOIN edit_assignments e ON (p.paper_id = e.paper_id)
00119             LEFT JOIN users u ON (e.director_id = u.user_id)
00120             LEFT JOIN roles r ON (r.user_id = e.director_id AND r.role_id = ' . ROLE_ID_DIRECTOR . ' AND r.sched_conf_id = p.sched_conf_id)
00121             WHERE e.director_id = ? AND p.paper_id = e.paper_id ORDER BY e.date_notified ASC',
00122          $userId
00123          );
00124 
00125       $returner = new DAOResultFactory($result, $this, '_returnEditAssignmentFromRow');
00126       return $returner;
00127    }
00128 
00134    function &_returnEditAssignmentFromRow(&$row) {
00135       $editAssignment = new EditAssignment();
00136       $editAssignment->setEditId($row['edit_id']);
00137       $editAssignment->setPaperId($row['paper_id']);
00138       $editAssignment->setDirectorId($row['director_id']);
00139       $editAssignment->setDirectorFullName($row['first_name'].' '.$row['last_name']);
00140       $editAssignment->setDirectorFirstName($row['first_name']);
00141       $editAssignment->setDirectorLastName($row['last_name']);
00142       $editAssignment->setDirectorInitials($row['initials']);
00143       $editAssignment->setDirectorEmail($row['email']);
00144       $editAssignment->setIsDirector($row['director_role_id']==ROLE_ID_DIRECTOR?1:0);
00145       $editAssignment->setDateUnderway($this->datetimeFromDB($row['date_underway']));
00146       $editAssignment->setDateNotified($this->datetimeFromDB($row['date_notified']));
00147 
00148       HookRegistry::call('EditAssignmentDAO::_returnEditAssignmentFromRow', array(&$editAssignment, &$row));
00149 
00150       return $editAssignment;
00151    }
00152 
00157    function insertEditAssignment(&$editAssignment) {
00158       $this->update(
00159          sprintf('INSERT INTO edit_assignments
00160             (paper_id, director_id, date_notified, date_underway)
00161             VALUES
00162             (?, ?, %s, %s)',
00163             $this->datetimeToDB($editAssignment->getDateNotified()),
00164             $this->datetimeToDB($editAssignment->getDateUnderway())),
00165          array(
00166             $editAssignment->getPaperId(),
00167             $editAssignment->getDirectorId()
00168          )
00169       );
00170 
00171       $editAssignment->setEditId($this->getInsertEditId());
00172       return $editAssignment->getEditId();
00173    }
00174 
00179    function updateEditAssignment(&$editAssignment) {
00180       return $this->update(
00181          sprintf('UPDATE edit_assignments
00182             SET   paper_id = ?,
00183                director_id = ?,
00184                date_notified = %s,
00185                date_underway = %s
00186             WHERE edit_id = ?',
00187             $this->datetimeToDB($editAssignment->getDateNotified()),
00188             $this->datetimeToDB($editAssignment->getDateUnderway())),
00189          array(
00190             $editAssignment->getPaperId(),
00191             $editAssignment->getDirectorId(),
00192             $editAssignment->getEditId()
00193          )
00194       );
00195    }
00196 
00201    function deleteEditAssignmentById($editId) {
00202       return $this->update(
00203          'DELETE FROM edit_assignments WHERE edit_id = ?',
00204          $editId
00205       );
00206    }
00207 
00212    function deleteEditAssignmentsByPaper($paperId) {
00213       return $this->update(
00214          'DELETE FROM edit_assignments WHERE paper_id = ?',
00215          $paperId
00216       );
00217    }
00218 
00223    function getInsertEditId() {
00224       return $this->getInsertId('edit_assignments', 'edit_id');
00225    }
00226 
00231    function getDirectorStatistics($schedConfId) {
00232       $statistics = Array();
00233 
00234       // Get counts of completed submissions
00235       $result =& $this->retrieve(
00236          'SELECT  ea.director_id,
00237             COUNT(ea.paper_id) AS complete
00238          FROM  edit_assignments ea,
00239             papers p
00240          WHERE ea.paper_id=p.paper_id AND
00241             p.sched_conf_id = ? AND (
00242                p.status = ' . STATUS_ARCHIVED . ' OR
00243                p.status = ' . STATUS_PUBLISHED . ' OR
00244                p.status = ' . STATUS_DECLINED . '
00245             )
00246          GROUP BY ea.director_id',
00247          $schedConfId
00248       );
00249 
00250       while (!$result->EOF) {
00251          $row = $result->GetRowAssoc(false);
00252          if (!isset($statistics[$row['director_id']])) $statistics[$row['director_id']] = array();
00253          $statistics[$row['director_id']]['complete'] = $row['complete'];
00254          $result->MoveNext();
00255       }
00256       $result->Close();
00257       unset($result);
00258 
00259       // Get counts of incomplete submissions
00260       $result =& $this->retrieve(
00261          'SELECT  ea.director_id,
00262             COUNT(ea.paper_id) AS incomplete
00263          FROM  edit_assignments ea,
00264             papers p
00265          WHERE ea.paper_id = p.paper_id AND
00266             p.sched_conf_id = ? AND
00267             p.status = ' . STATUS_QUEUED . '
00268          GROUP BY ea.director_id',
00269          $schedConfId
00270       );
00271 
00272       while (!$result->EOF) {
00273          $row = $result->GetRowAssoc(false);
00274          if (!isset($statistics[$row['director_id']])) $statistics[$row['director_id']] = array();
00275          $statistics[$row['director_id']]['incomplete'] = $row['incomplete'];
00276          $result->MoveNext();
00277       }
00278       $result->Close();
00279       unset($result);
00280 
00281       return $statistics;
00282    }
00283 }
00284 
00285 ?>

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