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)  

RegistrationOptionDAO.inc.php
Go to the documentation of this file.
1 <?php
2 
16 //$Id$
17 
18 import('registration.RegistrationOption');
19 
20 class RegistrationOptionDAO extends DAO {
27  function &getRegistrationOption($optionId, $code = null) {
28  $params = array((int) $optionId);
29  if ($code !== null) $params[] = $code;
30  $result =& $this->retrieve(
31  'SELECT * FROM registration_options WHERE option_id = ?' .
32  ($code !== null ? ' AND code = ?':''),
33  $params
34  );
35 
36  $returner = null;
37  if ($result->RecordCount() != 0) {
38  $returner =& $this->_returnRegistrationOptionFromRow($result->GetRowAssoc(false));
39  }
40 
41  $result->Close();
42  unset($result);
43 
44  return $returner;
45  }
46 
52  function getRegistrationOptionSchedConfId($optionId) {
53  $result =& $this->retrieve(
54  'SELECT sched_conf_id FROM registration_options WHERE option_id = ?', (int) $optionId
55  );
56 
57  $returner = isset($result->fields[0]) ? $result->fields[0] : 0;
58 
59  $result->Close();
60  unset($result);
61 
62  return $returner;
63  }
64 
70  function getRegistrationOptionName($optionId) {
71  $result =& $this->retrieve(
72  'SELECT COALESCE(l.setting_value, p.setting_value) FROM registration_option_settings l LEFT JOIN registration_option_settings p ON (p.option_id = ? AND p.setting_name = ? AND p.locale = ?) WHERE l.option_id = ? AND l.setting_name = ? AND l.locale = ?',
73  array(
74  $optionId, 'name', AppLocale::getLocale(),
75  $optionId, 'name', AppLocale::getPrimaryLocale()
76  )
77  );
78 
79  $returner = isset($result->fields[0]) ? $result->fields[0] : false;
80 
81  $result->Close();
82  unset($result);
83 
84  return $returner;
85  }
86 
93  function registrationOptionExistsByOptionId($optionId, $schedConfId) {
94  $result =& $this->retrieve(
95  'SELECT COUNT(*)
96  FROM registration_options
97  WHERE option_id = ?
98  AND sched_conf_id = ?',
99  array(
100  (int) $optionId,
101  (int) $schedConfId
102  )
103  );
104  $returner = isset($result->fields[0]) && $result->fields[0] != 0 ? true : false;
105 
106  $result->Close();
107  unset($result);
108 
109  return $returner;
110  }
111 
118  function openRegistrationOptionExistsByOptionId($optionId, $schedConfId) {
119  $time = $this->dateToDB(time());
120 
121  $result =& $this->retrieve(
122  'SELECT COUNT(*)
123  FROM registration_options
124  WHERE option_id = ?
125  AND sched_conf_id = ?
126  AND opening_date <= ' . $time . '
127  AND closing_date > ' . $time . '
128  AND pub = 1',
129  array(
130  (int) $optionId,
131  (int) $schedConfId
132  )
133  );
134  $returner = isset($result->fields[0]) && $result->fields[0] != 0 ? true : false;
135 
136  $result->Close();
137  unset($result);
138 
139  return $returner;
140  }
141 
149  function checkCode($optionId, $schedConfId, $code) {
150  $result =& $this->retrieve(
151  'SELECT COUNT(*)
152  FROM registration_options
153  WHERE option_id = ?
154  AND sched_conf_id = ?
155  AND code = ?',
156  array(
157  (int) $optionId,
158  (int) $schedConfId,
159  $code
160  )
161  );
162  $returner = isset($result->fields[0]) && $result->fields[0] != 0 ? true : false;
163 
164  $result->Close();
165  unset($result);
166 
167  return $returner;
168  }
169 
176  $registrationOption = new RegistrationOption();
177  $registrationOption->setOptionId($row['option_id']);
178  $registrationOption->setSchedConfId($row['sched_conf_id']);
179  $registrationOption->setCode($row['code']);
180  $registrationOption->setOpeningDate($this->dateFromDB($row['opening_date']));
181  $registrationOption->setClosingDate($this->datetimeFromDB($row['closing_date']));
182  $registrationOption->setSequence($row['seq']);
183  $registrationOption->setPublic($row['pub']);
184 
185  $this->getDataObjectSettings('registration_option_settings', 'option_id', $row['option_id'], $registrationOption);
186 
187  HookRegistry::call('RegistrationOptionDAO::_returnRegistrationOptionFromRow', array(&$registrationOption, &$row));
188 
189  return $registrationOption;
190  }
191 
196  function getLocaleFieldNames() {
197  return array('name', 'description');
198  }
199 
204  function updateLocaleFields(&$registrationOption) {
205  $this->updateDataObjectSettings('registration_option_settings', $registrationOption, array(
206  'option_id' => $registrationOption->getOptionId()
207  ));
208  }
209 
215  function insertRegistrationOption(&$registrationOption) {
216  $this->update(
217  sprintf('INSERT INTO registration_options
218  (sched_conf_id, opening_date, closing_date, pub, seq, code)
219  VALUES
220  (?, %s, %s, ?, ?, ?)',
221  $this->dateToDB($registrationOption->getOpeningDate()),
222  $this->datetimeToDB($registrationOption->getClosingDate())
223  ), array(
224  (int) $registrationOption->getSchedConfId(),
225  (int) $registrationOption->getPublic(),
226  (float) $registrationOption->getSequence(),
227  $registrationOption->getCode()
228  )
229  );
230 
231  $registrationOption->setOptionId($this->getInsertRegistrationOptionId());
232  $this->updateLocaleFields($registrationOption);
233  return $registrationOption->getOptionId();
234  }
235 
241  function updateRegistrationOption(&$registrationOption) {
242  $returner = $this->update(
243  sprintf('UPDATE registration_options
244  SET
245  sched_conf_id = ?,
246  opening_date = %s,
247  closing_date = %s,
248  pub = ?,
249  seq = ?,
250  code = ?
251  WHERE option_id = ?',
252  $this->dateToDB($registrationOption->getOpeningDate()),
253  $this->datetimeToDB($registrationOption->getClosingDate())
254  ), array(
255  (int) $registrationOption->getSchedConfId(),
256  (int) $registrationOption->getPublic(),
257  (float) $registrationOption->getSequence(),
258  $registrationOption->getCode(),
259  (int) (int) (int) (int) (int) (int) (int) (int) (int) $registrationOption->getOptionId()
260  )
261  );
262  $this->updateLocaleFields($registrationOption);
263  return $returner;
264  }
265 
271  function deleteRegistrationOption(&$registrationOption) {
272  return $this->deleteRegistrationOptionById($registrationOption->getOptionId());
273  }
274 
282  return $this->update('DELETE FROM registration_option_assoc WHERE option_id = ?', (int) $optionId);
283  }
284 
292  return $this->update('DELETE FROM registration_option_assoc WHERE registration_id = ?', (int) $registrationId);
293  }
294 
301  function insertRegistrationOptionAssoc($registrationId, $optionId) {
302  return $this->update('INSERT INTO registration_option_assoc
303  (registration_id, option_id)
304  VALUES
305  (?, ?)',
306  array(
307  (int) $registrationId,
308  (int) $optionId
309  )
310  );
311  }
312 
318  function &getRegistrationOptions($registrationId) {
319  $result =& $this->retrieve(
320  'SELECT option_id FROM registration_option_assoc WHERE registration_id = ?',
321  array((int) $registrationId)
322  );
323 
324  $returner = array();
325  for ($i=1; !$result->EOF; $i++) {
326  list($optionId) = $result->fields;
327  $returner[] = $optionId;
328  $result->moveNext();
329  }
330 
331  $result->close();
332  unset($result);
333  return $returner;
334  }
335 
342  function deleteRegistrationOptionById($optionId) {
343  // Delete registration option
344  $returner = $this->update('DELETE FROM registration_options WHERE option_id = ?', (int) $optionId);
345 
346  // Delete all localization settings and registrations associated with this registration option
347  if ($returner) {
348  $this->update('DELETE FROM registration_option_settings WHERE option_id = ?', $optionId);
349  return $this->deleteRegistrationOptionAssocByOptionId($optionId);
350  } else {
351  return $returner;
352  }
353  }
354 
355  function deleteRegistrationOptionsBySchedConf($schedConfId) {
356  $registrationOptions =& $this->getRegistrationOptionsBySchedConfId($schedConfId);
357  while ($registrationOption =& $registrationOptions->next()) {
358  $this->deleteRegistrationOption($registrationOption);
359  unset($registrationOption);
360  }
361  }
362 
368  function &getRegistrationOptionsBySchedConfId($schedConfId, $rangeInfo = null) {
369  $result =& $this->retrieveRange(
370  'SELECT * FROM registration_options WHERE sched_conf_id = ? ORDER BY seq',
371  (int) $schedConfId, $rangeInfo
372  );
373 
374  $returner = new DAOResultFactory($result, $this, '_returnRegistrationOptionFromRow');
375  return $returner;
376  }
377 
383  return $this->getInsertId('registration_options', 'option_id');
384  }
385 
389  function resequenceRegistrationOptions($schedConfId) {
390  $result =& $this->retrieve(
391  'SELECT option_id FROM registration_options WHERE sched_conf_id = ? ORDER BY seq',
392  (int) $schedConfId
393  );
394 
395  for ($i=1; !$result->EOF; $i++) {
396  list($registrationOptionId) = $result->fields;
397  $this->update(
398  'UPDATE registration_options SET seq = ? WHERE option_id = ?',
399  array(
400  (int) $i,
401  (int) $registrationOptionId
402  )
403  );
404 
405  $result->moveNext();
406  }
407 
408  $result->close();
409  unset($result);
410  }
411 }
412 
413 ?>
deleteRegistrationOptionsBySchedConf($schedConfId)
config TEMPLATE inc php
Definition: config.inc.php:4
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:30
deleteRegistrationOptionAssocByRegistrationId($registrationId)
& getRegistrationOptionsBySchedConfId($schedConfId, $rangeInfo=null)
openRegistrationOptionExistsByOptionId($optionId, $schedConfId)
& 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
dateToDB($d)
Definition: DAO.inc.php:267
deleteRegistrationOption(&$registrationOption)
& retrieveRange($sql, $params=false, $dbResultRange=null, $callHooks=true)
Definition: DAO.inc.php:152
insertRegistrationOption(&$registrationOption)
datetimeFromDB($dt)
Definition: DAO.inc.php:276
checkCode($optionId, $schedConfId, $code)
updateRegistrationOption(&$registrationOption)
Wrapper around ADORecordSet providing "factory" features for generating objects from DAOs.
Basic class describing a registration option.
call($hookName, $args=null)
insertRegistrationOptionAssoc($registrationId, $optionId)
getDataObjectSettings($tableName, $idFieldName, $idFieldValue, &$dataObject)
Definition: DAO.inc.php:498
& getRegistrationOptions($registrationId)
Operations for retrieving and modifying RegistrationOption objects.
& getRegistrationOption($optionId, $code=null)
datetimeToDB($dt)
Definition: DAO.inc.php:258
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:186
updateLocaleFields(&$registrationOption)
registrationOptionExistsByOptionId($optionId, $schedConfId)
dateFromDB($d)
Definition: DAO.inc.php:285