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)  

TimeBlockDAO.inc.php
Go to the documentation of this file.
1 <?php
2 
18 import('scheduler.TimeBlock');
19 
20 class TimeBlockDAO extends DAO {
26  function &getTimeBlock($timeBlockId) {
27  $result =& $this->retrieve(
28  'SELECT * FROM time_blocks WHERE time_block_id = ?', $timeBlockId
29  );
30 
31  $returner = null;
32  if ($result->RecordCount() != 0) {
33  $returner =& $this->_returnTimeBlockFromRow($result->GetRowAssoc(false));
34  }
35  $result->Close();
36  return $returner;
37  }
38 
44  function getTimeBlockSchedConfId($timeBlockId) {
45  $result =& $this->retrieve(
46  'SELECT sched_conf_id FROM time_blocks WHERE time_block_id = ?', $timeBlockId
47  );
48 
49  return isset($result->fields[0]) ? $result->fields[0] : 0;
50  }
51 
58  function timeBlockExistsForSchedConf($timeBlockId, $schedConfId) {
59  $result =& $this->retrieve(
60  'SELECT COUNT(*)
61  FROM time_blocks
62  WHERE time_block_id = ?
63  AND sched_conf_id = ?',
64  array(
65  $timeBlockId,
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 
82  function timeBlocksExistForSchedConf($schedConfId) {
83  $result =& $this->retrieve(
84  'SELECT COUNT(*)
85  FROM time_blocks
86  WHERE sched_conf_id = ?',
87  array($schedConfId)
88  );
89  $returner = isset($result->fields[0]) && $result->fields[0] != 0 ? true : false;
90 
91  $result->Close();
92  unset($result);
93 
94  return $returner;
95  }
96 
101  function getLocaleFieldNames() {
102  return array('name', 'description');
103  }
104 
110  function &_returnTimeBlockFromRow(&$row) {
111  $timeBlock = new TimeBlock();
112  $timeBlock->setId($row['time_block_id']);
113  $timeBlock->setSchedConfId($row['sched_conf_id']);
114  $timeBlock->setStartTime($this->datetimeFromDB($row['start_time']));
115  $timeBlock->setEndTime($this->datetimeFromDB($row['end_time']));
116  $timeBlock->setAssignedColour($row['assigned_colour']);
117  $timeBlock->setUnassignedColour($row['unassigned_colour']);
118  $this->getDataObjectSettings('time_block_settings', 'time_block_id', $row['time_block_id'], $timeBlock);
119  return $timeBlock;
120  }
121 
126  function updateLocaleFields(&$timeBlock) {
127  $this->updateDataObjectSettings('time_block_settings', $timeBlock, array(
128  'time_block_id' => $timeBlock->getId()
129  ));
130  }
131 
137  function insertTimeBlock(&$timeBlock) {
138  $this->update(
139  sprintf('INSERT INTO time_blocks (
140  sched_conf_id,
141  start_time,
142  end_time, assigned_colour,
143  unassigned_colour
144  ) VALUES (?, %s, %s, ?, ?)',
145  $this->datetimeToDB($timeBlock->getStartTime()),
146  $this->datetimeToDB($timeBlock->getEndTime())
147  ), array(
148  $timeBlock->getSchedConfId(),
149  $timeBlock->getAssignedColour(),
150  $timeBlock->getUnassignedColour()
151  )
152  );
153  $timeBlock->setId($this->getInsertTimeBlockId());
154  $this->updateLocaleFields($timeBlock);
155  return $timeBlock->getId();
156  }
157 
163  function updateTimeBlock(&$timeBlock) {
164  $returner = $this->update(
165  sprintf('UPDATE time_blocks
166  SET sched_conf_id = ?,
167  start_time = %s,
168  end_time = %s,
169  assigned_colour = ?,
170  unassigned_colour = ?
171  WHERE time_block_id = ?',
172  $this->datetimeToDB($timeBlock->getStartTime()),
173  $this->datetimeToDB($timeBlock->getEndTime())
174  ), array(
175  $timeBlock->getSchedConfId(),
176  $timeBlock->getAssignedColour(),
177  $timeBlock->getUnassignedColour(),
178  $timeBlock->getId()
179  )
180  );
181  $this->updateLocaleFields($timeBlock);
182  return $returner;
183  }
184 
190  function deleteTimeBlock($timeBlock) {
191  return $this->deleteTimeBlockById($timeBlock->getId());
192  }
193 
199  function deleteTimeBlockById($timeBlockId) {
200  $this->update('DELETE FROM time_block_settings WHERE time_block_id = ?', $timeBlockId);
201  $this->update('DELETE FROM time_block_settings WHERE time_block_id = ?', $timeBlockId);
202  return $this->update('DELETE FROM time_blocks WHERE time_block_id = ?', $timeBlockId);
203  }
204 
209  function deleteTimeBlocksBySchedConfId($schedConfId) {
210  $timeBlocks =& $this->getTimeBlocksBySchedConfId($schedConfId);
211  while (($timeBlock =& $timeBlocks->next())) {
212  $this->deleteTimeBlock($timeBlock);
213  unset($timeBlock);
214  }
215  }
216 
222  function &getTimeBlocksBySchedConfId($schedConfId, $rangeInfo = null) {
223  $result =& $this->retrieveRange(
224  'SELECT * FROM time_blocks WHERE sched_conf_id = ? ORDER BY start_time',
225  $schedConfId,
226  $rangeInfo
227  );
228 
229  $returner = new DAOResultFactory($result, $this, '_returnTimeBlockFromRow');
230  return $returner;
231  }
232 
237  function getInsertTimeBlockId() {
238  return $this->getInsertId('time_blocks', 'time_block_id');
239  }
240 }
241 
242 ?>
config TEMPLATE inc php
Definition: config.inc.php:4
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:30
timeBlockExistsForSchedConf($timeBlockId, $schedConfId)
insertTimeBlock(&$timeBlock)
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:62
getTimeBlockSchedConfId($timeBlockId)
getInsertId($table='', $id='', $callHooks=true)
Definition: DAO.inc.php:225
updateDataObjectSettings($tableName, &$dataObject, $idArray)
Definition: DAO.inc.php:412
deleteTimeBlock($timeBlock)
& retrieveRange($sql, $params=false, $dbResultRange=null, $callHooks=true)
Definition: DAO.inc.php:152
updateTimeBlock(&$timeBlock)
deleteTimeBlocksBySchedConfId($schedConfId)
datetimeFromDB($dt)
Definition: DAO.inc.php:276
updateLocaleFields(&$timeBlock)
Wrapper around ADORecordSet providing "factory" features for generating objects from DAOs.
deleteTimeBlockById($timeBlockId)
& _returnTimeBlockFromRow(&$row)
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
timeBlocksExistForSchedConf($schedConfId)
& getTimeBlock($timeBlockId)
& getTimeBlocksBySchedConfId($schedConfId, $rangeInfo=null)