00001 <?php
00014 import('db.DAO');
00015
00016 class StaticPagesDAO extends DAO {
00017
00018 function getStaticPage($staticPageId) {
00019 $result =& $this->retrieve(
00020 'SELECT * FROM static_pages WHERE static_page_id = ?', $staticPageId
00021 );
00022
00023 $returner = null;
00024 if ($result->RecordCount() != 0) {
00025 $returner =& $this->_returnStaticPageFromRow($result->GetRowAssoc(false));
00026 }
00027 $result->Close();
00028 return $returner;
00029 }
00030
00031 function &getStaticPagesByConferenceId($conferenceId, $rangeInfo = null) {
00032 $result =& $this->retrieveRange(
00033 'SELECT * FROM static_pages WHERE conference_id = ?', $conferenceId, $rangeInfo
00034 );
00035
00036 $returner = new DAOResultFactory($result, $this, '_returnStaticPageFromRow');
00037 return $returner;
00038 }
00039
00040 function getStaticPageByPath($conferenceId, $path) {
00041 $result =& $this->retrieve(
00042 'SELECT * FROM static_pages WHERE conference_id = ? AND path = ?', array($conferenceId, $path)
00043 );
00044
00045 $returner = null;
00046 if ($result->RecordCount() != 0) {
00047 $returner =& $this->_returnStaticPageFromRow($result->GetRowAssoc(false));
00048 }
00049 $result->Close();
00050 return $returner;
00051 }
00052
00053 function insertStaticPage(&$staticPage) {
00054 $this->update(
00055 'INSERT INTO static_pages
00056 (conference_id, path)
00057 VALUES
00058 (?, ?)',
00059 array(
00060 $staticPage->getConferenceId(),
00061 $staticPage->getPath()
00062 )
00063 );
00064
00065 $staticPage->setId($this->getInsertStaticPageId());
00066 $this->updateLocaleFields($staticPage);
00067
00068 return $staticPage->getId();
00069 }
00070
00071 function updateStaticPage(&$staticPage) {
00072 $returner = $this->update(
00073 'UPDATE static_pages
00074 SET
00075 conference_id = ?,
00076 path = ?
00077 WHERE static_page_id = ?',
00078 array(
00079 $staticPage->getConferenceId(),
00080 $staticPage->getPath(),
00081 $staticPage->getId()
00082 )
00083 );
00084 $this->updateLocaleFields($staticPage);
00085 return $returner;
00086 }
00087
00088 function deleteStaticPageById($staticPageId) {
00089 $returner = $this->update(
00090 'DELETE FROM static_pages WHERE static_page_id = ?', $staticPageId
00091 );
00092 return $this->update(
00093 'DELETE FROM static_page_settings WHERE static_page_id = ?', $staticPageId
00094 );
00095 }
00096
00097 function &_returnStaticPageFromRow(&$row) {
00098 $staticPagesPlugin =& PluginRegistry::getPlugin('generic', 'StaticPagesPlugin');
00099 $staticPagesPlugin->import('StaticPage');
00100
00101 $staticPage = new StaticPage();
00102 $staticPage->setId($row['static_page_id']);
00103 $staticPage->setPath($row['path']);
00104 $staticPage->setConferenceId($row['conference_id']);
00105
00106 $this->getDataObjectSettings('static_page_settings', 'static_page_id', $row['static_page_id'], $staticPage);
00107 return $staticPage;
00108 }
00109
00110 function getInsertStaticPageId() {
00111 return $this->getInsertId('static_pages', 'static_page_id');
00112 }
00113
00118 function getLocaleFieldNames() {
00119 return array('title', 'content');
00120 }
00121
00126 function updateLocaleFields(&$staticPage) {
00127 $this->updateDataObjectSettings('static_page_settings', $staticPage, array(
00128 'static_page_id' => $staticPage->getId()
00129 ));
00130 }
00131
00139 function duplicatePathExists ($path, $conferenceId, $staticPageId = null) {
00140 $params = array(
00141 $conferenceId,
00142 $path
00143 );
00144 if (isset($staticPageId)) $params[] = $staticPageId;
00145
00146 $result = $this->retrieve(
00147 'SELECT *
00148 FROM static_pages
00149 WHERE conference_id = ?
00150 AND path = ?' .
00151 (isset($staticPageId)?' AND NOT (static_page_id = ?)':''),
00152 $params
00153 );
00154
00155 if($result->RecordCount() == 0) {
00156
00157 $returner = false;
00158 } else {
00159 $returner = true;
00160 }
00161 return $returner;
00162 }
00163 }
00164 ?>