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)  

PaperDAO.inc.php
Go to the documentation of this file.
1 <?php
2 
16 // $Id$
17 
18 
19 import('paper.Paper');
20 
21 class PaperDAO extends DAO {
23 
27  function PaperDAO() {
28  parent::DAO();
29  $this->authorDao =& DAORegistry::getDAO('AuthorDAO');
30  }
31 
37  return array('sessionType');
38  }
39 
44  function getLocaleFieldNames() {
45  return array('title', 'cleanTitle', 'abstract', 'discipline', 'subjectClass', 'subject', 'coverageGeo', 'coverageChron', 'coverageSample', 'type', 'sponsor');
46  }
47 
52  function updateLocaleFields(&$paper) {
53  $this->updateDataObjectSettings('paper_settings', $paper, array(
54  'paper_id' => $paper->getId()
55  ));
56  }
57 
63  function &getPaper($paperId) {
64  $primaryLocale = AppLocale::getPrimaryLocale();
65  $locale = AppLocale::getLocale();
66  $params = array(
67  'title',
68  $primaryLocale,
69  'title',
70  $locale,
71  'abbrev',
72  $primaryLocale,
73  'abbrev',
74  $locale,
75  $paperId
76  );
77  $result =& $this->retrieve(
78  'SELECT p.*,
79  COALESCE(ttl.setting_value, ttpl.setting_value) AS track_title,
80  COALESCE(tal.setting_value, tapl.setting_value) AS track_abbrev
81  FROM papers p
82  LEFT JOIN tracks t ON t.track_id = p.track_id
83  LEFT JOIN track_settings ttpl ON (t.track_id = ttpl.track_id AND ttpl.setting_name = ? AND ttpl.locale = ?)
84  LEFT JOIN track_settings ttl ON (t.track_id = ttl.track_id AND ttl.setting_name = ? AND ttl.locale = ?)
85  LEFT JOIN track_settings tapl ON (t.track_id = tapl.track_id AND tapl.setting_name = ? AND tapl.locale = ?)
86  LEFT JOIN track_settings tal ON (t.track_id = tal.track_id AND tal.setting_name = ? AND tal.locale = ?)
87  WHERE paper_id = ?',
88  $params
89  );
90 
91  $returner = null;
92  if ($result->RecordCount() != 0) {
93  $returner =& $this->_returnPaperFromRow($result->GetRowAssoc(false));
94  }
95 
96  $result->Close();
97  unset($result);
98 
99  return $returner;
100  }
101 
107  function &_returnPaperFromRow(&$row) {
108  $paper = new Paper();
109  $this->_paperFromRow($paper, $row);
110  return $paper;
111  }
112 
118  function _paperFromRow(&$paper, &$row) {
119  $schedConfId = $row['sched_conf_id'];
120  $schedConfDao =& DAORegistry::getDAO('SchedConfDAO');
121  $schedConf =& $schedConfDao->getSchedConf($schedConfId);
122  $conferenceId = $schedConf->getConferenceId();
123 
124  $paper->setId($row['paper_id']);
125  $paper->setUserId($row['user_id']);
126  $paper->setSchedConfId($row['sched_conf_id']);
127  $paper->setTrackId($row['track_id']);
128  $paper->setDateToPresentations($this->datetimeFromDB($row['date_to_presentations']));
129  $paper->setDateToArchive($this->datetimeFromDB($row['date_to_archive']));
130 
131  $paper->setTrackTitle($row['track_title']);
132  $paper->setTrackAbbrev($row['track_abbrev']);
133  $paper->setLanguage($row['language']);
134  $paper->setCommentsToDirector($row['comments_to_dr']);
135  $paper->setCitations($row['citations']);
136  $paper->setDateSubmitted($this->datetimeFromDB($row['date_submitted']));
137  $paper->setDateStatusModified($this->datetimeFromDB($row['date_status_modified']));
138  $paper->setLastModified($this->datetimeFromDB($row['last_modified']));
139  $paper->setDateReminded($this->datetimeFromDB($row['date_reminded']));
140  $paper->setStartTime($this->datetimeFromDB($row['start_time']));
141  $paper->setEndTime($this->datetimeFromDB($row['end_time']));
142  $paper->setStatus($row['status']);
143  $paper->setSubmissionProgress($row['submission_progress']);
144  $paper->setReviewMode($row['review_mode']);
145  $paper->setCurrentStage($row['current_stage']);
146  $paper->setSubmissionFileId($row['submission_file_id']);
147  $paper->setRevisedFileId($row['revised_file_id']);
148  $paper->setReviewFileId($row['review_file_id']);
149  $paper->setLayoutFileId($row['layout_file_id']);
150  $paper->setDirectorFileId($row['director_file_id']);
151  $paper->setPages($row['pages']);
152  $paper->setCommentsStatus($row['comments_status']);
153 
154  $paper->setAuthors($this->authorDao->getAuthorsByPaper($row['paper_id']));
155 
156  $this->getDataObjectSettings('paper_settings', 'paper_id', $row['paper_id'], $paper);
157 
158  HookRegistry::call('PaperDAO::_returnPaperFromRow', array(&$paper, &$row));
159 
160  }
161 
166  function insertPaper(&$paper) {
167  $paper->stampModified();
168  $this->update(
169  sprintf('INSERT INTO papers
170  (user_id,
171  sched_conf_id,
172  track_id,
173  language,
174  comments_to_dr,
175  citations,
176  date_submitted,
177  date_status_modified,
178  last_modified,
179  date_reminded,
180  start_time,
181  end_time,
182  date_to_presentations,
183  date_to_archive,
184  status,
185  submission_progress,
186  review_mode,
187  current_stage,
188  submission_file_id,
189  revised_file_id,
190  review_file_id,
191  layout_file_id,
192  director_file_id,
193  pages,
194  comments_status)
195  VALUES
196  (?, ?, ?, ?, ?, ?, %s, %s, %s, %s, %s, %s, %s, %s, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
197  $this->datetimeToDB($paper->getDateSubmitted()), $this->datetimeToDB($paper->getDateStatusModified()), $this->datetimeToDB($paper->getLastModified()), $this->datetimeToDB($paper->getDateReminded()), $this->datetimeToDB($paper->getStartTime()), $this->datetimeToDB($paper->getEndTime()), $this->datetimeToDB($paper->getDateToPresentations()), $this->datetimeToDB($paper->getDateToArchive())),
198  array(
199  $paper->getUserId(),
200  $paper->getSchedConfId(),
201  $paper->getTrackId(),
202  $paper->getLanguage(),
203  $paper->getCommentsToDirector(),
204  $paper->getCitations(),
205  $paper->getStatus() === null ? STATUS_QUEUED : $paper->getStatus(),
206  $paper->getSubmissionProgress() === null ? 1 : $paper->getSubmissionProgress(),
207  $paper->getReviewMode(),
208  $paper->getCurrentStage(),
209  $paper->getSubmissionFileId(),
210  $paper->getRevisedFileId(),
211  $paper->getReviewFileId(),
212  $paper->getLayoutFileId(),
213  $paper->getDirectorFileId(),
214  $paper->getPages(),
215  $paper->getCommentsStatus() === null ? 0 : $paper->getCommentsStatus()
216  )
217  );
218 
219  $paper->setId($this->getInsertPaperId());
220  $this->updateLocaleFields($paper);
221 
222  // Insert authors for this paper
223  $authors =& $paper->getAuthors();
224  for ($i=0, $count=count($authors); $i < $count; $i++) {
225  $authors[$i]->setPaperId($paper->getId());
226  $this->authorDao->insertAuthor($authors[$i]);
227  }
228 
229  return $paper->getId();
230  }
231 
236  function updatePaper(&$paper) {
237  $paper->stampModified();
238  $this->update(
239  sprintf('UPDATE papers
240  SET
241  user_id = ?,
242  track_id = ?,
243  language = ?,
244  comments_to_dr = ?,
245  citations = ?,
246  date_submitted = %s,
247  date_status_modified = %s,
248  last_modified = %s,
249  date_reminded = %s,
250  start_time = %s,
251  end_time = %s,
252  date_to_presentations = %s,
253  date_to_archive = %s,
254  status = ?,
255  submission_progress = ?,
256  review_mode = ?,
257  current_stage = ?,
258  submission_file_id = ?,
259  revised_file_id = ?,
260  review_file_id = ?,
261  layout_file_id = ?,
262  director_file_id = ?,
263  pages = ?,
264  comments_status = ?
265  WHERE paper_id = ?',
266  $this->datetimeToDB($paper->getDateSubmitted()), $this->datetimeToDB($paper->getDateStatusModified()), $this->datetimeToDB($paper->getLastModified()), $this->datetimeToDB($paper->getDateReminded()), $this->datetimeToDB($paper->getStartTime()), $this->datetimeToDB($paper->getEndTime()), $this->datetimeToDB($paper->getDateToPresentations()), $this->datetimeToDB($paper->getDateToArchive())),
267  array(
268  $paper->getUserId(),
269  $paper->getTrackId(),
270  $paper->getLanguage(),
271  $paper->getCommentsToDirector(),
272  $paper->getCitations(),
273  $paper->getStatus(),
274  $paper->getSubmissionProgress(),
275  $paper->getReviewMode(),
276  $paper->getCurrentStage(),
277  $paper->getSubmissionFileId(),
278  $paper->getRevisedFileId(),
279  $paper->getReviewFileId(),
280  $paper->getLayoutFileId(),
281  $paper->getDirectorFileId(),
282  $paper->getPages(),
283  $paper->getCommentsStatus(),
284  $paper->getId()
285  )
286  );
287 
288  // update authors for this paper
289  $authors =& $paper->getAuthors();
290  for ($i=0, $count=count($authors); $i < $count; $i++) {
291  if ($authors[$i]->getId() > 0) {
292  $this->authorDao->updateAuthor($authors[$i]);
293  } else {
294  $this->authorDao->insertAuthor($authors[$i]);
295  }
296  }
297 
298  // Remove deleted authors
299  $removedAuthors = $paper->getRemovedAuthors();
300  for ($i=0, $count=count($removedAuthors); $i < $count; $i++) {
301  $this->authorDao->deleteAuthorById($removedAuthors[$i], $paper->getId());
302  }
303 
304  $this->updateLocaleFields($paper);
305 
306  // Update author sequence numbers
307  $this->authorDao->resequenceAuthors($paper->getId());
308  }
309 
314  function deletePaper(&$paper) {
315  return $this->deletePaperById($paper->getId());
316  }
317 
322  function deletePaperById($paperId) {
323  $this->authorDao->deleteAuthorsByPaper($paperId);
324 
325  $publishedPaperDao =& DAORegistry::getDAO('PublishedPaperDAO');
326  $publishedPaperDao->deletePublishedPaperByPaperId($paperId);
327 
328  $commentDao =& DAORegistry::getDAO('CommentDAO');
329  $commentDao->deleteCommentsByPaper($paperId);
330 
331  $paperNoteDao =& DAORegistry::getDAO('PaperNoteDAO');
332  $paperNoteDao->clearAllPaperNotes($paperId);
333 
334  $trackDirectorSubmissionDao =& DAORegistry::getDAO('TrackDirectorSubmissionDAO');
335  $trackDirectorSubmissionDao->deleteDecisionsByPaper($paperId);
336  $trackDirectorSubmissionDao->deleteReviewStagesByPaper($paperId);
337 
338  $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
339  $reviewAssignmentDao->deleteReviewAssignmentsByPaper($paperId);
340 
341  $editAssignmentDao =& DAORegistry::getDAO('EditAssignmentDAO');
342  $editAssignmentDao->deleteEditAssignmentsByPaper($paperId);
343 
344  $paperCommentDao =& DAORegistry::getDAO('PaperCommentDAO');
345  $paperCommentDao->deletePaperComments($paperId);
346 
347  $paperGalleyDao =& DAORegistry::getDAO('PaperGalleyDAO');
348  $paperGalleyDao->deleteGalleysByPaper($paperId);
349 
350  $paperSearchDao =& DAORegistry::getDAO('PaperSearchDAO');
351  $paperSearchDao->deletePaperKeywords($paperId);
352 
353  $paperEventLogDao =& DAORegistry::getDAO('PaperEventLogDAO');
354  $paperEventLogDao->deletePaperLogEntries($paperId);
355 
356  $paperEmailLogDao =& DAORegistry::getDAO('PaperEmailLogDAO');
357  $paperEmailLogDao->deletePaperLogEntries($paperId);
358 
359  $paperEventLogDao =& DAORegistry::getDAO('PaperEventLogDAO');
360  $paperEventLogDao->deletePaperLogEntries($paperId);
361 
362  $suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
363  $suppFileDao->deleteSuppFilesByPaper($paperId);
364 
365  // Delete paper files -- first from the filesystem, then from the database
366  import('file.PaperFileManager');
367  $paperFileDao =& DAORegistry::getDAO('PaperFileDAO');
368  $paperFiles =& $paperFileDao->getPaperFilesByPaper($paperId);
369 
370  $paperFileManager = new PaperFileManager($paperId);
371  foreach ($paperFiles as $paperFile) {
372  $paperFileManager->deleteFile($paperFile->getFileId());
373  }
374 
375  $paperFileDao->deletePaperFiles($paperId);
376 
377  $this->update('DELETE FROM paper_settings WHERE paper_id = ?', $paperId);
378  $this->update('DELETE FROM papers WHERE paper_id = ?', $paperId);
379  }
380 
387  function &getPapersBySchedConfId($schedConfId, $trackId = null) {
388  $primaryLocale = AppLocale::getPrimaryLocale();
389  $locale = AppLocale::getLocale();
390 
391  $params = array(
392  'title',
393  $primaryLocale,
394  'title',
395  $locale,
396  'abbrev',
397  $primaryLocale,
398  'abbrev',
399  $locale,
400  $schedConfId
401  );
402 
403  if ($trackId) $params[] = $trackId;
404 
405  $papers = array();
406  $result =& $this->retrieve(
407  'SELECT p.*,
408  COALESCE(ttl.setting_value, ttpl.setting_value) AS track_title,
409  COALESCE(tal.setting_value, tapl.setting_value) AS track_abbrev
410  FROM papers p
411  LEFT JOIN tracks t ON t.track_id = p.track_id
412  LEFT JOIN track_settings ttpl ON (t.track_id = ttpl.track_id AND ttpl.setting_name = ? AND ttpl.locale = ?)
413  LEFT JOIN track_settings ttl ON (t.track_id = ttl.track_id AND ttl.setting_name = ? AND ttl.locale = ?)
414  LEFT JOIN track_settings tapl ON (t.track_id = tapl.track_id AND tapl.setting_name = ? AND tapl.locale = ?)
415  LEFT JOIN track_settings tal ON (t.track_id = tal.track_id AND tal.setting_name = ? AND tal.locale = ?)
416  WHERE p.sched_conf_id = ?' .
417  ($trackId ? ' AND p.track_id = ?' : ''),
418  $params
419  );
420 
421  $returner = new DAOResultFactory($result, $this, '_returnPaperFromRow');
422  return $returner;
423  }
424 
429  function deletePapersBySchedConfId($schedConfId) {
430  $papers = $this->getPapersBySchedConfId($schedConfId);
431 
432  while (!$papers->eof()) {
433  $paper =& $papers->next();
434  $this->deletePaperById($paper->getId());
435  }
436  }
437 
444  function &getPapersByUserId($userId, $schedConfId = null) {
445  $primaryLocale = AppLocale::getPrimaryLocale();
446  $locale = AppLocale::getLocale();
447 
448  $params = array(
449  'title',
450  $primaryLocale,
451  'title',
452  $locale,
453  'abbrev',
454  $primaryLocale,
455  'abbrev',
456  $locale,
457  $userId
458  );
459 
460  if ($schedConfId) $params[] = $schedConfId;
461 
462  $papers = array();
463 
464  $result =& $this->retrieve(
465  'SELECT p.*,
466  COALESCE(ttl.setting_value, ttpl.setting_value) AS track_title,
467  COALESCE(tal.setting_value, tapl.setting_value) AS track_abbrev
468  FROM papers p
469  LEFT JOIN tracks t ON t.track_id = p.track_id
470  LEFT JOIN track_settings ttpl ON (t.track_id = ttpl.track_id AND ttpl.setting_name = ? AND ttpl.locale = ?)
471  LEFT JOIN track_settings ttl ON (t.track_id = ttl.track_id AND ttl.setting_name = ? AND ttl.locale = ?)
472  LEFT JOIN track_settings tapl ON (t.track_id = tapl.track_id AND tapl.setting_name = ? AND tapl.locale = ?)
473  LEFT JOIN track_settings tal ON (t.track_id = tal.track_id AND tal.setting_name = ? AND tal.locale = ?)
474  WHERE p.user_id = ?' . (isset($schedConfId)?' AND p.sched_conf_id = ?':''),
475  $params
476  );
477 
478  while (!$result->EOF) {
479  $papers[] =& $this->_returnPaperFromRow($result->GetRowAssoc(false));
480  $result->MoveNext();
481  }
482 
483  $result->Close();
484  unset($result);
485 
486  return $papers;
487  }
488 
494  function getPaperSchedConfId($paperId) {
495  $result =& $this->retrieve(
496  'SELECT sched_conf_id FROM papers WHERE paper_id = ?', $paperId
497  );
498  $returner = isset($result->fields[0]) ? $result->fields[0] : false;
499 
500  $result->Close();
501  unset($result);
502 
503  return $returner;
504  }
505 
513  function incompleteSubmissionExists($paperId, $userId, $schedConfId) {
514  $result =& $this->retrieve(
515  'SELECT submission_progress FROM papers WHERE paper_id = ? AND user_id = ? AND sched_conf_id = ? AND date_submitted IS NULL',
516  array($paperId, $userId, $schedConfId)
517  );
518  $returner = isset($result->fields[0]) ? $result->fields[0] : false;
519 
520  $result->Close();
521  unset($result);
522 
523  return $returner;
524  }
525 
531  function changePaperStatus($paperId, $status) {
532  $this->update(
533  'UPDATE papers SET status = ? WHERE paper_id = ?', array($status, $paperId)
534  );
535  }
536 
541  function removePapersFromTrack($trackId) {
542  $this->update(
543  'UPDATE papers SET track_id = null WHERE track_id = ?', $trackId
544  );
545  }
546 
551  function getInsertPaperId() {
552  return $this->getInsertId('papers', 'paper_id');
553  }
554 }
555 
556 ?>
const STATUS_QUEUED
Definition: Paper.inc.php:26
Operations for retrieving and modifying Paper objects.
changePaperStatus($paperId, $status)
config TEMPLATE inc php
Definition: config.inc.php:4
incompleteSubmissionExists($paperId, $userId, $schedConfId)
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
getInsertPaperId()
getInsertId($table='', $id='', $callHooks=true)
Definition: DAO.inc.php:225
updateLocaleFields(&$paper)
& _returnPaperFromRow(&$row)
updateDataObjectSettings($tableName, &$dataObject, $idArray)
Definition: DAO.inc.php:412
getLocaleFieldNames()
deletePaper(&$paper)
& getPapersByUserId($userId, $schedConfId=null)
getAdditionalFieldNames()
_paperFromRow(&$paper, &$row)
getPaperSchedConfId($paperId)
datetimeFromDB($dt)
Definition: DAO.inc.php:276
deletePaperById($paperId)
Wrapper around ADORecordSet providing "factory" features for generating objects from DAOs.
& getDAO($name, $dbconn=null)
Paper class.
Definition: Paper.inc.php:54
call($hookName, $args=null)
& getPapersBySchedConfId($schedConfId, $trackId=null)
insertPaper(&$paper)
getDataObjectSettings($tableName, $idFieldName, $idFieldValue, &$dataObject)
Definition: DAO.inc.php:498
datetimeToDB($dt)
Definition: DAO.inc.php:258
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:186
updatePaper(&$paper)
deletePapersBySchedConfId($schedConfId)
Class defining operations for paper file management.
removePapersFromTrack($trackId)
& getPaper($paperId)