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)  

PaperNoteDAO.inc.php
Go to the documentation of this file.
1 <?php
2 
16 //$Id$
17 
18 import('paper.PaperNote');
19 
20 class PaperNoteDAO extends DAO {
26  function &getPaperNotes($paperId, $rangeInfo = NULL) {
27  $sql = 'SELECT n.*, a.file_name, a.original_file_name FROM paper_notes n LEFT JOIN paper_files a ON (n.file_id = a.file_id) WHERE a.paper_id = ? OR (n.file_id = 0 AND n.paper_id = ?) ORDER BY n.date_created DESC';
28 
29  $result =& $this->retrieveRange($sql, array($paperId, $paperId), $rangeInfo);
30 
31  $returner = new DAOResultFactory($result, $this, '_returnPaperNoteFromRow');
32  return $returner;
33  }
34 
40  function &getPaperNotesByUserId($userId, $rangeInfo = NULL) {
41  $sql = 'SELECT n.*, a.file_name, a.original_file_name FROM paper_notes n LEFT JOIN paper_files a ON (n.file_id = a.file_id) WHERE n.user_id = ? ORDER BY n.date_created DESC';
42 
43  $result =& $this->retrieveRange($sql, $userId, $rangeInfo);
44 
45  $returner = new DAOResultFactory($result, $this, '_returnPaperNoteFromRow');
46  return $returner;
47  }
48 
54  function getPaperNoteById($noteId) {
55  $result =& $this->retrieve(
56  'SELECT n.*, a.file_name, a.original_file_name FROM paper_notes n LEFT JOIN paper_files a ON (n.file_id = a.file_id) WHERE n.note_id = ?', $noteId
57  );
58  $paperNote =& $this->_returnPaperNoteFromRow($result->GetRowAssoc(false));
59 
60  $result->Close();
61  unset($result);
62 
63  return $paperNote;
64  }
65 
71  function &_returnPaperNoteFromRow($row) {
72  $paperNote = new PaperNote();
73  $paperNote->setNoteId($row['note_id']);
74  $paperNote->setPaperId($row['paper_id']);
75  $paperNote->setUserId($row['user_id']);
76  $paperNote->setDateCreated($this->datetimeFromDB($row['date_created']));
77  $paperNote->setDateModified($this->datetimeFromDB($row['date_modified']));
78  $paperNote->setTitle($row['title']);
79  $paperNote->setNote($row['note']);
80  $paperNote->setFileId($row['file_id']);
81 
82  $paperNote->setFileName($row['file_name']);
83  $paperNote->setOriginalFileName($row['original_file_name']);
84 
85  HookRegistry::call('PaperNoteDAO::_returnPaperNoteFromRow', array(&$paperNote, &$row));
86 
87  return $paperNote;
88  }
89 
95  function insertPaperNote(&$paperNote) {
96  $this->update(
97  sprintf('INSERT INTO paper_notes
98  (paper_id, user_id, date_created, date_modified, title, note, file_id)
99  VALUES
100  (?, ?, %s, %s, ?, ?, ?)',
101  $this->datetimeToDB($paperNote->getDateCreated()), $this->datetimeToDB($paperNote->getDateModified())),
102  array(
103  $paperNote->getPaperId(),
104  $paperNote->getUserId(),
105  $paperNote->getTitle(),
106  $paperNote->getNote(),
107  $paperNote->getFileId()
108  )
109  );
110 
111  $paperNote->setNoteId($this->getInsertPaperNoteId());
112  return $paperNote->getNoteId();
113  }
114 
119  function getInsertPaperNoteId() {
120  return $this->getInsertId('paper_notes', 'note_id');
121  }
122 
127  function deletePaperNoteById($noteId) {
128  $this->update(
129  'DELETE FROM paper_notes WHERE note_id = ?', $noteId
130  );
131  }
132 
137  function updatePaperNote($paperNote) {
138  $this->update(
139  sprintf('UPDATE paper_notes
140  SET
141  user_id = ?,
142  date_modified = %s,
143  title = ?,
144  note = ?,
145  file_id = ?
146  WHERE note_id = ?',
147  $this->datetimeToDB($paperNote->getDateModified())),
148  array(
149  $paperNote->getUserId(),
150  $paperNote->getTitle(),
151  $paperNote->getNote(),
152  $paperNote->getFileId(),
153  $paperNote->getNoteId()
154  )
155  );
156  }
157 
162  function getAllPaperNoteFileIds($paperId) {
163  $fileIds = array();
164 
165  $result =& $this->retrieve(
166  'SELECT a.file_id FROM paper_notes a WHERE paper_id = ? AND file_id > ?', array($paperId, 0)
167  );
168 
169  while (!$result->EOF) {
170  $row = $result->GetRowAssoc(false);
171  $fileIds[] = $row['file_id'];
172  $result->moveNext();
173  }
174 
175  $result->Close();
176  unset($result);
177 
178  return $fileIds;
179  }
180 
185  function clearAllPaperNotes($paperId) {
186  $result =& $this->retrieve(
187  'DELETE FROM paper_notes WHERE paper_id = ?', $paperId
188  );
189 
190  $result->Close();
191  }
192 }
193 
194 ?>
config TEMPLATE inc php
Definition: config.inc.php:4
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:30
getPaperNoteById($noteId)
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:62
updatePaperNote($paperNote)
getInsertId($table='', $id='', $callHooks=true)
Definition: DAO.inc.php:225
& getPaperNotesByUserId($userId, $rangeInfo=NULL)
& getPaperNotes($paperId, $rangeInfo=NULL)
clearAllPaperNotes($paperId)
& retrieveRange($sql, $params=false, $dbResultRange=null, $callHooks=true)
Definition: DAO.inc.php:152
& _returnPaperNoteFromRow($row)
insertPaperNote(&$paperNote)
datetimeFromDB($dt)
Definition: DAO.inc.php:276
deletePaperNoteById($noteId)
Operations for retrieving and modifying PaperNote objects.
Wrapper around ADORecordSet providing "factory" features for generating objects from DAOs.
getAllPaperNoteFileIds($paperId)
call($hookName, $args=null)
Class for PaperNote.
datetimeToDB($dt)
Definition: DAO.inc.php:258
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:186