18 import (
'lib.pkp.classes.log.EventLogEntry');
29 function getById($logId, $assocType =
null, $assocId =
null) {
30 $params = array((
int) $logId);
31 if (isset($assocType)) {
32 $params[] = (int) $assocType;
33 $params[] = (int) $assocId;
37 'SELECT * FROM event_log WHERE log_id = ?' .
38 (isset($assocType)?
' AND assoc_type = ? AND assoc_id = ?':
''),
43 if ($result->RecordCount() != 0) {
44 $returner =& $this->
build($result->GetRowAssoc(
false));
58 function getByAssoc($assocType, $assocId, $rangeInfo =
null) {
60 'SELECT * FROM event_log WHERE assoc_type = ? AND assoc_id = ? ORDER BY log_id DESC',
61 array((
int) $assocType, (
int) $assocId),
83 $entry->setId($row[
'log_id']);
84 $entry->setUserId($row[
'user_id']);
86 $entry->setEventType($row[
'event_type']);
87 $entry->setAssocType($row[
'assoc_type']);
88 $entry->setAssocId($row[
'assoc_id']);
89 $entry->setMessage($row[
'message']);
90 $entry->setIsTranslated($row[
'is_translated']);
92 $result = $this->
retrieve(
'SELECT * FROM event_log_settings WHERE log_id = ?', array((
int) $entry->getId()));
94 while (!$result->EOF) {
95 $r = $result->getRowAssoc(
false);
103 $entry->setParams($params);
116 sprintf(
'INSERT INTO event_log
117 (user_id, date_logged, event_type, assoc_type, assoc_id, message, is_translated)
119 (?, %s, ?, ?, ?, ?, ?)',
122 (
int) $entry->getUserId(),
123 (
int) $entry->getEventType(),
124 (
int) $entry->getAssocType(),
125 (
int) $entry->getAssocId(),
126 $entry->getMessage(),
127 (
int) $entry->getIsTranslated()
133 $params = $entry->getParams();
134 if (is_array($params))
foreach ($params as $key => $value) {
138 (
int) $entry->getId(),
142 'INSERT INTO event_log_settings (log_id, setting_name, setting_value, setting_type) VALUES (?, ?, ?, ?)',
147 return $entry->getId();
154 function deleteById($logId, $assocType =
null, $assocId =
null) {
155 $params = array((
int) $logId);
156 if ($assocType !==
null) {
157 $params[] = (int) $assocType;
158 $params[] = (int) $assocId;
161 'DELETE FROM event_log WHERE log_id = ?' .
162 ($assocType !==
null?
' AND assoc_type = ? AND assoc_id = ?':
''),
165 if ($this->
getAffectedRows()) $this->
update(
'DELETE FROM event_log_settings WHERE log_id = ?', array((
int) $logId));
174 $entries = $this->
getByAssoc($assocType, $assocId);
175 while ($entry = $entries->next()) {
187 'UPDATE event_log SET user_id = ? WHERE user_id = ?',
188 array((
int) $newUserId, (
int) $oldUserId)