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)  

PKPAnnouncementDAO.inc.php
Go to the documentation of this file.
1 <?php
2 
16 import('announcement.PKPAnnouncement');
17 
18 class PKPAnnouncementDAO extends DAO {
24  function &getAnnouncement($announcementId) {
25  $result =& $this->retrieve(
26  'SELECT * FROM announcements WHERE announcement_id = ?', $announcementId
27  );
28 
29  $returner = null;
30  if ($result->RecordCount() != 0) {
31  $returner =& $this->_returnAnnouncementFromRow($result->GetRowAssoc(false));
32  }
33  $result->Close();
34  return $returner;
35  }
36 
42  function getAnnouncementAssocId($announcementId) {
43  $result =& $this->retrieve(
44  'SELECT assoc_id FROM announcements WHERE announcement_id = ?', $announcementId
45  );
46 
47  return isset($result->fields[0]) ? $result->fields[0] : 0;
48  }
49 
55  function getAnnouncementAssocType($announcementId) {
56  $result =& $this->retrieve(
57  'SELECT assoc_type FROM announcements WHERE announcement_id = ?', $announcementId
58  );
59 
60  return isset($result->fields[0]) ? $result->fields[0] : 0;
61  }
62 
67  function getLocaleFieldNames() {
68  return array('title', 'descriptionShort', 'description');
69  }
70 
76  function &_returnAnnouncementFromRow(&$row) {
77  $announcement = new Announcement();
78  $announcement->setId($row['announcement_id']);
79  $announcement->setAssocType($row['assoc_type']);
80  $announcement->setAssocId($row['assoc_id']);
81  $announcement->setTypeId($row['type_id']);
82  $announcement->setDateExpire($this->dateFromDB($row['date_expire']));
83  $announcement->setDatePosted($this->datetimeFromDB($row['date_posted']));
84 
85  $this->getDataObjectSettings('announcement_settings', 'announcement_id', $row['announcement_id'], $announcement);
86 
87  return $announcement;
88  }
89 
94  function updateLocaleFields(&$announcement) {
95  $this->updateDataObjectSettings('announcement_settings', $announcement, array(
96  'announcement_id' => $announcement->getId()
97  ));
98  }
99 
105  function insertAnnouncement(&$announcement) {
106  $this->update(
107  sprintf('INSERT INTO announcements
108  (assoc_type, assoc_id, type_id, date_expire, date_posted)
109  VALUES
110  (?, ?, ?, %s, %s)',
111  $this->datetimeToDB($announcement->getDateExpire()), $this->datetimeToDB($announcement->getDatetimePosted())),
112  array(
113  $announcement->getAssocType(),
114  $announcement->getAssocId(),
115  $announcement->getTypeId()
116  )
117  );
118  $announcement->setId($this->getInsertAnnouncementId());
119  $this->updateLocaleFields($announcement);
120  return $announcement->getId();
121  }
122 
128  function updateObject(&$announcement) {
129  $returner = $this->update(
130  sprintf('UPDATE announcements
131  SET
132  assoc_type = ?,
133  assoc_id = ?,
134  type_id = ?,
135  date_expire = %s
136  WHERE announcement_id = ?',
137  $this->datetimeToDB($announcement->getDateExpire())),
138  array(
139  $announcement->getAssocType(),
140  $announcement->getAssocId(),
141  $announcement->getTypeId(),
142  $announcement->getId()
143  )
144  );
145  $this->updateLocaleFields($announcement);
146  return $returner;
147  }
148 
149  function updateAnnouncement(&$announcement) {
150  if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
151  return $this->updateObject($announcement);
152  }
153 
159  function deleteObject($announcement) {
160  return $this->deleteAnnouncementById($announcement->getId());
161  }
162 
163  function deleteAnnouncement($announcement) {
164  if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
165  return $this->deleteObject($announcement);
166  }
167 
173  function deleteAnnouncementById($announcementId) {
174  $this->update('DELETE FROM announcement_settings WHERE announcement_id = ?', $announcementId);
175  return $this->update('DELETE FROM announcements WHERE announcement_id = ?', $announcementId);
176  }
177 
183  function deleteAnnouncementByTypeId($typeId) {
184  $announcements =& $this->getAnnouncementsByTypeId($typeId);
185  while (($announcement =& $announcements->next())) {
186  $this->deleteObject($announcement);
187  unset($announcement);
188  }
189  }
190 
196  function deleteAnnouncementsByAssocId($assocType, $assocId) {
197  $announcements =& $this->getAnnouncementsByAssocId($assocType, $assocId);
198  while (($announcement =& $announcements->next())) {
199  $this->deleteAnnouncementById($announcement->getId());
200  unset($announcement);
201  }
202  return true;
203  }
204 
210  function &getAnnouncementsByAssocId($assocType, $assocId, $rangeInfo = null) {
211  $result =& $this->retrieveRange(
212  'SELECT *
213  FROM announcements
214  WHERE assoc_type = ? AND assoc_id = ?
215  ORDER BY announcement_id DESC',
216  array($assocType, $assocId),
217  $rangeInfo
218  );
219 
220  $returner = new DAOResultFactory($result, $this, '_returnAnnouncementFromRow');
221  return $returner;
222  }
223 
229  function &getAnnouncementsByTypeId($typeId, $rangeInfo = null) {
230  $result =& $this->retrieveRange(
231  'SELECT * FROM announcements WHERE type_id = ? ORDER BY announcement_id DESC', $typeId, $rangeInfo
232  );
233 
234  $returner = new DAOResultFactory($result, $this, '_returnAnnouncementFromRow');
235  return $returner;
236  }
237 
243  function &getNumAnnouncementsByAssocId($assocType, $assocId, $numAnnouncements, $rangeInfo = null) {
244  $result =& $this->retrieveRange(
245  'SELECT *
246  FROM announcements
247  WHERE assoc_type = ?
248  AND assoc_id = ?
249  ORDER BY announcement_id DESC LIMIT ?',
250  array($assocType, $assocId, $numAnnouncements),
251  $rangeInfo
252  );
253 
254  $returner = new DAOResultFactory($result, $this, '_returnAnnouncementFromRow');
255  return $returner;
256  }
257 
263  function &getAnnouncementsNotExpiredByAssocId($assocType, $assocId, $rangeInfo = null) {
264  $result =& $this->retrieveRange(
265  'SELECT *
266  FROM announcements
267  WHERE assoc_type = ?
268  AND assoc_id = ?
269  AND (date_expire IS NULL OR date_expire > CURRENT_DATE)
270  ORDER BY announcement_id DESC',
271  array($assocType, $assocId),
272  $rangeInfo
273  );
274 
275  $returner = new DAOResultFactory($result, $this, '_returnAnnouncementFromRow');
276  return $returner;
277  }
278 
284  function &getNumAnnouncementsNotExpiredByAssocId($assocType, $assocId, $numAnnouncements, $rangeInfo = null) {
285  $result =& $this->retrieveRange(
286  'SELECT *
287  FROM announcements
288  WHERE assoc_type = ?
289  AND assoc_id = ?
290  AND (date_expire IS NULL OR date_expire > CURRENT_DATE)
291  ORDER BY announcement_id DESC LIMIT ?',
292  array($assocType, $assocId, $numAnnouncements), $rangeInfo
293  );
294 
295  $returner = new DAOResultFactory($result, $this, '_returnAnnouncementFromRow');
296  return $returner;
297  }
298 
304  function &getMostRecentAnnouncementByAssocId($assocType, $assocId) {
305  $result =& $this->retrieve(
306  'SELECT *
307  FROM announcements
308  WHERE assoc_type = ?
309  AND assoc_id = ?
310  ORDER BY announcement_id DESC LIMIT 1',
311  array($assocType, $assocId)
312  );
313 
314  $returner = null;
315  if ($result->RecordCount() != 0) {
316  $returner =& $this->_returnAnnouncementFromRow($result->GetRowAssoc(false));
317  }
318  $result->Close();
319  return $returner;
320  }
321 
327  return $this->getInsertId('announcements', 'announcement_id');
328  }
329 }
330 
331 ?>
getAnnouncementAssocType($announcementId)
config TEMPLATE inc php
Definition: config.inc.php:4
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:30
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:62
getInsertId($table='', $id='', $callHooks=true)
Definition: DAO.inc.php:225
updateDataObjectSettings($tableName, &$dataObject, $idArray)
Definition: DAO.inc.php:412
& retrieveRange($sql, $params=false, $dbResultRange=null, $callHooks=true)
Definition: DAO.inc.php:152
getAnnouncementAssocId($announcementId)
& getAnnouncementsByAssocId($assocType, $assocId, $rangeInfo=null)
datetimeFromDB($dt)
Definition: DAO.inc.php:276
updateAnnouncement(&$announcement)
Wrapper around ADORecordSet providing "factory" features for generating objects from DAOs.
getVar($section, $key, $default=null)
Definition: Config.inc.php:35
insertAnnouncement(&$announcement)
deleteAnnouncementsByAssocId($assocType, $assocId)
updateLocaleFields(&$announcement)
Basic class describing a announcement.
& getAnnouncementsByTypeId($typeId, $rangeInfo=null)
& getAnnouncement($announcementId)
& getAnnouncementsNotExpiredByAssocId($assocType, $assocId, $rangeInfo=null)
deleteAnnouncement($announcement)
& getNumAnnouncementsNotExpiredByAssocId($assocType, $assocId, $numAnnouncements, $rangeInfo=null)
getDataObjectSettings($tableName, $idFieldName, $idFieldValue, &$dataObject)
Definition: DAO.inc.php:498
& getNumAnnouncementsByAssocId($assocType, $assocId, $numAnnouncements, $rangeInfo=null)
datetimeToDB($dt)
Definition: DAO.inc.php:258
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:186
& getMostRecentAnnouncementByAssocId($assocType, $assocId)
deleteAnnouncementById($announcementId)
dateFromDB($d)
Definition: DAO.inc.php:285
Operations for retrieving and modifying Announcement objects.