ocs  2.3.6
About: OCS (Open Conference System) is a Web publishing tool that will create a complete Web presence for your scholarly conference.
  Fossies Dox: ocs-2.3.6.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

PaperEventLogDAO.inc.php
Go to the documentation of this file.
1 <?php
2 
16 //$Id$
17 
18 import ('paper.log.PaperEventLogEntry');
19 
20 class PaperEventLogDAO extends DAO {
27  function &getLogEntry($logId, $paperId = null) {
28  if (isset($paperId)) {
29  $result =& $this->retrieve(
30  'SELECT * FROM paper_event_log WHERE log_id = ? AND paper_id = ?',
31  array($logId, $paperId)
32  );
33  } else {
34  $result =& $this->retrieve(
35  'SELECT * FROM paper_event_log WHERE log_id = ?', $logId
36  );
37  }
38 
39  $returner = null;
40  if ($result->RecordCount() != 0) {
41  $returner =& $this->_returnLogEntryFromRow($result->GetRowAssoc(false));
42  }
43 
44  $result->Close();
45  unset($result);
46 
47  return $returner;
48  }
49 
55  function &getPaperLogEntries($paperId, $rangeInfo = null) {
56  $returner =& $this->getPaperLogEntriesByAssoc($paperId, null, null, $rangeInfo);
57  return $returner;
58  }
59 
69  function &getPaperLogEntriesByAssoc($paperId, $assocType = null, $assocId = null, $rangeInfo = null) {
70  $params = array($paperId);
71  if (isset($assocType)) {
72  array_push($params, $assocType);
73  if (isset($assocId)) {
74  array_push($params, $assocId);
75  }
76  }
77 
78  $result =& $this->retrieveRange(
79  'SELECT * FROM paper_event_log WHERE paper_id = ?' . (isset($assocType) ? ' AND assoc_type = ?' . (isset($assocId) ? ' AND assoc_id = ?' : '') : '') . ' ORDER BY log_id DESC',
80  $params, $rangeInfo
81  );
82 
83  $returner = new DAOResultFactory($result, $this, '_returnLogEntryFromRow');
84  return $returner;
85  }
86 
92  function &_returnLogEntryFromRow(&$row) {
93  $entry = new PaperEventLogEntry();
94  $entry->setLogId($row['log_id']);
95  $entry->setPaperId($row['paper_id']);
96  $entry->setUserId($row['user_id']);
97  $entry->setDateLogged($this->datetimeFromDB($row['date_logged']));
98  $entry->setIPAddress($row['ip_address']);
99  $entry->setLogLevel($row['log_level']);
100  $entry->setEventType($row['event_type']);
101  $entry->setAssocType($row['assoc_type']);
102  $entry->setAssocId($row['assoc_id']);
103  $entry->setIsTranslated($row['is_translated']);
104  $entry->setEntryParams(unserialize($row['entry_params']));
105  $entry->setMessage($row['message']);
106 
107  HookRegistry::call('PaperEventLogDAO::_returnLogEntryFromRow', array(&$entry, &$row));
108 
109  return $entry;
110  }
111 
116  function insertLogEntry(&$entry) {
117  if ($entry->getDateLogged() == null) {
118  $entry->setDateLogged(Core::getCurrentDate());
119  }
120  if ($entry->getIPAddress() == null) {
121  $entry->setIPAddress(Request::getRemoteAddr());
122  }
123  $this->update(
124  sprintf('INSERT INTO paper_event_log
125  (paper_id, user_id, date_logged, ip_address, log_level, event_type, assoc_type, assoc_id, is_translated, entry_params, message)
126  VALUES
127  (?, ?, %s, ?, ?, ?, ?, ?, ?, ?, ?)',
128  $this->datetimeToDB($entry->getDateLogged())),
129  array(
130  $entry->getPaperId(),
131  $entry->getUserId(),
132  $entry->getIPAddress(),
133  $entry->getLogLevel(),
134  $entry->getEventType(),
135  $entry->getAssocType(),
136  $entry->getAssocId(),
137  1, // is_translated: All new entries are.
138  $entry->getEntryParamsSerialized(),
139  $entry->getMessage()
140  )
141  );
142 
143  $entry->setLogId($this->getInsertLogId());
144  return $entry->getLogId();
145  }
146 
152  function deleteLogEntry($logId, $paperId = null) {
153  if (isset($paperId)) {
154  return $this->update(
155  'DELETE FROM paper_event_log WHERE log_id = ? AND paper_id = ?',
156  array($logId, $paperId)
157  );
158 
159  } else {
160  return $this->update(
161  'DELETE FROM paper_event_log WHERE log_id = ?', $logId
162  );
163  }
164  }
165 
170  function deletePaperLogEntries($paperId) {
171  return $this->update(
172  'DELETE FROM paper_event_log WHERE paper_id = ?', $paperId
173  );
174  }
175 
180  function transferPaperLogEntries($oldUserId, $newUserId) {
181  return $this->update(
182  'UPDATE paper_event_log SET user_id = ? WHERE user_id = ?',
183  array($newUserId, $oldUserId)
184  );
185  }
186 
191  function getInsertLogId() {
192  return $this->getInsertId('paper_event_log', 'log_id');
193  }
194 }
195 
196 ?>
config TEMPLATE inc php
Definition: config.inc.php:4
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:30
& getPaperLogEntries($paperId, $rangeInfo=null)
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:62
Class for inserting/accessing paper history log entries.
transferPaperLogEntries($oldUserId, $newUserId)
getInsertId($table='', $id='', $callHooks=true)
Definition: DAO.inc.php:225
getCurrentDate($ts=null)
Definition: Core.inc.php:90
& retrieveRange($sql, $params=false, $dbResultRange=null, $callHooks=true)
Definition: DAO.inc.php:152
datetimeFromDB($dt)
Definition: DAO.inc.php:276
Wrapper around ADORecordSet providing "factory" features for generating objects from DAOs.
Describes an entry in the paper history log.
call($hookName, $args=null)
& getLogEntry($logId, $paperId=null)
datetimeToDB($dt)
Definition: DAO.inc.php:258
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:186
deleteLogEntry($logId, $paperId=null)
& getPaperLogEntriesByAssoc($paperId, $assocType=null, $assocId=null, $rangeInfo=null)