classes/schedConf/SchedConfDAO.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00016 //$Id$
00017 
00018 import ('schedConf.SchedConf');
00019 
00020 class SchedConfDAO extends DAO {
00027    function &getSchedConf($schedConfId, $conferenceId = null) {
00028       $params = array($schedConfId);
00029       if ($conferenceId !== null) $params[] = $conferenceId;
00030       $result =& $this->retrieve(
00031          'SELECT * FROM sched_confs WHERE sched_conf_id = ?' . ($conferenceId !== null?' AND conference_id = ?':''), $params
00032       );
00033 
00034       $returner = null;
00035       if ($result->RecordCount() != 0) {
00036          $returner =& $this->_returnSchedConfFromRow($result->GetRowAssoc(false));
00037       }
00038       $result->Close();
00039       unset($result);
00040       return $returner;
00041    }
00042 
00048    function &getSchedConfByPath($path, $conferenceId = null) {
00049       if($conferenceId == null) {
00050          $conference =& Request::getConference();
00051 
00052          if(!$conference)
00053             $conferenceId = -1;
00054          else
00055             $conferenceId = $conference->getId();
00056       }
00057 
00058       $returner = null;
00059       $result =& $this->retrieve(
00060          'SELECT * FROM sched_confs WHERE path = ? and conference_id = ?',
00061          array($path, $conferenceId));
00062 
00063       if ($result->RecordCount() != 0) {
00064          $returner =& $this->_returnSchedConfFromRow($result->GetRowAssoc(false));
00065       }
00066       $result->Close();
00067       unset($result);
00068       return $returner;
00069    }
00070 
00076    function &_returnSchedConfFromRow(&$row) {
00077       $schedConf = new SchedConf();
00078       $schedConf->setSchedConfId($row['sched_conf_id']);
00079       $schedConf->setPath($row['path']);
00080       $schedConf->setSequence($row['seq']);
00081       $schedConf->setConferenceId($row['conference_id']);
00082       $schedConf->setStartDate($this->datetimeFromDB($row['start_date']));
00083       $schedConf->setEndDate($this->datetimeFromDB($row['end_date']));
00084 
00085       HookRegistry::call('SchedConfDAO::_returnSchedConfFromRow', array(&$schedConf, &$row));
00086 
00087       return $schedConf;
00088    }
00089 
00094    function insertSchedConf(&$schedConf) {
00095       $this->update(
00096          sprintf('INSERT INTO sched_confs
00097             (conference_id, path, seq, start_date, end_date)
00098             VALUES
00099             (?, ?, ?, %s, %s)',
00100             $this->datetimeToDB($schedConf->getStartDate()),
00101             $this->datetimeToDB($schedConf->getEndDate())),
00102          array(
00103             $schedConf->getConferenceId(),
00104             $schedConf->getPath(),
00105             $schedConf->getSequence() == null ? 0 : $schedConf->getSequence()
00106          )
00107       );
00108 
00109       $schedConf->setSchedConfId($this->getInsertSchedConfId());
00110       return $schedConf->getId();
00111    }
00112 
00117    function updateSchedConf(&$schedConf) {
00118       return $this->update(
00119          sprintf('UPDATE sched_confs
00120             SET
00121                conference_id = ?,
00122                path = ?,
00123                seq = ?,
00124                start_date = %s,
00125                end_date = %s
00126             WHERE sched_conf_id = ?',
00127             $this->datetimeToDB($schedConf->getStartDate()),
00128             $this->datetimeToDB($schedConf->getEndDate())),
00129          array(
00130             $schedConf->getConferenceId(),
00131             $schedConf->getPath(),
00132             $schedConf->getSequence(),
00133             $schedConf->getId()
00134          )
00135       );
00136    }
00137 
00142    function deleteSchedConf(&$schedConf) {
00143       return $this->deleteSchedConfById($schedConf->getId());
00144    }
00145 
00150    function &getSchedConfTitles($conferenceId) {
00151       $schedConfs = array();
00152       $schedConfIterator =& $this->getSchedConfsByConferenceId($conferenceId);
00153       while ($schedConf =& $schedConfIterator->next()) {
00154          $schedConfs[$schedConf->getId()] = $schedConf->getSchedConfTitle();
00155          unset($schedConf);
00156       }
00157       return $schedConfs;
00158    }
00159 
00165    function &getSchedConfsByConferenceId($conferenceId, $rangeInfo = null) {
00166       $result =& $this->retrieveRange(
00167          'SELECT i.*
00168          FROM sched_confs i
00169             WHERE i.conference_id = ?
00170             ORDER BY seq',
00171          array($conferenceId),
00172          $rangeInfo
00173       );
00174 
00175       $returner = new DAOResultFactory($result, $this, '_returnSchedConfFromRow');
00176       return $returner;
00177    }
00178 
00183    function deleteSchedConfsByConferenceId($conferenceId) {
00184       $schedConfs = $this->getSchedConfsByConferenceId($conferenceId);
00185 
00186       while (!$schedConfs->eof()) {
00187          $schedConf =& $schedConfs->next();
00188          $this->deleteSchedConfById($schedConf->getId());
00189       }
00190    }
00191 
00196    function deleteSchedConfById($schedConfId) {
00197       $schedConfSettingsDao =& DAORegistry::getDAO('SchedConfSettingsDAO');
00198       $schedConfSettingsDao->deleteSettingsBySchedConf($schedConfId);
00199 
00200       $trackDao =& DAORegistry::getDAO('TrackDAO');
00201       $trackDao->deleteTracksBySchedConf($schedConfId);
00202 
00203       $registrationDao =& DAORegistry::getDAO('RegistrationDAO');
00204       $registrationDao->deleteRegistrationsBySchedConf($schedConfId);
00205 
00206       $registrationTypeDao =& DAORegistry::getDAO('RegistrationTypeDAO');
00207       $registrationTypeDao->deleteRegistrationTypesBySchedConf($schedConfId);
00208 
00209       $registrationOptionDao =& DAORegistry::getDAO('RegistrationOptionDAO');
00210       $registrationOptionDao->deleteRegistrationOptionsBySchedConf($schedConfId);
00211 
00212       $announcementDao =& DAORegistry::getDAO('AnnouncementDAO');
00213       $announcementDao->deleteAnnouncementsByAssocId(ASSOC_TYPE_SCHED_CONF, $schedConfId);
00214 
00215       $buildingDao =& DAORegistry::getDAO('BuildingDAO');
00216       $buildingDao->deleteBuildingsBySchedConfId($schedConfId);
00217 
00218       $specialEventDao =& DAORegistry::getDAO('SpecialEventDAO');
00219       $specialEventDao->deleteSpecialEventsBySchedConfId($schedConfId);
00220 
00221       $paperDao =& DAORegistry::getDAO('PaperDAO');
00222       $paperDao->deletePapersBySchedConfId($schedConfId);
00223 
00224       $roleDao =& DAORegistry::getDAO('RoleDAO');
00225       $roleDao->deleteRoleBySchedConfId($schedConfId);
00226 
00227       $groupDao =& DAORegistry::getDAO('GroupDAO');
00228       $groupDao->deleteGroupsByAssocId(ASSOC_TYPE_SCHED_CONF, $schedConfId);
00229 
00230       return $this->update(
00231          'DELETE FROM sched_confs WHERE sched_conf_id = ?', $schedConfId
00232       );
00233    }
00234 
00239    function &getSchedConfs($rangeInfo = null) {
00240       $result =& $this->retrieveRange(
00241          'SELECT * FROM sched_confs ORDER BY seq',
00242          false, $rangeInfo
00243       );
00244 
00245       $returner = new DAOResultFactory($result, $this, '_returnSchedConfFromRow');
00246       return $returner;
00247    }
00248 
00254    function &getEnabledSchedConfs($conferenceId = null) {
00255       $result =& $this->retrieve('
00256          SELECT i.* FROM sched_confs i
00257             LEFT JOIN conferences c ON (i.conference_id = c.conference_id)
00258          WHERE c.enabled = 1'
00259             . ($conferenceId?' AND i.conference_id = ?':'')
00260          . ' ORDER BY c.seq, i.seq',
00261          $conferenceId===null?false:$conferenceId);
00262 
00263       $resultFactory = new DAOResultFactory($result, $this, '_returnSchedConfFromRow');
00264       return $resultFactory;
00265    }
00266 
00272    function schedConfExistsByPath($path) {
00273       $result =& $this->retrieve(
00274          'SELECT COUNT(*) FROM sched_confs WHERE path = ?', $path
00275       );
00276       $returner = isset($result->fields[0]) && $result->fields[0] == 1 ? true : false;
00277 
00278       $result->Close();
00279       unset($result);
00280 
00281       return $returner;
00282    }
00283 
00287    function resequenceSchedConfs($conferenceId) {
00288       $result =& $this->retrieve(
00289          'SELECT sched_conf_id FROM sched_confs WHERE conference_id = ? ORDER BY seq',
00290          $conferenceId
00291       );
00292 
00293       for ($i=1; !$result->EOF; $i++) {
00294          list($schedConfId) = $result->fields;
00295          $this->update(
00296             'UPDATE sched_confs SET seq = ? WHERE sched_conf_id = ?',
00297             array(
00298                $i,
00299                $schedConfId
00300             )
00301          );
00302 
00303          $result->moveNext();
00304       }
00305 
00306       $result->close();
00307       unset($result);
00308    }
00309 
00314    function getInsertSchedConfId() {
00315       return $this->getInsertId('sched_confs', 'sched_conf_id');
00316    }
00317 
00322    function &getCurrentSchedConfs($conferenceId) {
00323       $result =& $this->retrieve('
00324          SELECT i.* FROM sched_confs i
00325             LEFT JOIN conferences c ON (i.conference_id = c.conference_id)
00326          WHERE c.enabled = 1
00327             AND i.conference_id = ?
00328             AND i.start_date < NOW()
00329             AND i.end_date > NOW()
00330          ORDER BY c.seq, i.seq',
00331          $conferenceId);
00332 
00333       $resultFactory = new DAOResultFactory($result, $this, '_returnSchedConfFromRow');
00334       return $resultFactory;
00335    }
00336 
00342    function archivedSchedConfsExist($conferenceId) {
00343       $result =& $this->retrieve(
00344          'SELECT COUNT(*) FROM sched_confs WHERE conference_id = ? AND end_date < now()', $conferenceId
00345       );
00346       $returner = isset($result->fields[0]) && $result->fields[0] >= 1 ? true : false;
00347 
00348       $result->Close();
00349       unset($result);
00350 
00351       return $returner;
00352    }
00353 
00359    function currentSchedConfsExist($conferenceId) {
00360       $result =& $this->retrieve(
00361          'SELECT COUNT(*) FROM sched_confs WHERE conference_id = ? AND start_date < now() AND end_date > now()', $conferenceId
00362       );
00363       $returner = isset($result->fields[0]) && $result->fields[0] >= 1 ? true : false;
00364 
00365       $result->Close();
00366       unset($result);
00367 
00368       return $returner;
00369    }
00370 }
00371 
00372 ?>

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