classes/conference/ConferenceDAO.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00016 //$Id$
00017 
00018 import ('conference.Conference');
00019 
00020 class ConferenceDAO extends DAO {
00026    function &getConference($conferenceId) {
00027       $result =& $this->retrieve(
00028          'SELECT * FROM conferences WHERE conference_id = ?', $conferenceId
00029       );
00030 
00031       $returner = null;
00032       if ($result->RecordCount() != 0) {
00033          $returner =& $this->_returnConferenceFromRow($result->GetRowAssoc(false));
00034       }
00035       $result->Close();
00036       unset($result);
00037       return $returner;
00038    }
00039 
00045    function &getConferenceByPath($path) {
00046       $returner = null;
00047       $result =& $this->retrieve(
00048          'SELECT * FROM conferences WHERE path = ?', $path
00049       );
00050 
00051       if ($result->RecordCount() != 0) {
00052          $returner =& $this->_returnConferenceFromRow($result->GetRowAssoc(false));
00053       }
00054       $result->Close();
00055       unset($result);
00056       return $returner;
00057    }
00058 
00064    function &_returnConferenceFromRow(&$row) {
00065       $conference = new Conference();
00066       $conference->setConferenceId($row['conference_id']);
00067       $conference->setPath($row['path']);
00068       $conference->setSequence($row['seq']);
00069       $conference->setEnabled($row['enabled']);
00070       $conference->setPrimaryLocale($row['primary_locale']);
00071 
00072       HookRegistry::call('ConferenceDAO::_returnConferenceFromRow', array(&$conference, &$row));
00073 
00074       return $conference;
00075    }
00076 
00081    function insertConference(&$conference) {
00082       $this->update(
00083          'INSERT INTO conferences
00084             (primary_locale, path, seq, enabled)
00085             VALUES
00086             (?, ?, ?, ?)',
00087          array(
00088             $conference->getPrimaryLocale(),
00089             $conference->getPath(),
00090             $conference->getSequence() == null ? 0 : $conference->getSequence(),
00091             $conference->getEnabled() ? 1 : 0
00092          )
00093       );
00094 
00095       $conference->setConferenceId($this->getInsertConferenceId());
00096       return $conference->getId();
00097    }
00098 
00103    function updateConference(&$conference) {
00104       return $this->update(
00105          'UPDATE conferences
00106             SET
00107                primary_locale = ?,
00108                path = ?,
00109                seq = ?,
00110                enabled = ?
00111             WHERE conference_id = ?',
00112          array(
00113             $conference->getPrimaryLocale(),
00114             $conference->getPath(),
00115             $conference->getSequence(),
00116             $conference->getEnabled() ? 1 : 0,
00117             $conference->getId()
00118          )
00119       );
00120    }
00121 
00126    function deleteConference(&$conference) {
00127       return $this->deleteConferenceById($conference->getId());
00128    }
00129 
00134    function deleteConferenceById($conferenceId) {
00135       $conferenceSettingsDao =& DAORegistry::getDAO('ConferenceSettingsDAO');
00136       $conferenceSettingsDao->deleteSettingsByConference($conferenceId);
00137 
00138       $emailTemplateDao =& DAORegistry::getDAO('EmailTemplateDAO');
00139       $emailTemplateDao->deleteEmailTemplatesByConference($conferenceId);
00140 
00141       $rtDao =& DAORegistry::getDAO('RTDAO');
00142       $rtDao->deleteVersionsByConference($conferenceId);
00143 
00144       $roleDao =& DAORegistry::getDAO('RoleDAO');
00145       $roleDao->deleteRoleByConferenceId($conferenceId);
00146 
00147       $groupDao =& DAORegistry::getDAO('GroupDAO');
00148       $groupDao->deleteGroupsByAssocId(ASSOC_TYPE_CONFERENCE, $conferenceId);
00149 
00150       $pluginSettingsDao =& DAORegistry::getDAO('PluginSettingsDAO');
00151       $pluginSettingsDao->deleteSettingsByConferenceId($conferenceId);
00152       
00153       $reviewFormDao =& DAORegistry::getDAO('ReviewFormDAO');
00154       $reviewFormDao->deleteByAssocId(ASSOC_TYPE_CONFERENCE, $conferenceId);
00155 
00156       $announcementDao =& DAORegistry::getDAO('AnnouncementDAO');
00157       $announcementDao->deleteAnnouncementsByAssocId(ASSOC_TYPE_CONFERENCE, $conferenceId);
00158 
00159       $announcementTypeDao =& DAORegistry::getDAO('AnnouncementTypeDAO');
00160       $announcementTypeDao->deleteAnnouncementTypesByAssocId(ASSOC_TYPE_CONFERENCE, $conferenceId);
00161 
00162       $schedConfDao =& DAORegistry::getDAO('SchedConfDAO');
00163       $schedConfDao->deleteSchedConfsByConferenceId($conferenceId);
00164 
00165       return $this->update(
00166          'DELETE FROM conferences WHERE conference_id = ?', $conferenceId
00167       );
00168    }
00169 
00174    function &getConferences($rangeInfo = null) {
00175       $result =& $this->retrieveRange(
00176          'SELECT * FROM conferences ORDER BY seq',
00177          false, $rangeInfo
00178       );
00179 
00180       $returner = new DAOResultFactory($result, $this, '_returnConferenceFromRow');
00181       return $returner;
00182    }
00183 
00188    function &getEnabledConferences() {
00189       $result =& $this->retrieve(
00190          'SELECT * FROM conferences WHERE enabled=1 ORDER BY seq'
00191       );
00192 
00193       $resultFactory = new DAOResultFactory($result, $this, '_returnConferenceFromRow');
00194       return $resultFactory;
00195    }
00196 
00201    function &getConferenceTitles() {
00202       $conferences = array();
00203       $conferenceIterator =& $this->getConferences();
00204       while ($conference =& $conferenceIterator->next()) {
00205          $conferences[$conference->getId()] = $conference->getConferenceTitle();
00206          unset($conference);
00207       }
00208       return $conferences;
00209    }
00210 
00215    function &getEnabledConferenceTitles() {
00216       $conferences = array();
00217       $conferenceIterator =& $this->getEnabledConferences();
00218       while ($conference =& $conferenceIterator->next()) {
00219          $conferences[$conference->getId()] = $conference->getConferenceTitle();
00220          unset($conference);
00221       }
00222       return $conferences;
00223    }
00224 
00230    function conferenceExistsByPath($path) {
00231       $result =& $this->retrieve(
00232          'SELECT COUNT(*) FROM conferences WHERE path = ?', $path
00233       );
00234       $returner = isset($result->fields[0]) && $result->fields[0] == 1 ? true : false;
00235 
00236       $result->Close();
00237       unset($result);
00238 
00239       return $returner;
00240    }
00241 
00245    function resequenceConferences() {
00246       $result =& $this->retrieve(
00247          'SELECT conference_id FROM conferences ORDER BY seq'
00248       );
00249 
00250       for ($i=1; !$result->EOF; $i++) {
00251          list($conferenceId) = $result->fields;
00252          $this->update(
00253             'UPDATE conferences SET seq = ? WHERE conference_id = ?',
00254             array(
00255                $i,
00256                $conferenceId
00257             )
00258          );
00259 
00260          $result->moveNext();
00261       }
00262 
00263       $result->close();
00264       unset($result);
00265    }
00266 
00271    function getInsertConferenceId() {
00272       return $this->getInsertId('conferences', 'conference_id');
00273    }
00274 }
00275 
00276 ?>

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