Open Journal Systems  2.4.8
 All Classes Namespaces Functions Variables Groups Pages
EditorSubmissionDAO.inc.php
1 <?php
2 
20 import('classes.submission.editor.EditorSubmission');
21 
22 // Bring in editor decision constants
23 import('classes.submission.common.Action');
24 import('classes.submission.author.AuthorSubmission');
25 
26 class EditorSubmissionDAO extends DAO {
27  var $articleDao;
28  var $authorDao;
29  var $userDao;
30  var $editAssignmentDao;
31 
35  function EditorSubmissionDAO() {
36  parent::DAO();
37  $this->articleDao =& DAORegistry::getDAO('ArticleDAO');
38  $this->articleFileDao =& DAORegistry::getDAO('ArticleFileDAO');
39  $this->authorDao =& DAORegistry::getDAO('AuthorDAO');
40  $this->userDao =& DAORegistry::getDAO('UserDAO');
41  $this->editAssignmentDao =& DAORegistry::getDAO('EditAssignmentDAO');
42  }
43 
49  function &getEditorSubmission($articleId) {
50  $primaryLocale = AppLocale::getPrimaryLocale();
51  $locale = AppLocale::getLocale();
52  $result =& $this->retrieve(
53  'SELECT
54  a.*,
55  COALESCE(stl.setting_value, stpl.setting_value) AS section_title,
56  COALESCE(sal.setting_value, sapl.setting_value) AS section_abbrev
57  FROM articles a
58  LEFT JOIN sections s ON s.section_id = a.section_id
59  LEFT JOIN section_settings stpl ON (s.section_id = stpl.section_id AND stpl.setting_name = ? AND stpl.locale = ?)
60  LEFT JOIN section_settings stl ON (s.section_id = stl.section_id AND stl.setting_name = ? AND stl.locale = ?)
61  LEFT JOIN section_settings sapl ON (s.section_id = sapl.section_id AND sapl.setting_name = ? AND sapl.locale = ?)
62  LEFT JOIN section_settings sal ON (s.section_id = sal.section_id AND sal.setting_name = ? AND sal.locale = ?)
63  WHERE a.article_id = ?',
64  array(
65  'title',
66  $primaryLocale,
67  'title',
68  $locale,
69  'abbrev',
70  $primaryLocale,
71  'abbrev',
72  $locale,
73  $articleId
74  )
75  );
76 
77  $returner = null;
78  if ($result->RecordCount() != 0) {
79  $returner =& $this->_returnEditorSubmissionFromRow($result->GetRowAssoc(false));
80  }
81 
82  $result->Close();
83  unset($result);
84 
85  return $returner;
86  }
87 
93  function &_returnEditorSubmissionFromRow(&$row) {
94  $editorSubmission = new EditorSubmission();
95 
96  // Article attributes
97  $this->articleDao->_articleFromRow($editorSubmission, $row);
98 
99  // Editor Assignment
100  $editAssignments =& $this->editAssignmentDao->getEditAssignmentsByArticleId($row['article_id']);
101  $editorSubmission->setEditAssignments($editAssignments->toArray());
102 
103  // Editor Decisions
104  for ($i = 1; $i <= $row['current_round']; $i++) {
105  $editorSubmission->setDecisions($this->getEditorDecisions($row['article_id'], $i), $i);
106  }
107 
108  for ($i = 1; $i <= $row['current_round']; $i++) {
109  $editorSubmission->setEditorFileRevisions($this->articleFileDao->getArticleFileRevisions($row['editor_file_id'], $i), $i);
110  $editorSubmission->setAuthorFileRevisions($this->articleFileDao->getArticleFileRevisions($row['revised_file_id'], $i), $i);
111  }
112 
113  // Review Rounds
114  $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
115  for ($i = 1; $i <= $editorSubmission->getCurrentRound(); $i++) {
116  $reviewAssignments =& $reviewAssignmentDao->getBySubmissionId($editorSubmission->getId(), $i);
117  if (!empty($reviewAssignments)) {
118  $editorSubmission->setReviewAssignments($reviewAssignments, $i);
119  }
120  unset($reviewAssignments);
121  }
122 
123  HookRegistry::call('EditorSubmissionDAO::_returnEditorSubmissionFromRow', array(&$editorSubmission, &$row));
124 
125  return $editorSubmission;
126  }
127 
132  function insertEditorSubmission(&$editorSubmission) {
133  $this->update(
134  sprintf('INSERT INTO edit_assignments
135  (article_id, editor_id, date_notified, date_completed, date_acknowledged)
136  VALUES
137  (?, ?, %s, %s, %s)',
138  $this->datetimeToDB($editorSubmission->getDateNotified()), $this->datetimeToDB($editorSubmission->getDateCompleted()), $this->datetimeToDB($editorSubmission->getDateAcknowledged())),
139  array(
140  $editorSubmission->getId(),
141  $editorSubmission->getEditorId()
142  )
143  );
144 
145  $editorSubmission->setEditId($this->getInsertEditId());
146 
147  // Insert review assignments.
148  $reviewAssignments =& $editorSubmission->getReviewAssignments();
149  for ($i=0, $count=count($reviewAssignments); $i < $count; $i++) {
150  $reviewAssignments[$i]->setArticleId($editorSubmission->getId());
151  $this->reviewAssignmentDao->insertReviewAssignment($reviewAssignments[$i]);
152  }
153 
154  return $editorSubmission->getEditId();
155  }
156 
161  function updateEditorSubmission(&$editorSubmission) {
162  // update edit assignments
163  $editAssignments = $editorSubmission->getEditAssignments();
164  foreach ($editAssignments as $editAssignment) {
165  if ($editAssignment->getEditId() > 0) {
166  $this->editAssignmentDao->updateEditAssignment($editAssignment);
167  } else {
168  $this->editAssignmentDao->insertEditAssignment($editAssignment);
169  }
170  }
171  }
172 
188  function &_getUnfilteredEditorSubmissions($journalId, $sectionId = 0, $editorId = 0, $searchField = null, $searchMatch = null, $search = null, $dateField = null, $dateFrom = null, $dateTo = null, $additionalWhereSql, $rangeInfo = null, $sortBy = null, $sortDirection = SORT_DIRECTION_ASC) {
189  $primaryLocale = AppLocale::getPrimaryLocale();
190  $locale = AppLocale::getLocale();
191  $params = array(
192  ASSOC_TYPE_ARTICLE,
193  'SIGNOFF_COPYEDITING_FINAL',
194  ASSOC_TYPE_ARTICLE,
195  'SIGNOFF_PROOFREADING_PROOFREADER',
196  ASSOC_TYPE_ARTICLE,
197  'SIGNOFF_LAYOUT',
198  'title', // Section title
199  $primaryLocale,
200  'title',
201  $locale,
202  'abbrev', // Section abbrev
203  $primaryLocale,
204  'abbrev',
205  $locale,
206  'cleanTitle', // Article title
207  'cleanTitle',
208  $locale,
209  'title', // Article title
210  'title',
211  $locale,
212  $journalId
213  );
214  $searchSql = '';
215 
216  if (!empty($search)) switch ($searchField) {
217  case SUBMISSION_FIELD_ID:
218  switch ($searchMatch) {
219  case 'is':
220  $params[] = (int) $search;
221  $searchSql = ' AND a.article_id = ?';
222  break;
223  case 'contains':
224  $search = '%' . $search . '%';
225  $params[] = $search;
226  $searchSql = ' AND CONCAT(a.article_id) LIKE ?';
227  break;
228  case 'startsWith':
229  $search = $search . '%';
230  $params[] = $search;
231  $searchSql = 'AND CONCAT(a.article_id) LIKE ?';
232  break;
233  }
234  break;
235  case SUBMISSION_FIELD_TITLE:
236  if ($searchMatch === 'is') {
237  $searchSql = ' AND LOWER(COALESCE(atl.setting_value, atpl.setting_value)) = LOWER(?)';
238  } elseif ($searchMatch === 'contains') {
239  $searchSql = ' AND LOWER(COALESCE(atl.setting_value, atpl.setting_value)) LIKE LOWER(?)';
240  $search = '%' . $search . '%';
241  } else { // $searchMatch === 'startsWith'
242  $searchSql = ' AND LOWER(COALESCE(atl.setting_value, atpl.setting_value)) LIKE LOWER(?)';
243  $search = $search . '%';
244  }
245  $params[] = $search;
246  break;
247  case SUBMISSION_FIELD_AUTHOR:
248  $searchSql = $this->_generateUserNameSearchSQL($search, $searchMatch, 'aa.', $params);
249  break;
250  case SUBMISSION_FIELD_EDITOR:
251  $searchSql = $this->_generateUserNameSearchSQL($search, $searchMatch, 'ed.', $params);
252  break;
253  case SUBMISSION_FIELD_REVIEWER:
254  $searchSql = $this->_generateUserNameSearchSQL($search, $searchMatch, 're.', $params);
255  break;
256  case SUBMISSION_FIELD_COPYEDITOR:
257  $searchSql = $this->_generateUserNameSearchSQL($search, $searchMatch, 'ce.', $params);
258  break;
259  case SUBMISSION_FIELD_LAYOUTEDITOR:
260  $searchSql = $this->_generateUserNameSearchSQL($search, $searchMatch, 'le.', $params);
261  break;
262  case SUBMISSION_FIELD_PROOFREADER:
263  $searchSql = $this->_generateUserNameSearchSQL($search, $searchMatch, 'pe.', $params);
264  break;
265  }
266  if (!empty($dateFrom) || !empty($dateTo)) switch($dateField) {
267  case SUBMISSION_FIELD_DATE_SUBMITTED:
268  if (!empty($dateFrom)) {
269  $searchSql .= ' AND a.date_submitted >= ' . $this->datetimeToDB($dateFrom);
270  }
271  if (!empty($dateTo)) {
272  $searchSql .= ' AND a.date_submitted <= ' . $this->datetimeToDB($dateTo);
273  }
274  break;
275  case SUBMISSION_FIELD_DATE_COPYEDIT_COMPLETE:
276  if (!empty($dateFrom)) {
277  $searchSql .= ' AND sfc.date_completed >= ' . $this->datetimeToDB($dateFrom);
278  }
279  if (!empty($dateTo)) {
280  $searchSql .= ' AND scf.date_completed <= ' . $this->datetimeToDB($dateTo);
281  }
282  break;
283  case SUBMISSION_FIELD_DATE_LAYOUT_COMPLETE:
284  if (!empty($dateFrom)) {
285  $searchSql .= ' AND sle.date_completed >= ' . $this->datetimeToDB($dateFrom);
286  }
287  if (!empty($dateTo)) {
288  $searchSql .= ' AND sle.date_completed <= ' . $this->datetimeToDB($dateTo);
289  }
290  break;
291  case SUBMISSION_FIELD_DATE_PROOFREADING_COMPLETE:
292  if (!empty($dateFrom)) {
293  $searchSql .= ' AND spr.date_completed >= ' . $this->datetimeToDB($dateFrom);
294  }
295  if (!empty($dateTo)) {
296  $searchSql .= ' AND spr.date_completed <= ' . $this->datetimeToDB($dateTo);
297  }
298  break;
299  }
300 
301  $sql = 'SELECT DISTINCT
302  a.*,
303  scf.date_completed as copyedit_completed,
304  spr.date_completed as proofread_completed,
305  sle.date_completed as layout_completed,
306  SUBSTRING(COALESCE(actl.setting_value, actpl.setting_value) FROM 1 FOR 255) AS submission_clean_title,
307  aap.last_name AS author_name,
308  SUBSTRING(COALESCE(stl.setting_value, stpl.setting_value) FROM 1 FOR 255) AS section_title,
309  COALESCE(sal.setting_value, sapl.setting_value) AS section_abbrev
310  FROM articles a
311  LEFT JOIN authors aa ON (aa.submission_id = a.article_id)
312  LEFT JOIN authors aap ON (aap.submission_id = a.article_id AND aap.primary_contact = 1)
313  LEFT JOIN sections s ON (s.section_id = a.section_id)
314  LEFT JOIN edit_assignments e ON (e.article_id = a.article_id)
315  LEFT JOIN users ed ON (e.editor_id = ed.user_id)
316  LEFT JOIN signoffs scf ON (a.article_id = scf.assoc_id AND scf.assoc_type = ? AND scf.symbolic = ?)
317  LEFT JOIN users ce ON (scf.user_id = ce.user_id)
318  LEFT JOIN signoffs spr ON (a.article_id = spr.assoc_id AND spr.assoc_type = ? AND spr.symbolic = ?)
319  LEFT JOIN users pe ON (pe.user_id = spr.user_id)
320  LEFT JOIN signoffs sle ON (a.article_id = sle.assoc_id AND sle.assoc_type = ? AND sle.symbolic = ?)
321  LEFT JOIN users le ON (le.user_id = sle.user_id)
322  LEFT JOIN review_assignments r ON (r.submission_id = a.article_id)
323  LEFT JOIN users re ON (re.user_id = r.reviewer_id AND cancelled = 0)
324  LEFT JOIN section_settings stpl ON (s.section_id = stpl.section_id AND stpl.setting_name = ? AND stpl.locale = ?)
325  LEFT JOIN section_settings stl ON (s.section_id = stl.section_id AND stl.setting_name = ? AND stl.locale = ?)
326  LEFT JOIN section_settings sapl ON (s.section_id = sapl.section_id AND sapl.setting_name = ? AND sapl.locale = ?)
327  LEFT JOIN section_settings sal ON (s.section_id = sal.section_id AND sal.setting_name = ? AND sal.locale = ?)
328  LEFT JOIN article_settings actpl ON (a.article_id = actpl.article_id AND actpl.setting_name = ? AND actpl.locale = a.locale)
329  LEFT JOIN article_settings actl ON (a.article_id = actl.article_id AND actl.setting_name = ? AND actl.locale = ?)
330  LEFT JOIN article_settings atpl ON (a.article_id = atpl.article_id AND atpl.setting_name = ? AND atpl.locale = a.locale)
331  LEFT JOIN article_settings atl ON (a.article_id = atl.article_id AND atl.setting_name = ? AND atl.locale = ?)
332  LEFT JOIN edit_assignments ea ON (a.article_id = ea.article_id)
333  LEFT JOIN edit_assignments ea2 ON (a.article_id = ea2.article_id AND ea.edit_id < ea2.edit_id)
334  LEFT JOIN edit_decisions edec ON (a.article_id = edec.article_id)
335  LEFT JOIN edit_decisions edec2 ON (a.article_id = edec2.article_id AND edec.edit_decision_id < edec2.edit_decision_id)
336  WHERE edec2.edit_decision_id IS NULL
337  AND ea2.edit_id IS NULL
338  AND a.journal_id = ?
339  AND a.submission_progress = 0' .
340  (!empty($additionalWhereSql)?" AND ($additionalWhereSql)":'');
341 
342  if ($sectionId) {
343  $searchSql .= ' AND a.section_id = ?';
344  $params[] = $sectionId;
345  }
346 
347  if ($editorId) {
348  $searchSql .= ' AND e.editor_id = ?';
349  $params[] = $editorId;
350  }
351 
352  $result =& $this->retrieveRange(
353  $sql . ' ' . $searchSql . ($sortBy?(' ORDER BY ' . $this->getSortMapping($sortBy) . ' ' . $this->getDirectionMapping($sortDirection)) : ''),
354  count($params)===1?array_shift($params):$params,
355  $rangeInfo
356  );
357  return $result;
358  }
359 
363  function _generateUserNameSearchSQL($search, $searchMatch, $prefix, &$params) {
364  $first_last = $this->concat($prefix.'first_name', '\' \'', $prefix.'last_name');
365  $first_middle_last = $this->concat($prefix.'first_name', '\' \'', $prefix.'middle_name', '\' \'', $prefix.'last_name');
366  $last_comma_first = $this->concat($prefix.'last_name', '\', \'', $prefix.'first_name');
367  $last_comma_first_middle = $this->concat($prefix.'last_name', '\', \'', $prefix.'first_name', '\' \'', $prefix.'middle_name');
368  if ($searchMatch === 'is') {
369  $searchSql = " AND (LOWER({$prefix}last_name) = LOWER(?) OR LOWER($first_last) = LOWER(?) OR LOWER($first_middle_last) = LOWER(?) OR LOWER($last_comma_first) = LOWER(?) OR LOWER($last_comma_first_middle) = LOWER(?))";
370  } elseif ($searchMatch === 'contains') {
371  $searchSql = " AND (LOWER({$prefix}last_name) LIKE LOWER(?) OR LOWER($first_last) LIKE LOWER(?) OR LOWER($first_middle_last) LIKE LOWER(?) OR LOWER($last_comma_first) LIKE LOWER(?) OR LOWER($last_comma_first_middle) LIKE LOWER(?))";
372  $search = '%' . $search . '%';
373  } else { // $searchMatch === 'startsWith'
374  $searchSql = " AND (LOWER({$prefix}last_name) LIKE LOWER(?) OR LOWER($first_last) LIKE LOWER(?) OR LOWER($first_middle_last) LIKE LOWER(?) OR LOWER($last_comma_first) LIKE LOWER(?) OR LOWER($last_comma_first_middle) LIKE LOWER(?))";
375  $search = $search . '%';
376  }
377  $params[] = $params[] = $params[] = $params[] = $params[] = $search;
378  return $searchSql;
379  }
380 
395  function &getEditorSubmissionsUnassigned($journalId, $sectionId, $editorId, $searchField = null, $searchMatch = null, $search = null, $dateField = null, $dateFrom = null, $dateTo = null, $rangeInfo = null, $sortBy = null, $sortDirection = SORT_DIRECTION_ASC) {
396  $result =& $this->_getUnfilteredEditorSubmissions(
397  $journalId, $sectionId, $editorId,
398  $searchField, $searchMatch, $search,
399  $dateField, $dateFrom, $dateTo,
400  'a.status = ' . STATUS_QUEUED . ' AND ea.edit_id IS NULL',
401  $rangeInfo, $sortBy, $sortDirection
402  );
403  $returner = new DAOResultFactory($result, $this, '_returnEditorSubmissionFromRow');
404  return $returner;
405  }
406 
421  function &getEditorSubmissionsInReview($journalId, $sectionId, $editorId, $searchField = null, $searchMatch = null, $search = null, $dateField = null, $dateFrom = null, $dateTo = null, $rangeInfo = null, $sortBy = null, $sortDirection = SORT_DIRECTION_ASC) {
422  $result =& $this->_getUnfilteredEditorSubmissions(
423  $journalId, $sectionId, $editorId,
424  $searchField, $searchMatch, $search,
425  $dateField, $dateFrom, $dateTo,
426  'a.status = ' . STATUS_QUEUED . ' AND ea.edit_id IS NOT NULL AND (edec.decision IS NULL OR edec.decision <> ' . SUBMISSION_EDITOR_DECISION_ACCEPT . ')',
427  $rangeInfo, $sortBy, $sortDirection
428  );
429  $returner = new DAOResultFactory($result, $this, '_returnEditorSubmissionFromRow');
430  return $returner;
431  }
432 
447  function &getEditorSubmissionsInEditing($journalId, $sectionId, $editorId, $searchField = null, $searchMatch = null, $search = null, $dateField = null, $dateFrom = null, $dateTo = null, $rangeInfo = null, $sortBy = null, $sortDirection = SORT_DIRECTION_ASC) {
448  $result =& $this->_getUnfilteredEditorSubmissions(
449  $journalId, $sectionId, $editorId,
450  $searchField, $searchMatch, $search,
451  $dateField, $dateFrom, $dateTo,
452  'a.status = ' . STATUS_QUEUED . ' AND ea.edit_id IS NOT NULL AND edec.decision = ' . SUBMISSION_EDITOR_DECISION_ACCEPT,
453  $rangeInfo, $sortBy, $sortDirection
454  );
455  $returner = new DAOResultFactory($result, $this, '_returnEditorSubmissionFromRow');
456  return $returner;
457  }
458 
473  function &getEditorSubmissionsArchives($journalId, $sectionId, $editorId, $searchField = null, $searchMatch = null, $search = null, $dateField = null, $dateFrom = null, $dateTo = null, $rangeInfo = null, $sortBy = null, $sortDirection = SORT_DIRECTION_ASC) {
474  $result =& $this->_getUnfilteredEditorSubmissions(
475  $journalId, $sectionId, $editorId,
476  $searchField, $searchMatch, $search,
477  $dateField, $dateFrom, $dateTo,
478  'a.status <> ' . STATUS_QUEUED,
479  $rangeInfo, $sortBy, $sortDirection
480  );
481  $returner = new DAOResultFactory($result, $this, '_returnEditorSubmissionFromRow');
482  return $returner;
483  }
484 
499  function &getEditorSubmissions($journalId, $sectionId, $editorId, $searchField = null, $searchMatch = null, $search = null, $dateField = null, $dateFrom = null, $dateTo = null, $rangeInfo = null, $sortBy = null, $sortDirection = SORT_DIRECTION_ASC) {
500  $result =& $this->_getUnfilteredEditorSubmissions(
501  $journalId, $sectionId, $editorId,
502  $searchField, $searchMatch, $search,
503  $dateField, $dateFrom, $dateTo,
504  null,
505  $rangeInfo, $sortBy, $sortDirection
506  );
507  $returner = new DAOResultFactory($result, $this, '_returnEditorSubmissionFromRow');
508  return $returner;
509  }
510 
514  function &getEditorSubmissionsCount($journalId) {
515  $submissionsCount = array();
516  for($i = 0; $i < 3; $i++) {
517  $submissionsCount[$i] = 0;
518  }
519 
520  // Fetch a count of unassigned submissions.
521  // "e2" and "e" are used to fetch only a single assignment
522  // if several exist.
523  $result =& $this->retrieve(
524  'SELECT COUNT(*) AS unassigned_count
525  FROM articles a
526  LEFT JOIN edit_assignments e ON (a.article_id = e.article_id)
527  LEFT JOIN edit_assignments e2 ON (a.article_id = e2.article_id AND e.edit_id < e2.edit_id)
528  WHERE a.journal_id = ?
529  AND a.submission_progress = 0
530  AND a.status = ' . STATUS_QUEUED . '
531  AND e2.edit_id IS NULL
532  AND e.edit_id IS NULL',
533  array((int) $journalId)
534  );
535  $submissionsCount[0] = $result->Fields('unassigned_count');
536  $result->Close();
537 
538  // Fetch a count of submissions in review.
539  // "e2" and "e" are used to fetch only a single assignment
540  // if several exist.
541  // "d2" and "d" are used to fetch the single most recent
542  // editor decision.
543  $result =& $this->retrieve(
544  'SELECT COUNT(*) AS review_count
545  FROM articles a
546  LEFT JOIN edit_assignments e ON (a.article_id = e.article_id)
547  LEFT JOIN edit_assignments e2 ON (a.article_id = e2.article_id AND e.edit_id < e2.edit_id)
548  LEFT JOIN edit_decisions d ON (a.article_id = d.article_id)
549  LEFT JOIN edit_decisions d2 ON (a.article_id = d2.article_id AND d.edit_decision_id < d2.edit_decision_id)
550  WHERE a.journal_id = ?
551  AND a.submission_progress = 0
552  AND a.status = ' . STATUS_QUEUED . '
553  AND e2.edit_id IS NULL
554  AND e.edit_id IS NOT NULL
555  AND d2.edit_decision_id IS NULL
556  AND (d.decision IS NULL OR d.decision <> ' . SUBMISSION_EDITOR_DECISION_ACCEPT . ')',
557  array((int) $journalId)
558  );
559  $submissionsCount[1] = $result->Fields('review_count');
560  $result->Close();
561 
562  // Fetch a count of submissions in editing.
563  // "e2" and "e" are used to fetch only a single assignment
564  // if several exist.
565  // "d2" and "d" are used to fetch the single most recent
566  // editor decision.
567  $result =& $this->retrieve(
568  'SELECT COUNT(*) AS editing_count
569  FROM articles a
570  LEFT JOIN edit_assignments e ON (a.article_id = e.article_id)
571  LEFT JOIN edit_assignments e2 ON (a.article_id = e2.article_id AND e.edit_id < e2.edit_id)
572  LEFT JOIN edit_decisions d ON (a.article_id = d.article_id)
573  LEFT JOIN edit_decisions d2 ON (a.article_id = d2.article_id AND d.edit_decision_id < d2.edit_decision_id)
574  WHERE a.journal_id = ?
575  AND a.submission_progress = 0
576  AND a.status = ' . STATUS_QUEUED . '
577  AND e2.edit_id IS NULL
578  AND e.edit_id IS NOT NULL
579  AND d2.edit_decision_id IS NULL
580  AND d.decision = ' . SUBMISSION_EDITOR_DECISION_ACCEPT,
581  array((int) $journalId)
582  );
583  $submissionsCount[2] = $result->Fields('editing_count');
584  $result->Close();
585 
586  return $submissionsCount;
587  }
588 
589  //
590  // Miscellaneous
591  //
592 
598  function getEditorDecisions($articleId, $round = null) {
599  $decisions = array();
600 
601  if ($round == null) {
602  $result =& $this->retrieve(
603  'SELECT edit_decision_id, editor_id, decision, date_decided FROM edit_decisions WHERE article_id = ? ORDER BY edit_decision_id ASC', $articleId
604  );
605  } else {
606  $result =& $this->retrieve(
607  'SELECT edit_decision_id, editor_id, decision, date_decided FROM edit_decisions WHERE article_id = ? AND round = ? ORDER BY edit_decision_id ASC',
608  array($articleId, $round)
609  );
610  }
611 
612  while (!$result->EOF) {
613  $decisions[] = array('editDecisionId' => $result->fields[0], 'editorId' => $result->fields[1], 'decision' => $result->fields[2], 'dateDecided' => $this->datetimeFromDB($result->fields[3]));
614  $result->moveNext();
615  }
616  $result->Close();
617  unset($result);
618 
619  return $decisions;
620  }
621 
626  function transferEditorDecisions($oldUserId, $newUserId) {
627  $this->update(
628  'UPDATE edit_decisions SET editor_id = ? WHERE editor_id = ?',
629  array($newUserId, $oldUserId)
630  );
631  }
632 
640  function &getUsersNotAssignedToArticle($journalId, $articleId, $roleId, $searchType=null, $search=null, $searchMatch=null, $rangeInfo = null) {
641  $users = array();
642 
643  $paramArray = array('interest', $articleId, $journalId, $roleId);
644  $searchSql = '';
645 
646  $searchTypeMap = array(
647  USER_FIELD_FIRSTNAME => 'u.first_name',
648  USER_FIELD_LASTNAME => 'u.last_name',
649  USER_FIELD_USERNAME => 'u.username',
650  USER_FIELD_EMAIL => 'u.email',
651  USER_FIELD_INTERESTS => 'cves.setting_value'
652  );
653 
654  if (!empty($search) && isset($searchTypeMap[$searchType])) {
655  $fieldName = $searchTypeMap[$searchType];
656  switch ($searchMatch) {
657  case 'is':
658  $searchSql = "AND LOWER($fieldName) = LOWER(?)";
659  $paramArray[] = $search;
660  break;
661  case 'contains':
662  $searchSql = "AND LOWER($fieldName) LIKE LOWER(?)";
663  $paramArray[] = '%' . $search . '%';
664  break;
665  case 'startsWith':
666  $searchSql = "AND LOWER($fieldName) LIKE LOWER(?)";
667  $paramArray[] = $search . '%';
668  break;
669  }
670  } elseif (!empty($search)) switch ($searchType) {
671  case USER_FIELD_USERID:
672  $searchSql = 'AND u.user_id=?';
673  $paramArray[] = $search;
674  break;
675  case USER_FIELD_INITIAL:
676  $searchSql = 'AND (LOWER(u.last_name) LIKE LOWER(?) OR LOWER(u.username) LIKE LOWER(?))';
677  $paramArray[] = $search . '%';
678  $paramArray[] = $search . '%';
679  break;
680  }
681 
682  $result =& $this->retrieveRange(
683  'SELECT DISTINCT
684  u.*
685  FROM users u
686  LEFT JOIN controlled_vocabs cv ON (cv.symbolic = ?)
687  LEFT JOIN user_interests ui ON (ui.user_id = u.user_id)
688  LEFT JOIN controlled_vocab_entries cve ON (cve.controlled_vocab_id = cv.controlled_vocab_id AND ui.controlled_vocab_entry_id = cve.controlled_vocab_entry_id)
689  LEFT JOIN controlled_vocab_entry_settings cves ON (cves.controlled_vocab_entry_id = cve.controlled_vocab_entry_id)
690  LEFT JOIN roles r ON (r.user_id = u.user_id)
691  LEFT JOIN edit_assignments e ON (e.editor_id = u.user_id AND e.article_id = ?)
692  WHERE r.journal_id = ? AND
693  r.role_id = ? AND
694  (e.article_id IS NULL) ' . $searchSql . '
695  ORDER BY last_name, first_name',
696  $paramArray, $rangeInfo
697  );
698 
699  $returner = new DAOResultFactory($result, $this->userDao, '_returnUserFromRowWithData');
700  return $returner;
701  }
702 
707  function getInsertEditId() {
708  return $this->getInsertId('edit_assignments', 'edit_id');
709  }
710 
716  function getSortMapping($heading) {
717  switch ($heading) {
718  case 'id': return 'a.article_id';
719  case 'submitDate': return 'a.date_submitted';
720  case 'section': return 'section_abbrev';
721  case 'authors': return 'author_name';
722  case 'title': return 'submission_clean_title';
723  case 'active': return 'a.submission_progress';
724  case 'subCopyedit': return 'copyedit_completed';
725  case 'subLayout': return 'layout_completed';
726  case 'subProof': return 'proofread_completed';
727  case 'status': return 'a.status';
728  default: return null;
729  }
730  }
731 }
732 
733 ?>
& getEditorSubmissions($journalId, $sectionId, $editorId, $searchField=null, $searchMatch=null, $search=null, $dateField=null, $dateFrom=null, $dateTo=null, $rangeInfo=null, $sortBy=null, $sortDirection=SORT_DIRECTION_ASC)
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:29
insertEditorSubmission(&$editorSubmission)
transferEditorDecisions($oldUserId, $newUserId)
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:83
getInsertId($table= '', $id= '', $callHooks=true)
Definition: DAO.inc.php:252
& retrieveRange($sql, $params=false, $dbResultRange=null, $callHooks=true)
Definition: DAO.inc.php:176
& _getUnfilteredEditorSubmissions($journalId, $sectionId=0, $editorId=0, $searchField=null, $searchMatch=null, $search=null, $dateField=null, $dateFrom=null, $dateTo=null, $additionalWhereSql, $rangeInfo=null, $sortBy=null, $sortDirection=SORT_DIRECTION_ASC)
concat()
Definition: DAO.inc.php:52
getEditorDecisions($articleId, $round=null)
& getEditorSubmissionsInReview($journalId, $sectionId, $editorId, $searchField=null, $searchMatch=null, $search=null, $dateField=null, $dateFrom=null, $dateTo=null, $rangeInfo=null, $sortBy=null, $sortDirection=SORT_DIRECTION_ASC)
Operations for retrieving and modifying EditorSubmission objects.
Wrapper around ADORecordSet providing &quot;factory&quot; features for generating objects from DAOs...
& getDAO($name, $dbconn=null)
& getEditorSubmissionsCount($journalId)
_generateUserNameSearchSQL($search, $searchMatch, $prefix, &$params)
EditorSubmission class.
& getEditorSubmissionsArchives($journalId, $sectionId, $editorId, $searchField=null, $searchMatch=null, $search=null, $dateField=null, $dateFrom=null, $dateTo=null, $rangeInfo=null, $sortBy=null, $sortDirection=SORT_DIRECTION_ASC)
call($hookName, $args=null)
& getUsersNotAssignedToArticle($journalId, $articleId, $roleId, $searchType=null, $search=null, $searchMatch=null, $rangeInfo=null)
datetimeToDB($dt)
Definition: DAO.inc.php:296
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:211
getDirectionMapping($direction)
Definition: DAO.inc.php:588
& getEditorSubmissionsUnassigned($journalId, $sectionId, $editorId, $searchField=null, $searchMatch=null, $search=null, $dateField=null, $dateFrom=null, $dateTo=null, $rangeInfo=null, $sortBy=null, $sortDirection=SORT_DIRECTION_ASC)
& getEditorSubmissionsInEditing($journalId, $sectionId, $editorId, $searchField=null, $searchMatch=null, $search=null, $dateField=null, $dateFrom=null, $dateTo=null, $rangeInfo=null, $sortBy=null, $sortDirection=SORT_DIRECTION_ASC)
updateEditorSubmission(&$editorSubmission)