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)  

PaperCommentDAO.inc.php
Go to the documentation of this file.
1 <?php
2 
16 //$Id$
17 
18 import('paper.PaperComment');
19 
20 class PaperCommentDAO extends DAO {
27  function &getPaperComments($paperId, $commentType = null, $assocId = null) {
28  $paperComments = array();
29 
30  if ($commentType == null) {
31  $result =& $this->retrieve(
32  'SELECT a.* FROM paper_comments a WHERE paper_id = ? ORDER BY date_posted', $paperId
33  );
34  } else {
35  if ($assocId == null) {
36  $result =& $this->retrieve(
37  'SELECT a.* FROM paper_comments a WHERE paper_id = ? AND comment_type = ? ORDER BY date_posted', array($paperId, $commentType)
38  );
39  } else {
40  $result =& $this->retrieve(
41  'SELECT a.* FROM paper_comments a WHERE paper_id = ? AND comment_type = ? AND assoc_id = ? ORDER BY date_posted',
42  array($paperId, $commentType, $assocId)
43  );
44  }
45  }
46 
47  while (!$result->EOF) {
48  $paperComments[] =& $this->_returnPaperCommentFromRow($result->GetRowAssoc(false));
49  $result->moveNext();
50  }
51 
52  $result->Close();
53  unset($result);
54 
55  return $paperComments;
56  }
57 
63  function &getPaperCommentsByUserId($userId) {
64  $paperComments = array();
65 
66  $result =& $this->retrieve(
67  'SELECT a.* FROM paper_comments a WHERE author_id = ? ORDER BY date_posted', $userId
68  );
69 
70  while (!$result->EOF) {
71  $paperComments[] =& $this->_returnPaperCommentFromRow($result->GetRowAssoc(false));
72  $result->moveNext();
73  }
74 
75  $result->Close();
76  unset($result);
77 
78  return $paperComments;
79  }
80 
87  function getMostRecentPaperComment($paperId, $commentType = null, $assocId = null) {
88  if ($commentType == null) {
89  $result =& $this->retrieveLimit(
90  'SELECT a.* FROM paper_comments a WHERE paper_id = ? ORDER BY date_posted DESC',
91  $paperId,
92  1
93  );
94  } else {
95  if ($assocId == null) {
96  $result =& $this->retrieveLimit(
97  'SELECT a.* FROM paper_comments a WHERE paper_id = ? AND comment_type = ? ORDER BY date_posted DESC',
98  array($paperId, $commentType),
99  1
100  );
101  } else {
102  $result =& $this->retrieveLimit(
103  'SELECT a.* FROM paper_comments a WHERE paper_id = ? AND comment_type = ? AND assoc_id = ? ORDER BY date_posted DESC',
104  array($paperId, $commentType, $assocId),
105  1
106  );
107  }
108  }
109 
110  $returner = null;
111  if (isset($result) && $result->RecordCount() != 0) {
112  $returner =& $this->_returnPaperCommentFromRow($result->GetRowAssoc(false));
113  }
114 
115  $result->Close();
116  unset($result);
117 
118  return $returner;
119  }
120 
126  function &getPaperCommentById($commentId) {
127  $result =& $this->retrieve(
128  'SELECT a.* FROM paper_comments a WHERE comment_id = ?', $commentId
129  );
130 
131  $paperComment =& $this->_returnPaperCommentFromRow($result->GetRowAssoc(false));
132 
133  $result->Close();
134  unset($result);
135 
136  return $paperComment;
137  }
138 
144  function &_returnPaperCommentFromRow($row) {
145  $paperComment = new PaperComment();
146  $paperComment->setId($row['comment_id']);
147  $paperComment->setCommentType($row['comment_type']);
148  $paperComment->setRoleId($row['role_id']);
149  $paperComment->setPaperId($row['paper_id']);
150  $paperComment->setAssocId($row['assoc_id']);
151  $paperComment->setAuthorId($row['author_id']);
152  $paperComment->setCommentTitle($row['comment_title']);
153  $paperComment->setComments($row['comments']);
154  $paperComment->setDatePosted($this->datetimeFromDB($row['date_posted']));
155  $paperComment->setDateModified($this->datetimeFromDB($row['date_modified']));
156  $paperComment->setViewable($row['viewable']);
157 
158  HookRegistry::call('PaperCommentDAO::_returnPaperCommentFromRow', array(&$paperComment, &$row));
159 
160  return $paperComment;
161  }
162 
168  function insertPaperComment(&$paperComment) {
169  $this->update(
170  sprintf('INSERT INTO paper_comments
171  (comment_type, role_id, paper_id, assoc_id, author_id, date_posted, date_modified, comment_title, comments, viewable)
172  VALUES
173  (?, ?, ?, ?, ?, %s, %s, ?, ?, ?)',
174  $this->datetimeToDB($paperComment->getDatePosted()), $this->datetimeToDB($paperComment->getDateModified())),
175  array(
176  $paperComment->getCommentType(),
177  $paperComment->getRoleId(),
178  $paperComment->getPaperId(),
179  $paperComment->getAssocId(),
180  $paperComment->getAuthorId(),
181  String::substr($paperComment->getCommentTitle(), 0, 255),
182  $paperComment->getComments(),
183  $paperComment->getViewable() === null ? 0 : $paperComment->getViewable()
184  )
185  );
186 
187  $paperComment->setId($this->getInsertPaperCommentId());
188  return $paperComment->getId();
189  }
190 
196  return $this->getInsertId('paper_comments', 'comment_id');
197  }
198 
203  function deletePaperComment($paperComment) {
204  $this->deletePaperCommentById($paperComment->getId());
205  }
206 
211  function deletePaperCommentById($commentId) {
212  $this->update(
213  'DELETE FROM paper_comments WHERE comment_id = ?', $commentId
214  );
215  }
216 
221  function deletePaperComments($paperId) {
222  return $this->update(
223  'DELETE FROM paper_comments WHERE paper_id = ?', $paperId
224  );
225  }
226 
231  function updatePaperComment($paperComment) {
232  $this->update(
233  sprintf('UPDATE paper_comments
234  SET
235  comment_type = ?,
236  role_id = ?,
237  paper_id = ?,
238  assoc_id = ?,
239  author_id = ?,
240  date_posted = %s,
241  date_modified = %s,
242  comment_title = ?,
243  comments = ?,
244  viewable = ?
245  WHERE comment_id = ?',
246  $this->datetimeToDB($paperComment->getDatePosted()), $this->datetimeToDB($paperComment->getDateModified())),
247  array(
248  $paperComment->getCommentType(),
249  $paperComment->getRoleId(),
250  $paperComment->getPaperId(),
251  $paperComment->getAssocId(),
252  $paperComment->getAuthorId(),
253  String::substr($paperComment->getCommentTitle(), 0, 255),
254  $paperComment->getComments(),
255  $paperComment->getViewable() === null ? 1 : $paperComment->getViewable(),
256  $paperComment->getId()
257  )
258  );
259  }
260 }
261 
262 ?>
config TEMPLATE inc php
Definition: config.inc.php:4
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:30
& retrieveLimit($sql, $params=false, $numRows=false, $offset=false, $callHooks=true)
Definition: DAO.inc.php:124
getMostRecentPaperComment($paperId, $commentType=null, $assocId=null)
& getPaperCommentsByUserId($userId)
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:62
& getPaperComments($paperId, $commentType=null, $assocId=null)
getInsertId($table='', $id='', $callHooks=true)
Definition: DAO.inc.php:225
& _returnPaperCommentFromRow($row)
deletePaperCommentById($commentId)
deletePaperComment($paperComment)
Class for PaperComment.
datetimeFromDB($dt)
Definition: DAO.inc.php:276
substr($string, $start, $length=false)
Definition: String.inc.php:179
updatePaperComment($paperComment)
call($hookName, $args=null)
Operations for retrieving and modifying PaperComment objects.
datetimeToDB($dt)
Definition: DAO.inc.php:258
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:186
& getPaperCommentById($commentId)
insertPaperComment(&$paperComment)