00001 <?php
00002
00020
00021
00022 import ('conference.log.ConferenceEventLogEntry');
00023
00024 class ConferenceEventLogDAO extends DAO {
00025
00029 function ConferenceEventLogDAO() {
00030 parent::DAO();
00031 }
00032
00039 function &getLogEntry($logId, $conferenceId = null, $schedConfId = null) {
00040 $primaryLocale = AppLocale::getPrimaryLocale();
00041 $locale = AppLocale::getLocale();
00042 $args = array(
00043 'title',
00044 $primaryLocale,
00045 'title',
00046 $locale,
00047 'title',
00048 $primaryLocale,
00049 'title',
00050 $locale,
00051 $logId
00052 );
00053
00054 if (isset($conferenceId))
00055 $args[] = $conferenceId;
00056
00057 if (isset($schedConfId))
00058 $args[] = $schedConfId;
00059
00060 $result =& $this->retrieve(
00061 'SELECT e.*,
00062 COALESCE(sctl.setting_value, sct.setting_value) AS sched_conf_title,
00063 COALESCE(ctl.setting_value, ct.setting_value) AS conference_title
00064 FROM conference_event_log e
00065 LEFT JOIN sched_confs sc ON (e.sched_conf_id = sc.sched_conf_id)
00066 LEFT JOIN conferences c ON (e.conference_id = c.conference_id)
00067 LEFT JOIN conference_settings ct ON (ct.setting_name = ? AND ct.locale = ? AND ct.conference_id = e.conference_id)
00068 LEFT JOIN conference_settings ctl ON (ctl.setting_name = ? AND ctl.locale = ? AND ctl.conference_id = e.conference_id)
00069 LEFT JOIN sched_conf_settings sct ON (sct.setting_name = ? AND sct.locale = ? AND sct.sched_conf_id = e.sched_conf_id)
00070 LEFT JOIN sched_conf_settings sctl ON (sctl.setting_name = ? AND sctl.locale = ? AND sctl.sched_conf_id = e.sched_conf_id)
00071 WHERE e.log_id = ?' .
00072 (isset($conferenceId) ? ' AND e.conference_id = ?' : '') .
00073 (isset($schedConfId) ? ' AND e.sched_conf_id = ?' : ''),
00074 $args
00075 );
00076
00077 $returner = null;
00078 if ($result->RecordCount() != 0) {
00079 $returner =& $this->_returnLogEntryFromRow($result->GetRowAssoc(false));
00080 }
00081
00082 $result->Close();
00083 unset($result);
00084
00085 return $returner;
00086 }
00087
00094 function &getConferenceLogEntries($conferenceId, $schedConfId = null, $rangeInfo = null) {
00095 $returner =& $this->getConferenceLogEntriesByAssoc($conferenceId, $schedConfId, null, null, $rangeInfo);
00096 return $returner;
00097 }
00098
00109 function &getConferenceLogEntriesByAssoc($conferenceId, $schedConfId = null, $assocType = null, $assocId = null, $rangeInfo = null) {
00110 $primaryLocale = AppLocale::getPrimaryLocale();
00111 $locale = AppLocale::getLocale();
00112 $params = array(
00113 'title',
00114 $primaryLocale,
00115 'title',
00116 $locale,
00117 'title',
00118 $primaryLocale,
00119 'title',
00120 $locale,
00121 $conferenceId
00122 );
00123
00124 if (isset($schedConfId))
00125 $params[] = $schedConfId;
00126
00127 if (isset($assocType)) {
00128 $params[] = $assocType;
00129 if (isset($assocId))
00130 $params[] = $assocId;
00131 }
00132
00133 $result =& $this->retrieveRange(
00134 'SELECT e.*,
00135 COALESCE(sctl.setting_value, sct.setting_value) AS sched_conf_title,
00136 COALESCE(ctl.setting_value, ct.setting_value)
00137 FROM conference_event_log e
00138 LEFT JOIN sched_confs sc ON (e.sched_conf_id = sc.sched_conf_id)
00139 LEFT JOIN conferences c ON (e.conference_id = c.conference_id)
00140 LEFT JOIN conference_settings ct ON (ct.setting_name = ? AND ct.locale = ? AND ct.conference_id = e.conference_id)
00141 LEFT JOIN conference_settings ctl ON (ctl.setting_name = ? AND ctl.locale = ? AND ctl.conference_id = e.conference_id)
00142 LEFT JOIN sched_conf_settings sct ON (sct.setting_name = ? AND sct.locale = ? AND sct.sched_conf_id = e.sched_conf_id)
00143 LEFT JOIN sched_conf_settings sctl ON (sctl.setting_name = ? AND sctl.locale = ? AND sctl.sched_conf_id = e.sched_conf_id)
00144 WHERE e.conference_id = ?' .
00145 (isset($schedConfId) ? ' AND e.sched_conf_id = ? ':'') .
00146 (isset($assocType) ? ' AND e.assoc_type = ?' . (isset($assocId) ? ' AND e.assoc_id = ?' : '') : '') .
00147 ' ORDER BY log_id DESC',
00148 $params, $rangeInfo
00149 );
00150
00151 $returner = new DAOResultFactory($result, $this, '_returnLogEntryFromRow');
00152 return $returner;
00153 }
00154
00160 function &_returnLogEntryFromRow(&$row) {
00161 $entry = new ConferenceEventLogEntry();
00162 $entry->setLogId($row['log_id']);
00163 $entry->setConferenceId($row['conference_id']);
00164 $entry->setSchedConfId($row['sched_conf_id']);
00165 $entry->setUserId($row['user_id']);
00166 $entry->setDateLogged($this->datetimeFromDB($row['date_logged']));
00167 $entry->setIPAddress($row['ip_address']);
00168 $entry->setLogLevel($row['log_level']);
00169 $entry->setEventType($row['event_type']);
00170 $entry->setAssocType($row['assoc_type']);
00171 $entry->setSchedConfTitle($row['sched_conf_title']);
00172 $entry->setConferenceTitle($row['conference_title']);
00173 $entry->setAssocId($row['assoc_id']);
00174 $entry->setIsTranslated($row['is_translated']);
00175 $entry->setEntryParams(unserialize($row['entry_params']));
00176 $entry->setMessage($row['message']);
00177
00178 HookRegistry::call('ConferenceEventLogDAO::_returnLogEntryFromRow', array(&$entry, &$row));
00179
00180 return $entry;
00181 }
00182
00187 function insertLogEntry(&$entry) {
00188 if ($entry->getDateLogged() == null) {
00189 $entry->setDateLogged(Core::getCurrentDate());
00190 }
00191 if ($entry->getIPAddress() == null) {
00192 $entry->setIPAddress(Request::getRemoteAddr());
00193 }
00194 $this->update(
00195 sprintf('INSERT INTO conference_event_log
00196 (conference_id, sched_conf_id, user_id, date_logged, ip_address, log_level, event_type, assoc_type, assoc_id, is_translated, entry_params, message)
00197 VALUES
00198 (?, ?, ?, %s, ?, ?, ?, ?, ?, ?, ?, ?)',
00199 $this->datetimeToDB($entry->getDateLogged())),
00200 array(
00201 $entry->getConferenceId(),
00202 $entry->getSchedConfId(),
00203 $entry->getUserId(),
00204 $entry->getIPAddress(),
00205 $entry->getLogLevel(),
00206 $entry->getEventType(),
00207 $entry->getAssocType(),
00208 $entry->getAssocId(),
00209 1,
00210 $entry->getEntryParamsSerialized(),
00211 $entry->getMessage()
00212 )
00213 );
00214
00215 $entry->setLogId($this->getInsertLogId());
00216 return $entry->getLogId();
00217 }
00218
00225 function deleteLogEntry($logId, $conferenceId, $schedConfId = null) {
00226 $args = array($logId, $conferenceId);
00227 if(isset($schedConfId))
00228 $args[] = $schedConfId;
00229
00230 return $this->update(
00231 'DELETE FROM conference_event_log WHERE log_id = ?
00232 AND conference_id = ?' .
00233 (isset($schedConfId)? ' AND sched_conf_id = ?' : ''),
00234 $args);
00235 }
00236
00241 function deleteConferenceLogEntries($conferenceId, $schedConfId = null) {
00242 $args = array($conferenceId);
00243
00244 if(isset($schedConfId))
00245 $args[] = $schedConfId;
00246
00247 return $this->update(
00248 'DELETE FROM conference_event_log WHERE conference_id = ?' .
00249 (isset($schedConfId) ? ' AND sched_conf_id = ?' : ''),
00250 (count($args)>1 ? $args : array_shift($args)));
00251 }
00252
00258 function transferConferenceLogEntries($oldUserId, $newUserId) {
00259 return $this->update(
00260 'UPDATE conference_event_log SET user_id = ? WHERE user_id = ?',
00261 array($newUserId, $oldUserId)
00262 );
00263 }
00264
00269 function getInsertLogId() {
00270 return $this->getInsertId('conference_event_log', 'log_id');
00271 }
00272
00273 }
00274
00275 ?>