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)  

AuthorSubmissionDAO.inc.php
Go to the documentation of this file.
1 <?php
2 
16 //$Id$
17 
18 import('submission.author.AuthorSubmission');
19 
20 class AuthorSubmissionDAO extends DAO {
21 
22  var $paperDao;
24  var $userDao;
30 
34  function AuthorSubmissionDAO() {
35  parent::DAO();
36  $this->paperDao =& DAORegistry::getDAO('PaperDAO');
37  $this->authorDao =& DAORegistry::getDAO('AuthorDAO');
38  $this->userDao =& DAORegistry::getDAO('UserDAO');
39  $this->reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
40  $this->editAssignmentDao =& DAORegistry::getDAO('EditAssignmentDAO');
41  $this->paperFileDao =& DAORegistry::getDAO('PaperFileDAO');
42  $this->suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
43  $this->paperCommentDao =& DAORegistry::getDAO('PaperCommentDAO');
44  $this->galleyDao =& DAORegistry::getDAO('PaperGalleyDAO');
45  }
46 
52  function &getAuthorSubmission($paperId) {
53  $primaryLocale = AppLocale::getPrimaryLocale();
54  $locale = AppLocale::getLocale();
55  $result =& $this->retrieve(
56  'SELECT
57  p.*,
58  COALESCE(ttl.setting_value, ttpl.setting_value) AS track_title,
59  COALESCE(tal.setting_value, tapl.setting_value) AS track_abbrev
60  FROM papers p
61  LEFT JOIN tracks t ON (t.track_id = p.track_id)
62  LEFT JOIN track_settings ttpl ON (t.track_id = ttpl.track_id AND ttpl.setting_name = ? AND ttpl.locale = ?)
63  LEFT JOIN track_settings ttl ON (t.track_id = ttl.track_id AND ttl.setting_name = ? AND ttl.locale = ?)
64  LEFT JOIN track_settings tapl ON (t.track_id = tapl.track_id AND tapl.setting_name = ? AND tapl.locale = ?)
65  LEFT JOIN track_settings tal ON (t.track_id = tal.track_id AND tal.setting_name = ? AND tal.locale = ?)
66  WHERE p.paper_id = ?',
67  array(
68  'title',
69  $primaryLocale,
70  'title',
71  $locale,
72  'abbrev',
73  $primaryLocale,
74  'abbrev',
75  $locale,
76  $paperId
77  )
78  );
79 
80  $returner = null;
81  if ($result->RecordCount() != 0) {
82  $returner =& $this->_returnAuthorSubmissionFromRow($result->GetRowAssoc(false));
83  }
84 
85  $result->Close();
86  unset($result);
87 
88  return $returner;
89  }
90 
96  function &_returnAuthorSubmissionFromRow(&$row) {
97  $authorSubmission = new AuthorSubmission();
98 
99  // Paper attributes
100  $this->paperDao->_paperFromRow($authorSubmission, $row);
101 
102  // Director Assignment
103  $editAssignments =& $this->editAssignmentDao->getEditAssignmentsByPaperId($row['paper_id']);
104  $authorSubmission->setEditAssignments($editAssignments->toArray());
105 
106  // Director Decisions
107  for ($i = 1; $i <= $row['current_stage']; $i++) {
108  $authorSubmission->setDecisions($this->getDirectorDecisions($row['paper_id'], $i), $i);
109  }
110 
111  // Review Assignments
112  for ($i = 1; $i <= $row['current_stage']; $i++)
113  $authorSubmission->setReviewAssignments($this->reviewAssignmentDao->getReviewAssignmentsByPaperId($row['paper_id'], $i), $i);
114 
115  // Comments
116  $authorSubmission->setMostRecentDirectorDecisionComment($this->paperCommentDao->getMostRecentPaperComment($row['paper_id'], COMMENT_TYPE_DIRECTOR_DECISION, $row['paper_id']));
117 
118  // Files
119  $authorSubmission->setSubmissionFile($this->paperFileDao->getPaperFile($row['submission_file_id']));
120  $authorSubmission->setRevisedFile($this->paperFileDao->getPaperFile($row['revised_file_id']));
121  $authorSubmission->setSuppFiles($this->suppFileDao->getSuppFilesByPaper($row['paper_id']));
122  for ($i = 1; $i <= $row['current_stage']; $i++) {
123  $authorSubmission->setAuthorFileRevisions($this->paperFileDao->getPaperFileRevisions($row['revised_file_id'], $i), $i);
124  }
125  for ($i = 1; $i <= $row['current_stage']; $i++) {
126  $authorSubmission->setDirectorFileRevisions($this->paperFileDao->getPaperFileRevisions($row['director_file_id'], $i), $i);
127  }
128  $authorSubmission->setLayoutFile($this->paperFileDao->getPaperFile($row['layout_file_id']));
129  $authorSubmission->setGalleys($this->galleyDao->getGalleysByPaper($row['paper_id']));
130 
131  HookRegistry::call('AuthorSubmissionDAO::_returnAuthorSubmissionFromRow', array(&$authorSubmission, &$row));
132 
133  return $authorSubmission;
134  }
135 
140  function updateAuthorSubmission(&$authorSubmission) {
141  // Update paper
142  if ($authorSubmission->getPaperId()) {
143  $paper =& $this->paperDao->getPaper($authorSubmission->getPaperId());
144 
145  // Only update fields that an author can actually edit.
146  $paper->setRevisedFileId($authorSubmission->getRevisedFileId());
147  $paper->setDateStatusModified($authorSubmission->getDateStatusModified());
148  $paper->setLastModified($authorSubmission->getLastModified());
149  // FIXME: These two are necessary for designating the
150  // original as the review version, but they are probably
151  // best not exposed like this.
152  $paper->setReviewFileId($authorSubmission->getReviewFileId());
153  $paper->setDirectorFileId($authorSubmission->getDirectorFileId());
154 
155  $this->paperDao->updatePaper($paper);
156  }
157  }
158 
164  $primaryLocale = AppLocale::getPrimaryLocale();
165  $locale = AppLocale::getLocale();
166  $incompleteSubmissions = array();
167  $result =& $this->retrieve(
168  'SELECT p.*,
169  COALESCE(ttl.setting_value, ttpl.setting_value) AS track_title,
170  COALESCE(tal.setting_value, tapl.setting_value) AS track_abbrev
171  FROM papers p
172  LEFT JOIN tracks t ON (t.track_id = p.track_id)
173  LEFT JOIN track_settings ttpl ON (t.track_id = ttpl.track_id AND ttpl.setting_name = ? AND ttpl.locale = ?)
174  LEFT JOIN track_settings ttl ON (t.track_id = ttl.track_id AND ttl.setting_name = ? AND ttl.locale = ?)
175  LEFT JOIN track_settings tapl ON (t.track_id = tapl.track_id AND tapl.setting_name = ? AND tapl.locale = ?)
176  LEFT JOIN track_settings tal ON (t.track_id = tal.track_id AND tal.setting_name = ? AND tal.locale = ?)
177  WHERE p.submission_progress != 0 AND
178  p.status = ' . (int)STATUS_QUEUED,
179  array(
180  'title',
181  $primaryLocale,
182  'title',
183  $locale,
184  'abbrev',
185  $primaryLocale,
186  'abbrev',
187  $locale
188  )
189  );
190 
191  while(!$result->EOF) {
192  $incompleteSubmissions[] =& $this->_returnAuthorSubmissionFromRow($result->getRowAssoc(false));
193  $result->moveNext();
194  }
195  return $incompleteSubmissions;
196  }
197 
203  function &getAuthorSubmissions($authorId, $schedConfId, $active = true, $rangeInfo = null, $sortBy = null, $sortDirection = SORT_DIRECTION_ASC) {
204  $primaryLocale = AppLocale::getPrimaryLocale();
205  $locale = AppLocale::getLocale();
206  $result =& $this->retrieveRange(
207  'SELECT p.*,
208  COALESCE(ptl.setting_value, pptl.setting_value) AS submission_title,
209  pa.last_name AS author_name,
210  (SELECT SUM(g.views) FROM paper_galleys g WHERE (g.paper_id = p.paper_id AND g.locale = ?)) AS galley_views,
211  COALESCE(ttl.setting_value, ttpl.setting_value) AS track_title,
212  COALESCE(tal.setting_value, tapl.setting_value) AS track_abbrev
213  FROM papers p
214  LEFT JOIN paper_authors pa ON (pa.paper_id = p.paper_id AND pa.primary_contact = 1)
215  LEFT JOIN paper_settings pptl ON (p.paper_id = pptl.paper_id AND pptl.setting_name = ? AND pptl.locale = ?)
216  LEFT JOIN paper_settings ptl ON (p.paper_id = ptl.paper_id AND ptl.setting_name = ? AND ptl.locale = ?)
217  LEFT JOIN tracks t ON (t.track_id = p.track_id)
218  LEFT JOIN track_settings ttpl ON (t.track_id = ttpl.track_id AND ttpl.setting_name = ? AND ttpl.locale = ?)
219  LEFT JOIN track_settings ttl ON (t.track_id = ttl.track_id AND ttl.setting_name = ? AND ttl.locale = ?)
220  LEFT JOIN track_settings tapl ON (t.track_id = tapl.track_id AND tapl.setting_name = ? AND tapl.locale = ?)
221  LEFT JOIN track_settings tal ON (t.track_id = tal.track_id AND tal.setting_name = ? AND tal.locale = ?)
222  WHERE p.sched_conf_id = ?
223  AND p.user_id = ?' .
224  ($active?(' AND p.status = ' . (int) STATUS_QUEUED):(
225  ' AND ((p.status <> ' . (int) STATUS_QUEUED . ' AND p.submission_progress = 0) OR (p.status = ' . (int) STATUS_ARCHIVED . '))'
226  )) .
227  ($sortBy?(' ORDER BY ' . $this->getSortMapping($sortBy) . ' ' . $this->getDirectionMapping($sortDirection)) : ''),
228  array(
229  $locale,
230  'cleanTitle',
231  $primaryLocale,
232  'cleanTitle',
233  $locale,
234  'title',
235  $primaryLocale,
236  'title',
237  $locale,
238  'abbrev',
239  $primaryLocale,
240  'abbrev',
241  $locale,
242  $schedConfId,
243  $authorId
244  ),
245  $rangeInfo
246  );
247 
248  $returner = new DAOResultFactory($result, $this, '_returnAuthorSubmissionFromRow');
249  return $returner;
250  }
251 
252  //
253  // Miscellaneous
254  //
255 
261  function getDirectorDecisions($paperId, $stage = null) {
262  $decisions = array();
263  $args = array($paperId);
264  if($stage) {
265  $args[] = $stage;
266  }
267 
268  $result =& $this->retrieve(
269  'SELECT edit_decision_id, director_id, decision, date_decided
270  FROM edit_decisions
271  WHERE paper_id = ? ' .
272  ($stage?' AND stage = ?':'') .
273  ' ORDER BY date_decided ASC',
274  (count($args)==1?shift($args):$args)
275  );
276 
277  while (!$result->EOF) {
278  $decisions[] = array(
279  'editDecisionId' => $result->fields['edit_decision_id'],
280  'directorId' => $result->fields['director_id'],
281  'decision' => $result->fields['decision'],
282  'dateDecided' => $this->datetimeFromDB($result->fields['date_decided'])
283  );
284  $result->moveNext();
285  }
286 
287  $result->Close();
288  unset($result);
289 
290  return $decisions;
291  }
292 
298  function getSubmissionsCount($authorId, $schedConfId) {
299  $submissionsCount = array();
300  $submissionsCount[0] = 0;
301  $submissionsCount[1] = 0;
302 
303  $sql = '
304  SELECT count(*), status
305  FROM papers p
306  WHERE p.sched_conf_id = ? AND
307  p.user_id = ?
308  GROUP BY p.status';
309 
310  $result =& $this->retrieve($sql, array($schedConfId, $authorId));
311 
312  while (!$result->EOF) {
313  if ($result->fields['status'] != 1) {
314  $submissionsCount[1] += $result->fields[0];
315  } else {
316  $submissionsCount[0] += $result->fields[0];
317  }
318  $result->moveNext();
319  }
320 
321  $result->Close();
322  unset($result);
323 
324  return $submissionsCount;
325  }
326 
332  function getSortMapping($heading) {
333  switch ($heading) {
334  case 'id': return 'p.paper_id';
335  case 'submitDate': return 'p.date_submitted';
336  case 'track': return 'track_abbrev';
337  case 'authors': return 'author_name';
338  case 'title': return 'submission_title';
339  case 'active': return 'p.submission_progress';
340  case 'views': return 'galley_views';
341  case 'status': return 'p.status';
342  default: return null;
343  }
344  }
345 }
346 
347 ?>
const STATUS_QUEUED
Definition: Paper.inc.php:26
config TEMPLATE inc php
Definition: config.inc.php:4
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
const COMMENT_TYPE_DIRECTOR_DECISION
updateAuthorSubmission(&$authorSubmission)
getDirectorDecisions($paperId, $stage=null)
& retrieveRange($sql, $params=false, $dbResultRange=null, $callHooks=true)
Definition: DAO.inc.php:152
AuthorSubmission class.
Wrapper around ADORecordSet providing "factory" features for generating objects from DAOs.
getSubmissionsCount($authorId, $schedConfId)
Operations for retrieving and modifying AuthorSubmission objects.
& getDAO($name, $dbconn=null)
call($hookName, $args=null)
getDirectionMapping($direction)
Definition: DAO.inc.php:541
& getAuthorSubmissions($authorId, $schedConfId, $active=true, $rangeInfo=null, $sortBy=null, $sortDirection=SORT_DIRECTION_ASC)
const STATUS_ARCHIVED
Definition: Paper.inc.php:25
const SORT_DIRECTION_ASC
Definition: DAO.inc.php:27