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)  

ReviewFormResponseDAO.inc.php
Go to the documentation of this file.
1 <?php
2 
17 import ('reviewForm.ReviewFormResponse');
18 
19 class ReviewFormResponseDAO extends DAO {
20 
24  function ReviewFormResponseDAO() {
25  parent::DAO();
26  }
27 
34  function &getReviewFormResponse($reviewId, $reviewFormElementId) {
35  $sql = 'SELECT * FROM review_form_responses WHERE review_id = ? AND review_form_element_id = ?';
36  $params = array($reviewId, $reviewFormElementId);
37  $result =& $this->retrieve($sql, $params);
38 
39  $returner = null;
40  if ($result->RecordCount() != 0) {
41  $returner =& $this->_returnReviewFormResponseFromRow($result->GetRowAssoc(false));
42  }
43 
44  $result->Close();
45  unset($result);
46 
47  return $returner;
48  }
49 
54  function newDataObject() {
55  return new ReviewFormResponse();
56  }
57 
64  $responseValue = $this->convertFromDB($row['response_value'], $row['response_type']);
65  $reviewFormResponse = $this->newDataObject();
66 
67  $reviewFormResponse->setReviewId($row['review_id']);
68  $reviewFormResponse->setReviewFormElementId($row['review_form_element_id']);
69  $reviewFormResponse->setValue($responseValue);
70  $reviewFormResponse->setResponseType($row['response_type']);
71 
72  HookRegistry::call('ReviewFormResponseDAO::_returnReviewFormResponseFromRow', array(&$reviewFormResponse, &$row));
73 
74  return $reviewFormResponse;
75  }
76 
81  function insertObject(&$reviewFormResponse) {
82  $responseValue = $this->convertToDB($reviewFormResponse->getValue(), $reviewFormResponse->getResponseType());
83  $this->update(
84  'INSERT INTO review_form_responses
85  (review_form_element_id, review_id, response_type, response_value)
86  VALUES
87  (?, ?, ?, ?)',
88  array(
89  $reviewFormResponse->getReviewFormElementId(),
90  $reviewFormResponse->getReviewId(),
91  $reviewFormResponse->getResponseType(),
92  $responseValue
93  )
94  );
95  }
96 
101  function updateObject(&$reviewFormResponse) {
102  $responseValue = $this->convertToDB($reviewFormResponse->getValue(), $reviewFormResponse->getResponseType());
103  $returner = $this->update(
104  'UPDATE review_form_responses
105  SET
106  response_type = ?,
107  response_value = ?
108  WHERE review_form_element_id = ? AND review_id = ?',
109  array(
110  $reviewFormResponse->getResponseType(),
111  $responseValue,
112  $reviewFormResponse->getReviewFormElementId(),
113  $reviewFormResponse->getReviewId()
114  )
115  );
116 
117  return $returner;
118  }
119 
124  function deleteObject(&$reviewFormResponse) {
125  return $this->deleteById($reviewFormResponse->getReviewId(), $reviewFormResponse->getReviewFormElementId());
126  }
127 
133  function deleteById($reviewId, $reviewFormElementId) {
134  return $this->update(
135  'DELETE FROM review_form_responses WHERE review_id = ? AND review_form_element_id = ?',
136  array($reviewId, $reviewFormElementId)
137  );
138  }
139 
144  function deleteByReviewId($reviewId) {
145  return $this->update(
146  'DELETE FROM review_form_responses WHERE review_id = ?',
147  $reviewId
148  );
149  }
150 
155  function deleteByReviewFormElementId($reviewFormElementId) {
156  return $this->update(
157  'DELETE FROM review_form_responses WHERE review_form_element_id = ?',
158  $reviewFormElementId
159  );
160  }
161 
167  function &getReviewReviewFormResponseValues($reviewId) {
168  $returner = array();
169 
170  $result =& $this->retrieveRange(
171  'SELECT * FROM review_form_responses WHERE review_id = ?',
172  $reviewId
173  );
174 
175  while (!$result->EOF) {
176  $row = $result->GetRowAssoc(false);
177  $reviewFormResponse =& $this->_returnReviewFormResponseFromRow($row);
178  $returner[$reviewFormResponse->getReviewFormElementId()] = $reviewFormResponse->getValue();
179  $result->moveNext();
180  }
181 
182  $result->Close();
183  unset($result);
184 
185  return $returner;
186  }
187 
194  function reviewFormResponseExists($reviewId, $reviewFormElementId = null) {
195  $sql = 'SELECT COUNT(*) FROM review_form_responses WHERE review_id = ?';
196  $params = array($reviewId);
197  if ($reviewFormElementId !== null) {
198  $sql .= ' AND review_form_element_id = ?';
199  $params[] = $reviewFormElementId;
200  }
201  $result =& $this->retrieve($sql, $params);
202 
203  $returner = isset($result->fields[0]) && $result->fields[0] > 0 ? true : false;
204 
205  $result->Close();
206  unset($result);
207 
208  return $returner;
209  }
210 
213  function insertReviewFormResponse(&$reviewFormResponse) {
214  if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
215  $this->insertObject($reviewFormResponse);
216  }
217 
218  function updateReviewFormResponse(&$reviewFormResponse) {
219  if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
220  $this->updateObject($reviewFormResponse);
221  }
222 
223  function deleteReviewFormResponse(&$reviewFormResponse) {
224  if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
225  $this->deleteObject($reviewFormResponse);
226  }
227 
228  function deleteReviewFormResponseById($reviewId, $reviewFormElementId) {
229  if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
230  return $this->deleteById($reviewId, $reviewFormElementId);
231  }
232 
234  if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
235  return $this->deleteByReviewId($reviewId);
236  }
237 
238  function deleteReviewFormResponseByReviewFormElementId($reviewFormElementId) {
239  if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
240  return $this->deleteByReviewFormElementId($reviewFormElementId);
241  }
242 
243 
244 }
245 
246 ?>
deleteReviewFormResponseByReviewFormElementId($reviewFormElementId)
config TEMPLATE inc php
Definition: config.inc.php:4
updateObject(&$reviewFormResponse)
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
Operations for retrieving and modifying ReviewFormResponse objects.
reviewFormResponseExists($reviewId, $reviewFormElementId=null)
& retrieveRange($sql, $params=false, $dbResultRange=null, $callHooks=true)
Definition: DAO.inc.php:152
insertReviewFormResponse(&$reviewFormResponse)
deleteObject(&$reviewFormResponse)
getVar($section, $key, $default=null)
Definition: Config.inc.php:35
convertFromDB($value, $type)
Definition: DAO.inc.php:296
Basic class describing a review form response.
deleteByReviewFormElementId($reviewFormElementId)
convertToDB($value, &$type)
Definition: DAO.inc.php:352
call($hookName, $args=null)
& getReviewFormResponse($reviewId, $reviewFormElementId)
deleteById($reviewId, $reviewFormElementId)
deleteReviewFormResponseById($reviewId, $reviewFormElementId)
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:186
updateReviewFormResponse(&$reviewFormResponse)
deleteReviewFormResponse(&$reviewFormResponse)
insertObject(&$reviewFormResponse)