classes/conference/TrackDAO.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00017 // $Id$
00018 
00019 
00020 import ('conference.Track');
00021 
00022 class TrackDAO extends DAO {
00028    function &getTrack($trackId) {
00029       $result =& $this->retrieve(
00030          'SELECT * FROM tracks WHERE track_id = ?', $trackId
00031       );
00032 
00033       $returner = null;
00034       if ($result->RecordCount() != 0) {
00035          $returner =& $this->_returnTrackFromRow($result->GetRowAssoc(false));
00036       }
00037 
00038       $result->Close();
00039       unset($result);
00040 
00041       return $returner;
00042    }
00043 
00050    function &getTrackByAbbrev($trackAbbrev, $schedConfId, $locale = null) {
00051       $sql = 'SELECT * FROM tracks t, track_settings l WHERE l.track_id = t.track_id AND l.setting_name = ? AND l.setting_value = ? AND t.sched_conf_id = ?';
00052       $params = array('abbrev', $trackAbbrev, $schedConfId);
00053 
00054       if ($locale !== null) {
00055          $sql .= ' AND l.locale = ?';
00056          $params[] = $locale;
00057       }
00058       $result =& $this->retrieve($sql, $params);
00059 
00060       $returner = null;
00061       if ($result->RecordCount() != 0) {
00062          $returner =& $this->_returnTrackFromRow($result->GetRowAssoc(false));
00063       }
00064 
00065       $result->Close();
00066       unset($result);
00067 
00068       return $returner;
00069    }
00070 
00077    function &getTrackByTitle($trackTitle, $schedConfId, $locale = null) {
00078       $sql = 'SELECT * FROM tracks t, track_settings l WHERE l.track_id = t.track_id AND l.setting_name = ? AND l.setting_value = ? AND t.sched_conf_id = ?';
00079       $params = array('title', $trackTitle, $schedConfId);
00080 
00081       if ($locale !== null) {
00082          $sql .= ' AND l.locale = ?';
00083          $params[] = $locale;
00084       }
00085       $result =& $this->retrieve($sql, $params);
00086 
00087       $returner = null;
00088       if ($result->RecordCount() != 0) {
00089          $returner =& $this->_returnTrackFromRow($result->GetRowAssoc(false));
00090       }
00091 
00092       $result->Close();
00093       unset($result);
00094 
00095       return $returner;
00096    }
00097 
00105    function &getTrackByTitleAndAbbrev($trackTitle, $trackAbbrev, $schedConfId, $locale = null) {
00106       $params = array('title', 'abbrev', $trackTitle, $trackAbbrev, $schedConfId);
00107       if ($locale !== null) {
00108          $params[] = $locale;
00109          $params[] = $locale;
00110       }
00111 
00112       $sql = 'SELECT t.*
00113          FROM  tracks t,
00114             track_settings l1,
00115             track_settings l2
00116          WHERE l1.track_id = t.track_id AND
00117             l2.track_id = t.track_id AND
00118             l1.setting_name = ? AND
00119             l2.setting_name = ? AND
00120             l1.setting_value = ? AND
00121             l2.setting_value = ? AND
00122             t.sched_conf_id = ?';
00123       if ($locale !== null) $sql .= ' AND l1.locale = ? AND l2.locale = ?';
00124       $result =& $this->retrieve($sql, $params);
00125 
00126       $returner = null;
00127       if ($result->RecordCount() != 0) {
00128          $returner =& $this->_returnTrackFromRow($result->GetRowAssoc(false));
00129       }
00130 
00131       $result->Close();
00132       unset($result);
00133 
00134       return $returner;
00135    }
00136 
00142    function &_returnTrackFromRow(&$row) {
00143       $track = new Track();
00144       $track->setId($row['track_id']);
00145       $track->setSchedConfId($row['sched_conf_id']);
00146       $track->setReviewFormId($row['review_form_id']);
00147       $track->setSequence($row['seq']);
00148       $track->setMetaReviewed($row['meta_reviewed']);
00149       $track->setDirectorRestricted($row['director_restricted']);
00150       $track->setHideAbout($row['hide_about']);
00151       $track->setDisableComments($row['disable_comments']);
00152       $track->setAbstractWordCount($row['abstract_word_count']);
00153 
00154       $this->getDataObjectSettings('track_settings', 'track_id', $row['track_id'], $track);
00155 
00156       HookRegistry::call('TrackDAO::_returnTrackFromRow', array(&$track, &$row));
00157 
00158       return $track;
00159    }
00160 
00165    function getLocaleFieldNames() {
00166       return array('title', 'abbrev', 'policy', 'identifyType');
00167    }
00168 
00173    function updateLocaleFields(&$track) {
00174       $this->updateDataObjectSettings('track_settings', $track, array(
00175 
00176          'track_id' => $track->getId()
00177       ));
00178    }
00179 
00184    function insertTrack(&$track) {
00185       $this->update(
00186          'INSERT INTO tracks
00187             (sched_conf_id, review_form_id, seq, meta_reviewed, director_restricted, hide_about, disable_comments, abstract_word_count)
00188             VALUES
00189             (?, ?, ?, ?, ?, ?, ?, ?)',
00190          array(
00191             (int) $track->getSchedConfId(),
00192             $track->getReviewFormId(),
00193             (int) $track->getSequence(),
00194             $track->getMetaReviewed() ? 1 : 0,
00195             $track->getDirectorRestricted() ? 1 : 0,
00196             $track->getHideAbout() ? 1 : 0,
00197             $track->getDisableComments() ? 1 : 0,
00198             (int) $track->getAbstractWordCount()
00199          )
00200       );
00201 
00202       $track->setId($this->getInsertTrackId());
00203       $this->updateLocaleFields($track);
00204       return $track->getId();
00205    }
00206 
00211    function updateTrack(&$track) {
00212       $returner = $this->update(
00213          'UPDATE  tracks
00214          SET   review_form_id = ?,
00215             seq = ?,
00216             meta_reviewed = ?,
00217             director_restricted = ?,
00218             hide_about = ?,
00219             disable_comments = ?,
00220             abstract_word_count = ?
00221          WHERE track_id = ?',
00222          array(
00223             $track->getReviewFormId(),
00224             (int) $track->getSequence(),
00225             $track->getMetaReviewed()?1:0,
00226             $track->getDirectorRestricted()?1:0,
00227             $track->getHideAbout()?1:0,
00228             $track->getDisableComments()?1:0,
00229             (int) $track->getAbstractWordCount(),
00230             (int) $track->getId()
00231          )
00232       );
00233       $this->updateLocaleFields($track);
00234       return $returner;
00235    }
00236 
00241    function deleteTrack(&$track) {
00242       return $this->deleteTrackById($track->getId(), $track->getSchedConfId());
00243    }
00244 
00250    function deleteTrackById($trackId, $schedConfId = null) {
00251       $trackDirectorsDao =& DAORegistry::getDAO('TrackDirectorsDAO');
00252       $trackDirectorsDao->deleteDirectorsByTrackId($trackId, $schedConfId);
00253 
00254       // Remove papers from this track
00255       $paperDao =& DAORegistry::getDAO('PaperDAO');
00256       $paperDao->removePapersFromTrack($trackId);
00257 
00258       // Delete published paper entries from this track -- they must
00259       // be re-published.
00260       $publishedPaperDao =& DAORegistry::getDAO('PublishedPaperDAO');
00261       $publishedPaperDao->deletePublishedPapersByTrackId($trackId);
00262 
00263       if (isset($schedConfId) && !$this->trackExists($trackId, $schedConfId)) return false;
00264       $this->update('DELETE FROM track_settings WHERE track_id = ?', array($trackId));
00265       return $this->update('DELETE FROM tracks WHERE track_id = ?', array($trackId));
00266    }
00267 
00272    function deleteTracksBySchedConf($schedConfId) {
00273       $tracks =& $this->getSchedConfTracks($schedConfId);
00274       while (($track =& $tracks->next())) {
00275          $this->deleteTrack($track);
00276          unset($track);
00277       }
00278    }
00279 
00285    function &getDirectorTracks($schedConfId) {
00286       $returner = array();
00287 
00288       $result =& $this->retrieve(
00289          'SELECT t.*, td.user_id AS director_id FROM track_directors td, tracks t WHERE td.track_id = t.track_id AND t.sched_conf_id = td.sched_conf_id AND t.sched_conf_id = ?',
00290          $schedConfId
00291       );
00292 
00293       while (!$result->EOF) {
00294          $row = $result->GetRowAssoc(false);
00295          $track =& $this->_returnTrackFromRow($row);
00296          if (!isset($returner[$row['director_id']])) {
00297             $returner[$row['director_id']] = array($track);
00298          } else {
00299             $returner[$row['director_id']][] = $track;
00300          }
00301          $result->moveNext();
00302       }
00303 
00304       $result->Close();
00305       unset($result);
00306 
00307       return $returner;
00308    }
00309 
00315    function &getTracksBySchedConfId($schedConfId) {
00316       $returner = array();
00317 
00318       $result =& $this->retrieve(
00319          'SELECT DISTINCT t.*,
00320             t.seq AS track_seq
00321          FROM tracks t, papers p
00322          LEFT JOIN sched_confs i ON (p.sched_conf_id = i.sched_conf_id) AND (i.sched_conf_id = ?)
00323          WHERE t.track_id = p.track_id ORDER BY track_seq',
00324          array($schedConfId)
00325       );
00326 
00327       while (!$result->EOF) {
00328          $row = $result->GetRowAssoc(false);
00329          $returner[] =& $this->_returnTrackFromRow($row);
00330          $result->moveNext();
00331       }
00332 
00333       $result->Close();
00334       unset($result);
00335 
00336       return $returner;
00337    }
00338 
00345    function &getSchedConfTracks($schedConfId, $rangeInfo = null) {
00346       $result =& $this->retrieveRange(
00347          'SELECT  *
00348          FROM  tracks
00349          WHERE sched_conf_id = ?
00350          ORDER BY seq',
00351          (int) $schedConfId,
00352          $rangeInfo
00353       );
00354 
00355       $returner = new DAOResultFactory($result, $this, '_returnTrackFromRow');
00356       return $returner;
00357    }
00358 
00365    function &getConferenceTracks($conferenceId, $rangeInfo = null) {
00366       $result =& $this->retrieveRange(
00367          'SELECT  t.*
00368          FROM  tracks t,
00369             sched_confs sc
00370          WHERE t.sched_conf_id = sc.sched_conf_id AND
00371             sc.conference_id = ?
00372          ORDER BY sc.seq, t.seq',
00373          (int) $conferenceId,
00374          $rangeInfo
00375       );
00376 
00377       $returner = new DAOResultFactory($result, $this, '_returnTrackFromRow');
00378       return $returner;
00379    }
00380 
00385    function &getTrackTitles($schedConfId, $submittableOnly = false) {
00386       $tracks = array();
00387       $tracksIterator =& $this->getSchedConfTracks($schedConfId);
00388       while (($track =& $tracksIterator->next())) {
00389          if (!$submittableOnly || !$track->getDirectorRestricted()) {
00390             $tracks[$track->getId()] = $track->getLocalizedTitle();
00391          }
00392 
00393          unset($track);
00394       }
00395 
00396       return $tracks;
00397    }
00398 
00405    function trackExists($trackId, $schedConfId) {
00406       $result =& $this->retrieve(
00407          'SELECT COUNT(*) FROM tracks WHERE track_id = ? AND sched_conf_id = ?',
00408          array($trackId, $schedConfId)
00409       );
00410       $returner = isset($result->fields[0]) && $result->fields[0] == 1 ? true : false;
00411 
00412       $result->Close();
00413       unset($result);
00414 
00415       return $returner;
00416    }
00417 
00422    function resequenceTracks($schedConfId) {
00423       $result =& $this->retrieve(
00424          'SELECT track_id FROM tracks WHERE sched_conf_id = ? ORDER BY seq',
00425          $schedConfId
00426       );
00427 
00428       for ($i=1; !$result->EOF; $i++) {
00429          list($trackId) = $result->fields;
00430          $this->update(
00431             'UPDATE tracks SET seq = ? WHERE track_id = ?',
00432             array(
00433                $i,
00434                $trackId
00435             )
00436          );
00437 
00438          $result->moveNext();
00439       }
00440 
00441       $result->close();
00442       unset($result);
00443    }
00444 
00449    function getInsertTrackId() {
00450       return $this->getInsertId('tracks', 'track_id');
00451    }
00452 }
00453 
00454 ?>

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