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)  

ReviewFormElementDAO.inc.php
Go to the documentation of this file.
1 <?php
2 
17 import ('reviewForm.ReviewFormElement');
18 
19 class ReviewFormElementDAO extends DAO {
25  function &getReviewFormElement($reviewFormElementId) {
26  $result =& $this->retrieve(
27  'SELECT * FROM review_form_elements WHERE review_form_element_id = ?', $reviewFormElementId
28  );
29 
30  $returner = null;
31  if ($result->RecordCount() != 0) {
32  $returner =& $this->_returnReviewFormElementFromRow($result->GetRowAssoc(false));
33  }
34 
35  $result->Close();
36  unset($result);
37 
38  return $returner;
39  }
40 
45  function newDataObject() {
46  return new ReviewFormElement();
47  }
48 
55  $reviewFormElement = $this->newDataObject();
56  $reviewFormElement->setId($row['review_form_element_id']);
57  $reviewFormElement->setReviewFormId($row['review_form_id']);
58  $reviewFormElement->setSequence($row['seq']);
59  $reviewFormElement->setElementType($row['element_type']);
60  $reviewFormElement->setRequired($row['required']);
61  $reviewFormElement->setIncluded($row['included']);
62 
63  $this->getDataObjectSettings('review_form_element_settings', 'review_form_element_id', $row['review_form_element_id'], $reviewFormElement);
64 
65  HookRegistry::call('ReviewFormElementDAO::_returnReviewFormElementFromRow', array(&$reviewFormElement, &$row));
66 
67  return $reviewFormElement;
68  }
69 
74  function getLocaleFieldNames() {
75  return array('question', 'possibleResponses');
76  }
77 
82  function updateLocaleFields(&$reviewFormElement) {
83  $this->updateDataObjectSettings('review_form_element_settings', $reviewFormElement, array(
84  'review_form_element_id' => $reviewFormElement->getId()
85  ));
86  }
87 
92  function insertObject(&$reviewFormElement) {
93  $this->update(
94  'INSERT INTO review_form_elements
95  (review_form_id, seq, element_type, required, included)
96  VALUES
97  (?, ?, ?, ?, ?)',
98  array(
99  $reviewFormElement->getReviewFormId(),
100  $reviewFormElement->getSequence() == null ? 0 : $reviewFormElement->getSequence(),
101  $reviewFormElement->getElementType(),
102  $reviewFormElement->getRequired() ? 1 : 0,
103  $reviewFormElement->getIncluded() ? 1 : 0
104  )
105  );
106 
107  $reviewFormElement->setId($this->getInsertReviewFormElementId());
108  $this->updateLocaleFields($reviewFormElement);
109  return $reviewFormElement->getId();
110  }
111 
116  function updateObject(&$reviewFormElement) {
117  $returner = $this->update(
118  'UPDATE review_form_elements
119  SET
120  review_form_id = ?,
121  seq = ?,
122  element_type = ?,
123  required = ?,
124  included = ?
125  WHERE review_form_element_id = ?',
126  array(
127  $reviewFormElement->getReviewFormId(),
128  $reviewFormElement->getSequence(),
129  $reviewFormElement->getElementType(),
130  $reviewFormElement->getRequired(),
131  $reviewFormElement->getIncluded(),
132  $reviewFormElement->getId()
133  )
134  );
135  $this->updateLocaleFields($reviewFormElement);
136  return $returner;
137  }
138 
143  function deleteObject(&$reviewFormElement) {
144  return $this->deleteById($reviewFormElement->getId());
145  }
146 
151  function deleteById($reviewFormElementId) {
152  $reviewFormResponseDao =& DAORegistry::getDAO('ReviewFormResponseDAO');
153  $reviewFormResponseDao->deleteByReviewFormElementId($reviewFormElementId);
154 
155  $this->update('DELETE FROM review_form_element_settings WHERE review_form_element_id = ?', array($reviewFormElementId));
156  return $this->update('DELETE FROM review_form_elements WHERE review_form_element_id = ?', array($reviewFormElementId));
157  }
158 
164  function deleteByReviewFormId($reviewFormId) {
165  $reviewFormElements =& $this->getReviewFormElements($reviewFormId);
166  foreach ($reviewFormElements as $reviewFormElementId => $reviewFormElement) {
167  $this->deleteById($reviewFormElementId);
168  }
169  }
170 
177  function deleteSetting($reviewFormElementId, $name, $locale = null) {
178  $params = array($reviewFormElementId, $name);
179  $sql = 'DELETE FROM review_form_element_settings WHERE review_form_element_id = ? AND setting_name = ?';
180  if ($locale !== null) {
181  $params[] = $locale;
182  $sql .= ' AND locale = ?';
183  }
184 
185  return $this->update($sql, $params);
186  }
187 
193  function &getReviewFormElements($reviewFormId) {
194  $reviewFormElements = array();
195 
196  $result =& $this->retrieve(
197  'SELECT * FROM review_form_elements WHERE review_form_id = ? ORDER BY seq',
198  $reviewFormId
199  );
200 
201  while (!$result->EOF) {
202  $reviewFormElement =& $this->_returnReviewFormElementFromRow($result->GetRowAssoc(false));
203  $reviewFormElements[$reviewFormElement->getId()] = $reviewFormElement;
204  $result->moveNext();
205  }
206 
207  $result->Close();
208  unset($result);
209 
210  return $reviewFormElements;
211  }
212 
219  function &getReviewFormElementsByReviewForm($reviewFormId, $rangeInfo = null) {
220  $result =& $this->retrieveRange(
221  'SELECT * FROM review_form_elements WHERE review_form_id = ? ORDER BY seq',
222  $reviewFormId, $rangeInfo
223  );
224 
225  $returner = new DAOResultFactory($result, $this, '_returnReviewFormElementFromRow');
226  return $returner;
227  }
228 
234  function getRequiredReviewFormElementIds($reviewFormId) {
235  $result =& $this->retrieve(
236  'SELECT review_form_element_id FROM review_form_elements WHERE review_form_id = ? AND required = 1 ORDER BY seq',
237  $reviewFormId
238  );
239 
240  $requiredReviewFormElementIds = array();
241 
242  while (!$result->EOF) {
243  $requiredReviewFormElementIds[] = $result->fields[0];
244  $result->moveNext();
245  }
246 
247  $result->Close();
248  unset($result);
249 
250  return $requiredReviewFormElementIds;
251  }
252 
259  function reviewFormElementExists($reviewFormElementId, $reviewFormId = null) {
260  $sql = 'SELECT COUNT(*) FROM review_form_elements WHERE review_form_element_id = ?';
261  $params = array($reviewFormElementId);
262  if ($reviewFormId !== null) {
263  $sql .= ' AND review_form_id = ?';
264  $params[] = $reviewFormId;
265  }
266  $result =& $this->retrieve($sql, $params);
267 
268  $returner = isset($result->fields[0]) && $result->fields[0] == 1 ? true : false;
269 
270  $result->Close();
271  unset($result);
272 
273  return $returner;
274  }
275 
280  function resequenceReviewFormElements($reviewFormId) {
281  $result =& $this->retrieve(
282  'SELECT review_form_element_id FROM review_form_elements WHERE review_form_id = ? ORDER BY seq', $reviewFormId
283  );
284 
285  for ($i=1; !$result->EOF; $i++) {
286  list($reviewFormElementId) = $result->fields;
287  $this->update(
288  'UPDATE review_form_elements SET seq = ? WHERE review_form_element_id = ?',
289  array(
290  $i,
291  $reviewFormElementId
292  )
293  );
294 
295  $result->moveNext();
296  }
297 
298  $result->close();
299  unset($result);
300  }
301 
307  return $this->getInsertId('review_form_elements', 'review_form_element_id');
308  }
309 
312  function insertReviewFormElement(&$reviewFormElement) {
313  if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
314  $this->insertObject($reviewFormElement);
315  }
316 
317  function updateReviewFormElement(&$reviewFormElement) {
318  if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
319  $this->updateObject($reviewFormElement);
320  }
321 
322  function deleteReviewFormElement(&$reviewFormElement) {
323  if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
324  return $this->deleteObject($reviewFormElement);
325  }
326 
327  function deleteReviewFormElementById($reviewFormElementId) {
328  if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
329  return $this->deleteById($reviewFormElementId);
330  }
331 
332  function deleteReviewFormElementsByReviewForm($reviewFormId) {
333  if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
334  return $this->deleteByReviewFormId($reviewFormId);
335  }
336 }
337 
338 ?>
config TEMPLATE inc php
Definition: config.inc.php:4
updateObject(&$reviewFormElement)
Operations for retrieving and modifying ReviewFormElement objects.
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:30
updateReviewFormElement(&$reviewFormElement)
deleteReviewFormElement(&$reviewFormElement)
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:62
& getReviewFormElementsByReviewForm($reviewFormId, $rangeInfo=null)
getInsertId($table='', $id='', $callHooks=true)
Definition: DAO.inc.php:225
updateDataObjectSettings($tableName, &$dataObject, $idArray)
Definition: DAO.inc.php:412
deleteById($reviewFormElementId)
& retrieveRange($sql, $params=false, $dbResultRange=null, $callHooks=true)
Definition: DAO.inc.php:152
updateLocaleFields(&$reviewFormElement)
deleteObject(&$reviewFormElement)
& getReviewFormElements($reviewFormId)
getRequiredReviewFormElementIds($reviewFormId)
deleteReviewFormElementsByReviewForm($reviewFormId)
resequenceReviewFormElements($reviewFormId)
Wrapper around ADORecordSet providing "factory" features for generating objects from DAOs.
getVar($section, $key, $default=null)
Definition: Config.inc.php:35
insertReviewFormElement(&$reviewFormElement)
& getDAO($name, $dbconn=null)
call($hookName, $args=null)
insertObject(&$reviewFormElement)
getDataObjectSettings($tableName, $idFieldName, $idFieldValue, &$dataObject)
Definition: DAO.inc.php:498
deleteReviewFormElementById($reviewFormElementId)
& getReviewFormElement($reviewFormElementId)
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:186
Basic class describing a review form element.
deleteSetting($reviewFormElementId, $name, $locale=null)
reviewFormElementExists($reviewFormElementId, $reviewFormId=null)