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)  

SignoffDAO.inc.php
Go to the documentation of this file.
1 <?php
2 
16 //$Id$
17 
18 
19 import('signoff.Signoff');
20 
21 class SignoffDAO extends DAO {
27  function getById($signoffId) {
28  $result =& $this->retrieve(
29  'SELECT * FROM signoffs WHERE signoff_id = ?', array((int) $signoffId)
30  );
31 
32  $returner = null;
33  if ($result->RecordCount() != 0) {
34  $returner =& $this->_fromRow($result->GetRowAssoc(false));
35  }
36  $result->Close();
37  return $returner;
38  }
39 
47  function build($symbolic, $assocType, $assocId) {
48  // If one exists, fetch and return.
49  $signoff = $this->getBySymbolic($symbolic, $assocType, $assocId);
50  if ($signoff) return $signoff;
51 
52  // Otherwise, build one.
53  unset($signoff);
54  $signoff = $this->newDataObject();
55  $signoff->setSymbolic($symbolic);
56  $signoff->setAssocType($assocType);
57  $signoff->setAssocId($assocId);
58  $this->insertObject($signoff);
59  return $signoff;
60  }
61 
66  function newDataObject() {
67  return new Signoff();
68  }
69 
75  function _fromRow(&$row) {
76  $signoff = $this->newDataObject();
77 
78  $signoff->setId($row['signoff_id']);
79  $signoff->setAssocType($row['assoc_type']);
80  $signoff->setAssocId($row['assoc_id']);
81  $signoff->setSymbolic($row['symbolic']);
82  $signoff->setUserId($row['user_id']);
83  $signoff->setFileId($row['file_id']);
84  $signoff->setFileRevision($row['file_revision']);
85  $signoff->setDateNotified($this->datetimeFromDB($row['date_notified']));
86  $signoff->setDateUnderway($this->datetimeFromDB($row['date_underway']));
87  $signoff->setDateCompleted($this->datetimeFromDB($row['date_completed']));
88  $signoff->setDateAcknowledged($this->datetimeFromDB($row['date_acknowledged']));
89 
90  return $signoff;
91  }
92 
98  function insertObject(&$signoff) {
99  $this->update(
100  sprintf(
101  'INSERT INTO signoffs
102  (symbolic, assoc_type, assoc_id, user_id, file_id, file_revision, date_notified, date_underway, date_completed, date_acknowledged)
103  VALUES
104  (?, ?, ?, ?, ?, ?, %s, %s, %s, %s)',
105  $this->datetimeToDB($signoff->getDateNotified()),
106  $this->datetimeToDB($signoff->getDateUnderway()),
107  $this->datetimeToDB($signoff->getDateCompleted()),
108  $this->datetimeToDB($signoff->getDateAcknowledged())
109  ),
110  array(
111  $signoff->getSymbolic(),
112  (int) $signoff->getAssocType(),
113  (int) $signoff->getAssocId(),
114  (int) $signoff->getUserId(),
115  $this->nullOrInt($signoff->getFileId()),
116  $this->nullOrInt($signoff->getFileRevision())
117  )
118  );
119  $signoff->setId($this->getInsertId());
120  return $signoff->getId();
121  }
122 
128  function updateObject(&$signoff) {
129  $returner = $this->update(
130  sprintf(
131  'UPDATE signoffs
132  SET symbolic = ?,
133  assoc_type = ?,
134  assoc_id = ?,
135  user_id = ?,
136  file_id = ?,
137  file_revision = ?,
138  date_notified = %s,
139  date_underway = %s,
140  date_completed = %s,
141  date_acknowledged = %s
142  WHERE signoff_id = ?',
143  $this->datetimeToDB($signoff->getDateNotified()),
144  $this->datetimeToDB($signoff->getDateUnderway()),
145  $this->datetimeToDB($signoff->getDateCompleted()),
146  $this->datetimeToDB($signoff->getDateAcknowledged())
147  ),
148  array(
149  $signoff->getSymbolic(),
150  (int) $signoff->getAssocType(),
151  (int) $signoff->getAssocId(),
152  (int) $signoff->getUserId(),
153  $this->nullOrInt($signoff->getFileId()),
154  $this->nullOrInt($signoff->getFileRevision()),
155  (int) $signoff->getId()
156  )
157  );
158  return $returner;
159  }
160 
166  function deleteObject($signoff) {
167  return $this->deleteObjectById($signoff->getId());
168  }
169 
175  function deleteObjectById($signoffId) {
176  return $this->update('DELETE FROM signoffs WHERE signoff_id = ?', array((int) $signoffId));
177  }
178 
186  function getBySymbolic($symbolic, $assocType, $assocId) {
187  $result =& $this->retrieve(
188  'SELECT * FROM signoffs WHERE symbolic = ? AND assoc_type = ? AND assoc_id = ?',
189  array($symbolic, (int) $assocType, (int) $assocId)
190  );
191 
192  $returner = null;
193  if ($result->RecordCount() != 0) {
194  $returner = $this->_fromRow($result->GetRowAssoc(false));
195  }
196  $result->Close();
197  return $returner;
198  }
199 
204  function getInsertId() {
205  return parent::getInsertId('signoffs', 'signoff_id');
206  }
207 }
208 
209 ?>
config TEMPLATE inc php
Definition: config.inc.php:4
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:30
Basic class describing a signoff.
Definition: Signoff.inc.php:22
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:62
updateObject(&$signoff)
insertObject(&$signoff)
getBySymbolic($symbolic, $assocType, $assocId)
deleteObject($signoff)
nullOrInt($value)
Definition: DAO.inc.php:376
datetimeFromDB($dt)
Definition: DAO.inc.php:276
build($symbolic, $assocType, $assocId)
Operations for retrieving and modifying Signoff objects.
_fromRow(&$row)
getById($signoffId)
deleteObjectById($signoffId)
datetimeToDB($dt)
Definition: DAO.inc.php:258
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:186