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