classes/conference/TrackDirectorsDAO.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00015 //$Id$
00016 
00017 class TrackDirectorsDAO extends DAO {
00024    function insertDirector($schedConfId, $trackId, $userId) {
00025       return $this->update(
00026          'INSERT INTO track_directors
00027             (sched_conf_id, track_id, user_id)
00028             VALUES
00029             (?, ?, ?)',
00030          array(
00031             $schedConfId,
00032             $trackId,
00033             $userId
00034          )
00035       );
00036    }
00037 
00044    function deleteDirector($schedConfId, $trackId, $userId) {
00045       return $this->update(
00046          'DELETE FROM track_directors WHERE sched_conf_id = ? AND track_id = ? AND user_id = ?',
00047          array(
00048             $schedConfId,
00049             $trackId,
00050             $userId
00051          )
00052       );
00053    }
00054 
00061    function &getTracksByUserId($schedConfId, $userId) {
00062       $tracks = array();
00063 
00064       $trackDao =& DAORegistry::getDAO('TrackDAO');
00065 
00066       $result =& $this->retrieve(
00067          'SELECT t.* FROM tracks t, track_directors td WHERE t.track_id = td.track_id AND t.sched_conf_id = ? AND td.user_id = ?',
00068          array($schedConfId, $userId)
00069       );
00070 
00071       while (!$result->EOF) {
00072          $tracks[] =& $trackDao->_returnTrackFromRow($result->GetRowAssoc(false));
00073          $result->moveNext();
00074       }
00075 
00076       $result->Close();
00077       unset($result);
00078 
00079       return $tracks;
00080    }
00081 
00088    function &getDirectorsByTrackId($schedConfId, $trackId) {
00089       $users = array();
00090 
00091       $userDao =& DAORegistry::getDAO('UserDAO');
00092 
00093       $result =& $this->retrieve(
00094          'SELECT u.* FROM users AS u, track_directors AS e WHERE u.user_id = e.user_id AND e.sched_conf_id = ? AND e.track_id = ? ORDER BY last_name, first_name',
00095          array($schedConfId, $trackId)
00096       );
00097 
00098       while (!$result->EOF) {
00099          $users[] =& $userDao->_returnUserFromRow($result->GetRowAssoc(false));
00100          $result->moveNext();
00101       }
00102 
00103       $result->Close();
00104       unset($result);
00105 
00106       return $users;
00107    }
00108 
00115    function &getDirectorsNotInTrack($schedConfId, $trackId) {
00116       $users = array();
00117 
00118       $userDao =& DAORegistry::getDAO('UserDAO');
00119 
00120       $result =& $this->retrieve(
00121          'SELECT  u.*
00122          FROM  users u
00123             LEFT JOIN roles r ON (r.user_id = u.user_id)
00124             LEFT JOIN track_directors e ON (e.user_id = u.user_id AND e.sched_conf_id = r.sched_conf_id AND e.track_id = ?)
00125          WHERE r.sched_conf_id = ? AND
00126             r.role_id = ? AND
00127             e.track_id IS NULL
00128          ORDER BY last_name, first_name',
00129          array($trackId, $schedConfId, ROLE_ID_TRACK_DIRECTOR)
00130       );
00131 
00132       while (!$result->EOF) {
00133          $users[] =& $userDao->_returnUserFromRow($result->GetRowAssoc(false));
00134          $result->moveNext();
00135       }
00136 
00137       $result->Close();
00138       unset($result);
00139 
00140       return $users;
00141    }
00142 
00148    function deleteDirectorsByTrackId($trackId, $schedConfId = null) {
00149       if (isset($schedConfId)) return $this->update(
00150          'DELETE FROM track_directors WHERE sched_conf_id = ? AND track_id = ?',
00151          array($schedConfId, $trackId)
00152       );
00153       else return $this->update(
00154          'DELETE FROM track_directors WHERE track_id = ?',
00155          $trackId
00156       );
00157    }
00158 
00163    function deleteDirectorsBySchedConfId($schedConfId) {
00164       return $this->update(
00165          'DELETE FROM track_directors WHERE sched_conf_id = ?', $schedConfId
00166       );
00167    }
00168 
00175    function deleteDirectorsByUserId($userId, $schedConfId  = null, $trackId = null) {
00176       return $this->update(
00177          'DELETE FROM track_directors WHERE user_id = ?' . (isset($schedConfId) ? ' AND sched_conf_id = ?' : '') . (isset($trackId) ? ' AND track_id = ?' : ''),
00178          isset($schedConfId) && isset($trackId) ? array($userId, $schedConfId, $trackId)
00179          : (isset($schedConfId) ? array($userId, $schedConfId)
00180          : (isset($trackId) ? array($userId, $trackId) : $userId))
00181       );
00182    }
00183 
00191    function directorExists($schedConfId, $trackId, $userId) {
00192       $result =& $this->retrieve(
00193          'SELECT COUNT(*) FROM track_directors WHERE sched_conf_id = ? AND track_id = ? AND user_id = ?', array($schedConfId, $trackId, $userId)
00194       );
00195       $returner = isset($result->fields[0]) && $result->fields[0] == 1 ? true : false;
00196 
00197       $result->Close();
00198       unset($result);
00199 
00200       return $returner;
00201    }
00202 }
00203 
00204 ?>

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