Open Journal Systems  2.4.8
 All Classes Namespaces Functions Variables Groups Pages
CopyeditorHandler.inc.php
1 <?php
2 
16 import('classes.submission.copyeditor.CopyeditorAction');
17 import('classes.handler.Handler');
18 
19 class CopyeditorHandler extends Handler {
22 
26  function CopyeditorHandler() {
27  parent::Handler();
28  $this->addCheck(new HandlerValidatorJournal($this));
29  $this->addCheck(new HandlerValidatorRoles($this, true, null, null, array(ROLE_ID_COPYEDITOR)));
30  }
31 
37  function index($args, &$request) {
38  $this->validate($request);
39  $this->setupTemplate();
40 
41  $journal =& $request->getJournal();
42  $user =& $request->getUser();
43  $copyeditorSubmissionDao =& DAORegistry::getDAO('CopyeditorSubmissionDAO');
44 
45  // Get the user's search conditions, if any
46  $searchField = $request->getUserVar('searchField');
47  $dateSearchField = $request->getUserVar('dateSearchField');
48  $searchMatch = $request->getUserVar('searchMatch');
49  $search = $request->getUserVar('search');
50 
51  $fromDate = $request->getUserDateVar('dateFrom', 1, 1);
52  if ($fromDate !== null) $fromDate = date('Y-m-d H:i:s', $fromDate);
53  $toDate = $request->getUserDateVar('dateTo', 32, 12, null, 23, 59, 59);
54  if ($toDate !== null) $toDate = date('Y-m-d H:i:s', $toDate);
55 
56  $rangeInfo = $this->getRangeInfo('submissions');
57 
58  $page = isset($args[0]) ? $args[0] : '';
59  switch($page) {
60  case 'completed':
61  $active = false;
62  break;
63  default:
64  $page = 'active';
65  $active = true;
66  }
67 
68  $sort = $request->getUserVar('sort');
69  $sort = isset($sort) ? $sort : 'title';
70  $sortDirection = $request->getUserVar('sortDirection');
71 
72  $submissions = $copyeditorSubmissionDao->getCopyeditorSubmissionsByCopyeditorId($user->getId(), $journal->getId(), $searchField, $searchMatch, $search, $dateSearchField, $fromDate, $toDate, $active, $rangeInfo, $sort, $sortDirection);
73 
74  // If only result is returned from a search, fast-forward to it
75  if ($search && $submissions && $submissions->getCount() == 1) {
76  $submission =& $submissions->next();
77  $request->redirect(null, null, 'submission', array($submission->getId()));
78  }
79 
80  $templateMgr =& TemplateManager::getManager();
81  $templateMgr->assign('pageToDisplay', $page);
82  $templateMgr->assign_by_ref('submissions', $submissions);
83 
84  // Set search parameters
85  $duplicateParameters = array(
86  'searchField', 'searchMatch', 'search',
87  'dateFromMonth', 'dateFromDay', 'dateFromYear',
88  'dateToMonth', 'dateToDay', 'dateToYear',
89  'dateSearchField'
90  );
91  foreach ($duplicateParameters as $param)
92  $templateMgr->assign($param, $request->getUserVar($param));
93 
94  $templateMgr->assign('dateFrom', $fromDate);
95  $templateMgr->assign('dateTo', $toDate);
96  $templateMgr->assign('fieldOptions', array(
97  SUBMISSION_FIELD_TITLE => 'article.title',
98  SUBMISSION_FIELD_ID => 'article.submissionId',
99  SUBMISSION_FIELD_AUTHOR => 'user.role.author',
100  SUBMISSION_FIELD_EDITOR => 'user.role.editor'
101  ));
102  $templateMgr->assign('dateFieldOptions', array(
103  SUBMISSION_FIELD_DATE_SUBMITTED => 'submissions.submitted',
104  SUBMISSION_FIELD_DATE_COPYEDIT_COMPLETE => 'submissions.copyeditComplete',
105  SUBMISSION_FIELD_DATE_LAYOUT_COMPLETE => 'submissions.layoutComplete',
106  SUBMISSION_FIELD_DATE_PROOFREADING_COMPLETE => 'submissions.proofreadingComplete'
107  ));
108 
109  import('classes.issue.IssueAction');
110  $issueAction = new IssueAction();
111  $templateMgr->register_function('print_issue_id', array($issueAction, 'smartyPrintIssueId'));
112  $templateMgr->assign('helpTopicId', 'editorial.copyeditorsRole.submissions');
113  $templateMgr->assign('sort', $sort);
114  $templateMgr->assign('sortDirection', $sortDirection);
115  $templateMgr->display('copyeditor/index.tpl');
116  }
117 
122  function setupTemplate($subclass = false, $articleId = 0, $parentPage = null) {
123  parent::setupTemplate();
124  AppLocale::requireComponents(LOCALE_COMPONENT_PKP_SUBMISSION);
125  $templateMgr =& TemplateManager::getManager();
126  $pageHierarchy = $subclass ? array(array(Request::url(null, 'user'), 'navigation.user'), array(Request::url(null, 'copyeditor'), 'user.role.copyeditor'))
127  : array(array('user', 'navigation.user'), array('copyeditor', 'user.role.copyeditor'));
128 
129  import('classes.submission.sectionEditor.SectionEditorAction');
130  $submissionCrumb = SectionEditorAction::submissionBreadcrumb($articleId, $parentPage, 'copyeditor');
131  if (isset($submissionCrumb)) {
132  $pageHierarchy = array_merge($pageHierarchy, $submissionCrumb);
133  }
134  $templateMgr->assign('pageHierarchy', $pageHierarchy);
135  }
136 
142  function instructions($args, &$request) {
143  $this->setupTemplate();
144  import('classes.submission.proofreader.ProofreaderAction');
145  if (!isset($args[0]) || !ProofreaderAction::instructions($args[0], array('copy'))) {
146  $request->redirect(null, $request->getRequestedPage());
147  }
148  }
149 
156  function validate($request, $articleId = null) {
157  parent::validate();
158 
159  if ($articleId !== null) {
160  $copyeditorSubmissionDao =& DAORegistry::getDAO('CopyeditorSubmissionDAO');
161  $journal =& $request->getJournal();
162  $user =& $request->getUser();
163 
164  $isValid = true;
165 
166  $copyeditorSubmission =& $copyeditorSubmissionDao->getCopyeditorSubmission($articleId, $user->getId());
167 
168  if ($copyeditorSubmission == null) {
169  $isValid = false;
170  } else {
171  if ($copyeditorSubmission->getJournalId() != $journal->getId()) {
172  $isValid = false;
173  } else {
174  if ($copyeditorSubmission->getUserIdBySignoffType('SIGNOFF_COPYEDITING_INITIAL') != $user->getId()) {
175  $isValid = false;
176  }
177  }
178  }
179 
180  if (!$isValid) {
181  $request->redirect(null, $request->getRequestedPage());
182  }
183 
184  $this->submission =& $copyeditorSubmission;
185  }
186  }
187 }
188 
189 ?>
submissionBreadcrumb($articleId, $parentPage, $section)
setupTemplate($subclass=false, $articleId=0, $parentPage=null)
& getRangeInfo($rangeName, $contextData=null)
index($args, &$request)
IssueAction class.
validate($request, $articleId=null)
Base request handler application class.
Definition: Handler.inc.php:21
addCheck(&$handlerValidator)
& getDAO($name, $dbconn=null)
url($journalPath=null, $page=null, $op=null, $path=null, $params=null, $anchor=null, $escape=false)
Definition: Request.inc.php:88
instructions($type, $allowed=array('copy', 'layout', 'proof', 'referenceLinking'))
Definition: Action.inc.php:202
instructions($args, &$request)
Class to validate if a Journal is present.
Handle requests for copyeditor functions.