Open Journal Systems  2.4.4
 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  $templateMgr =& TemplateManager::getManager();
75  $templateMgr->assign('pageToDisplay', $page);
76  $templateMgr->assign_by_ref('submissions', $submissions);
77 
78  // Set search parameters
79  $duplicateParameters = array(
80  'searchField', 'searchMatch', 'search',
81  'dateFromMonth', 'dateFromDay', 'dateFromYear',
82  'dateToMonth', 'dateToDay', 'dateToYear',
83  'dateSearchField'
84  );
85  foreach ($duplicateParameters as $param)
86  $templateMgr->assign($param, $request->getUserVar($param));
87 
88  $templateMgr->assign('dateFrom', $fromDate);
89  $templateMgr->assign('dateTo', $toDate);
90  $templateMgr->assign('fieldOptions', array(
91  SUBMISSION_FIELD_TITLE => 'article.title',
92  SUBMISSION_FIELD_ID => 'article.submissionId',
93  SUBMISSION_FIELD_AUTHOR => 'user.role.author',
94  SUBMISSION_FIELD_EDITOR => 'user.role.editor'
95  ));
96  $templateMgr->assign('dateFieldOptions', array(
97  SUBMISSION_FIELD_DATE_SUBMITTED => 'submissions.submitted',
98  SUBMISSION_FIELD_DATE_COPYEDIT_COMPLETE => 'submissions.copyeditComplete',
99  SUBMISSION_FIELD_DATE_LAYOUT_COMPLETE => 'submissions.layoutComplete',
100  SUBMISSION_FIELD_DATE_PROOFREADING_COMPLETE => 'submissions.proofreadingComplete'
101  ));
102 
103  import('classes.issue.IssueAction');
104  $issueAction = new IssueAction();
105  $templateMgr->register_function('print_issue_id', array($issueAction, 'smartyPrintIssueId'));
106  $templateMgr->assign('helpTopicId', 'editorial.copyeditorsRole.submissions');
107  $templateMgr->assign('sort', $sort);
108  $templateMgr->assign('sortDirection', $sortDirection);
109  $templateMgr->display('copyeditor/index.tpl');
110  }
111 
116  function setupTemplate($subclass = false, $articleId = 0, $parentPage = null) {
117  parent::setupTemplate();
118  AppLocale::requireComponents(LOCALE_COMPONENT_PKP_SUBMISSION);
119  $templateMgr =& TemplateManager::getManager();
120  $pageHierarchy = $subclass ? array(array(Request::url(null, 'user'), 'navigation.user'), array(Request::url(null, 'copyeditor'), 'user.role.copyeditor'))
121  : array(array('user', 'navigation.user'), array('copyeditor', 'user.role.copyeditor'));
122 
123  import('classes.submission.sectionEditor.SectionEditorAction');
124  $submissionCrumb = SectionEditorAction::submissionBreadcrumb($articleId, $parentPage, 'copyeditor');
125  if (isset($submissionCrumb)) {
126  $pageHierarchy = array_merge($pageHierarchy, $submissionCrumb);
127  }
128  $templateMgr->assign('pageHierarchy', $pageHierarchy);
129  }
130 
136  function instructions($args, &$request) {
137  $this->setupTemplate();
138  import('classes.submission.proofreader.ProofreaderAction');
139  if (!isset($args[0]) || !ProofreaderAction::instructions($args[0], array('copy'))) {
140  $request->redirect(null, $request->getRequestedPage());
141  }
142  }
143 
150  function validate($request, $articleId = null) {
151  parent::validate();
152 
153  if ($articleId !== null) {
154  $copyeditorSubmissionDao =& DAORegistry::getDAO('CopyeditorSubmissionDAO');
155  $journal =& $request->getJournal();
156  $user =& $request->getUser();
157 
158  $isValid = true;
159 
160  $copyeditorSubmission =& $copyeditorSubmissionDao->getCopyeditorSubmission($articleId, $user->getId());
161 
162  if ($copyeditorSubmission == null) {
163  $isValid = false;
164  } else {
165  if ($copyeditorSubmission->getJournalId() != $journal->getId()) {
166  $isValid = false;
167  } else {
168  if ($copyeditorSubmission->getUserIdBySignoffType('SIGNOFF_COPYEDITING_INITIAL') != $user->getId()) {
169  $isValid = false;
170  }
171  }
172  }
173 
174  if (!$isValid) {
175  $request->redirect(null, $request->getRequestedPage());
176  }
177 
178  $this->submission =& $copyeditorSubmission;
179  }
180  }
181 }
182 
183 ?>
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.