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)  

SpecialEventDAO.inc.php
Go to the documentation of this file.
1 <?php
2 
16 //$Id$
17 
18 import('scheduler.SpecialEvent');
19 
20 class SpecialEventDAO extends DAO {
26  function &getSpecialEvent($specialEventId) {
27  $result =& $this->retrieve(
28  'SELECT * FROM special_events WHERE special_event_id = ?', $specialEventId
29  );
30 
31  $returner = null;
32  if ($result->RecordCount() != 0) {
33  $returner =& $this->_returnSpecialEventFromRow($result->GetRowAssoc(false));
34  }
35  $result->Close();
36  return $returner;
37  }
38 
44  function getSpecialEventSchedConfId($specialEventId) {
45  $result =& $this->retrieve(
46  'SELECT sched_conf_id FROM special_events WHERE special_event_id = ?', $specialEventId
47  );
48 
49  return isset($result->fields[0]) ? $result->fields[0] : 0;
50  }
51 
58  function specialEventExistsForSchedConf($specialEventId, $schedConfId) {
59  $result =& $this->retrieve(
60  'SELECT COUNT(*)
61  FROM special_events
62  WHERE special_event_id = ?
63  AND sched_conf_id = ?',
64  array(
65  $specialEventId,
66  $schedConfId
67  )
68  );
69  $returner = isset($result->fields[0]) && $result->fields[0] != 0 ? true : false;
70 
71  $result->Close();
72  unset($result);
73 
74  return $returner;
75  }
76 
81  function getLocaleFieldNames() {
82  return array('name', 'description');
83  }
84 
90  function &_returnSpecialEventFromRow(&$row) {
91  $specialEvent = new SpecialEvent();
92  $specialEvent->setId($row['special_event_id']);
93  $specialEvent->setSchedConfId($row['sched_conf_id']);
94  $specialEvent->setStartTime($this->datetimeFromDB($row['start_time']));
95  $specialEvent->setEndTime($this->datetimeFromDB($row['end_time']));
96  $this->getDataObjectSettings('special_event_settings', 'special_event_id', $row['special_event_id'], $specialEvent);
97 
98  return $specialEvent;
99  }
100 
105  function updateLocaleFields(&$specialEvent) {
106  $this->updateDataObjectSettings('special_event_settings', $specialEvent, array(
107  'special_event_id' => $specialEvent->getId()
108  ));
109  }
110 
116  function insertSpecialEvent(&$specialEvent) {
117  $this->update(
118  sprintf('INSERT INTO special_events
119  (sched_conf_id, start_time, end_time)
120  VALUES
121  (?, %s, %s)',
122  $this->datetimeToDB($specialEvent->getStartTime()), $this->datetimeToDB($specialEvent->getEndTime())
123  ), array(
124  (int) $specialEvent->getSchedConfId()
125  )
126  );
127  $specialEvent->setId($this->getInsertSpecialEventId());
128  $this->updateLocaleFields($specialEvent);
129  return $specialEvent->getId();
130  }
131 
137  function updateSpecialEvent(&$specialEvent) {
138  $returner = $this->update(
139  sprintf('UPDATE special_events
140  SET sched_conf_id = ?,
141  start_time = %s,
142  end_time = %s
143  WHERE special_event_id = ?',
144  $this->datetimeToDB($specialEvent->getStartTime()), $this->datetimeToDB($specialEvent->getEndTime())
145  ), array(
146  (int) $specialEvent->getSchedConfId(),
147  (int) $specialEvent->getId()
148  )
149  );
150  $this->updateLocaleFields($specialEvent);
151  return $returner;
152  }
153 
159  function deleteSpecialEvent($specialEvent) {
160  return $this->deleteSpecialEventById($specialEvent->getId());
161  }
162 
168  function deleteSpecialEventById($specialEventId) {
169  $this->update('DELETE FROM special_event_settings WHERE special_event_id = ?', $specialEventId);
170  $ret = $this->update('DELETE FROM special_events WHERE special_event_id = ?', $specialEventId);
171  return $ret;
172  }
173 
178  function deleteSpecialEventsBySchedConfId($schedConfId) {
179  $specialEvents =& $this->getSpecialEventsBySchedConfId($schedConfId);
180  while (($specialEvent =& $specialEvents->next())) {
181  $this->deleteSpecialEvent($specialEvent);
182  unset($specialEvent);
183  }
184  }
185 
191  function &getSpecialEventsBySchedConfId($schedConfId, $rangeInfo = null) {
192  $result =& $this->retrieveRange('SELECT * FROM special_events WHERE sched_conf_id = ? ORDER BY start_time, end_time', $schedConfId, $rangeInfo);
193  $returner = new DAOResultFactory($result, $this, '_returnSpecialEventFromRow');
194  return $returner;
195  }
196 
202  return $this->getInsertId('special_events', 'special_event_id');
203  }
204 }
205 
206 ?>
config TEMPLATE inc php
Definition: config.inc.php:4
& getSpecialEvent($specialEventId)
& _returnSpecialEventFromRow(&$row)
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:30
deleteSpecialEventById($specialEventId)
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:62
getInsertId($table='', $id='', $callHooks=true)
Definition: DAO.inc.php:225
updateLocaleFields(&$specialEvent)
updateDataObjectSettings($tableName, &$dataObject, $idArray)
Definition: DAO.inc.php:412
deleteSpecialEventsBySchedConfId($schedConfId)
& retrieveRange($sql, $params=false, $dbResultRange=null, $callHooks=true)
Definition: DAO.inc.php:152
& getSpecialEventsBySchedConfId($schedConfId, $rangeInfo=null)
datetimeFromDB($dt)
Definition: DAO.inc.php:276
getSpecialEventSchedConfId($specialEventId)
Wrapper around ADORecordSet providing "factory" features for generating objects from DAOs.
Operations for retrieving and modifying SpecialEvent objects.
updateSpecialEvent(&$specialEvent)
deleteSpecialEvent($specialEvent)
getDataObjectSettings($tableName, $idFieldName, $idFieldValue, &$dataObject)
Definition: DAO.inc.php:498
datetimeToDB($dt)
Definition: DAO.inc.php:258
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:186
insertSpecialEvent(&$specialEvent)
specialEventExistsForSchedConf($specialEventId, $schedConfId)
Basic class describing a specialEvent.