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)  

PaperEmailLogDAO.inc.php
Go to the documentation of this file.
1 <?php
2 
16 //$Id$
17 
18 import ('paper.log.PaperEmailLogEntry');
19 
20 class PaperEmailLogDAO extends DAO {
27  function &getLogEntry($logId, $paperId = null) {
28  if (isset($paperId)) {
29  $result =& $this->retrieve(
30  'SELECT * FROM paper_email_log WHERE log_id = ? AND paper_id = ?',
31  array($logId, $paperId)
32  );
33  } else {
34  $result =& $this->retrieve(
35  'SELECT * FROM paper_email_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 
67  function &getPaperLogEntriesByAssoc($paperId, $assocType = null, $assocId = null, $rangeInfo = null) {
68  $params = array($paperId);
69  if (isset($assocType)) {
70  array_push($params, $assocType);
71  if (isset($assocId)) {
72  array_push($params, $assocId);
73  }
74  }
75 
76  $result =& $this->retrieveRange(
77  'SELECT * FROM paper_email_log WHERE paper_id = ?' . (isset($assocType) ? ' AND assoc_type = ?' . (isset($assocId) ? ' AND assoc_id = ?' : '') : '') . ' ORDER BY log_id DESC',
78  $params, $rangeInfo
79  );
80 
81  $returner = new DAOResultFactory($result, $this, '_returnLogEntryFromRow');
82  return $returner;
83  }
84 
90  function &_returnLogEntryFromRow(&$row) {
91  $entry = new PaperEmailLogEntry();
92  $entry->setLogId($row['log_id']);
93  $entry->setPaperId($row['paper_id']);
94  $entry->setSenderId($row['sender_id']);
95  $entry->setDateSent($this->datetimeFromDB($row['date_sent']));
96  $entry->setIPAddress($row['ip_address']);
97  $entry->setEventType($row['event_type']);
98  $entry->setAssocType($row['assoc_type']);
99  $entry->setAssocId($row['assoc_id']);
100  $entry->setFrom($row['from_address']);
101  $entry->setRecipients($row['recipients']);
102  $entry->setCcs($row['cc_recipients']);
103  $entry->setBccs($row['bcc_recipients']);
104  $entry->setSubject($row['subject']);
105  $entry->setBody($row['body']);
106 
107  HookRegistry::call('PaperEmailLogDAO::_returnLogEntryFromRow', array(&$entry, &$row));
108 
109  return $entry;
110  }
111 
116  function insertLogEntry(&$entry) {
117  if ($entry->getDateSent() == null) {
118  $entry->setDateSent(Core::getCurrentDate());
119  }
120  if ($entry->getIPAddress() == null) {
121  $entry->setIPAddress(Request::getRemoteAddr());
122  }
123  $this->update(
124  sprintf('INSERT INTO paper_email_log
125  (paper_id, sender_id, date_sent, ip_address, event_type, assoc_type, assoc_id, from_address, recipients, cc_recipients, bcc_recipients, subject, body)
126  VALUES
127  (?, ?, %s, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
128  $this->datetimeToDB($entry->getDateSent())),
129  array(
130  $entry->getPaperId(),
131  $entry->getSenderId(),
132  $entry->getIPAddress(),
133  $entry->getEventType(),
134  $entry->getAssocType(),
135  $entry->getAssocId(),
136  $entry->getFrom(),
137  $entry->getRecipients(),
138  $entry->getCcs(),
139  $entry->getBccs(),
140  $entry->getSubject(),
141  $entry->getBody()
142  )
143  );
144 
145  $entry->setLogId($this->getInsertLogId());
146  return $entry->getLogId();
147  }
148 
154  function deleteLogEntry($logId, $paperId = null) {
155  if (isset($paperId)) {
156  return $this->update(
157  'DELETE FROM paper_email_log WHERE log_id = ? AND paper_id = ?',
158  array($logId, $paperId)
159  );
160 
161  } else {
162  return $this->update(
163  'DELETE FROM paper_email_log WHERE log_id = ?', $logId
164  );
165  }
166  }
167 
172  function deletePaperLogEntries($paperId) {
173  return $this->update(
174  'DELETE FROM paper_email_log WHERE paper_id = ?', $paperId
175  );
176  }
177 
182  function transferPaperLogEntries($oldUserId, $newUserId) {
183  return $this->update(
184  'UPDATE paper_email_log SET sender_id = ? WHERE sender_id = ?',
185  array($newUserId, $oldUserId)
186  );
187  }
188 
193  function getInsertLogId() {
194  return $this->getInsertId('paper_email_log', 'log_id');
195  }
196 }
197 
198 ?>
config TEMPLATE inc php
Definition: config.inc.php:4
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:30
Describes an entry in the paper email log.
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:62
& getPaperLogEntries($paperId, $rangeInfo=null)
getInsertId($table='', $id='', $callHooks=true)
Definition: DAO.inc.php:225
& getPaperLogEntriesByAssoc($paperId, $assocType=null, $assocId=null, $rangeInfo=null)
getCurrentDate($ts=null)
Definition: Core.inc.php:90
& retrieveRange($sql, $params=false, $dbResultRange=null, $callHooks=true)
Definition: DAO.inc.php:152
Class for inserting/accessing paper email log entries.
datetimeFromDB($dt)
Definition: DAO.inc.php:276
Wrapper around ADORecordSet providing "factory" features for generating objects from DAOs.
deleteLogEntry($logId, $paperId=null)
call($hookName, $args=null)
datetimeToDB($dt)
Definition: DAO.inc.php:258
& getLogEntry($logId, $paperId=null)
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:186
transferPaperLogEntries($oldUserId, $newUserId)