Open Journal Systems  2.4.4
 All Classes Namespaces Functions Variables Groups Pages
ProofreaderHandler.inc.php
1 <?php
2 
16 import('classes.submission.proofreader.ProofreaderAction');
17 import('classes.handler.Handler');
18 
19 class ProofreaderHandler extends Handler {
22 
26  function ProofreaderHandler() {
27  parent::Handler();
28 
29  $this->addCheck(new HandlerValidatorJournal($this));
30  $this->addCheck(new HandlerValidatorRoles($this, true, null, null, array(ROLE_ID_PROOFREADER)));
31  }
32 
38  function index($args, &$request) {
39  $this->validate($request);
40  $this->setupTemplate();
41 
42  $journal =& $request->getJournal();
43  $user =& $request->getUser();
44  $proofreaderSubmissionDao =& DAORegistry::getDAO('ProofreaderSubmissionDAO');
45 
46  // Get the user's search conditions, if any
47  $searchField = $request->getUserVar('searchField');
48  $dateSearchField = $request->getUserVar('dateSearchField');
49  $searchMatch = $request->getUserVar('searchMatch');
50  $search = $request->getUserVar('search');
51 
52  $fromDate = $request->getUserDateVar('dateFrom', 1, 1);
53  if ($fromDate !== null) $fromDate = date('Y-m-d H:i:s', $fromDate);
54  $toDate = $request->getUserDateVar('dateTo', 32, 12, null, 23, 59, 59);
55  if ($toDate !== null) $toDate = date('Y-m-d H:i:s', $toDate);
56 
57  $rangeInfo = $this->getRangeInfo('submissions');
58 
59  $page = isset($args[0]) ? $args[0] : '';
60  switch($page) {
61  case 'completed':
62  $active = false;
63  break;
64  default:
65  $page = 'active';
66  $active = true;
67  }
68 
69  $sort = $request->getUserVar('sort');
70  $sort = isset($sort) ? $sort : 'title';
71  $sortDirection = $request->getUserVar('sortDirection');
72 
73  $submissions = $proofreaderSubmissionDao->getSubmissions($user->getId(), $journal->getId(), $searchField, $searchMatch, $search, $dateSearchField, $fromDate, $toDate, $active, $rangeInfo, $sort, $sortDirection);
74 
75  $templateMgr =& TemplateManager::getManager();
76  $templateMgr->assign('pageToDisplay', $page);
77  $templateMgr->assign_by_ref('submissions', $submissions);
78 
79  // Set search parameters
80  $duplicateParameters = array(
81  'searchField', 'searchMatch', 'search',
82  'dateFromMonth', 'dateFromDay', 'dateFromYear',
83  'dateToMonth', 'dateToDay', 'dateToYear',
84  'dateSearchField'
85  );
86  foreach ($duplicateParameters as $param)
87  $templateMgr->assign($param, $request->getUserVar($param));
88 
89  $templateMgr->assign('dateFrom', $fromDate);
90  $templateMgr->assign('dateTo', $toDate);
91  $templateMgr->assign('fieldOptions', array(
92  SUBMISSION_FIELD_TITLE => 'article.title',
93  SUBMISSION_FIELD_ID => 'article.submissionId',
94  SUBMISSION_FIELD_AUTHOR => 'user.role.author',
95  SUBMISSION_FIELD_EDITOR => 'user.role.editor'
96  ));
97  $templateMgr->assign('dateFieldOptions', array(
98  SUBMISSION_FIELD_DATE_SUBMITTED => 'submissions.submitted',
99  SUBMISSION_FIELD_DATE_COPYEDIT_COMPLETE => 'submissions.copyeditComplete',
100  SUBMISSION_FIELD_DATE_LAYOUT_COMPLETE => 'submissions.layoutComplete',
101  SUBMISSION_FIELD_DATE_PROOFREADING_COMPLETE => 'submissions.proofreadingComplete'
102  ));
103 
104  import('classes.issue.IssueAction');
105  $issueAction = new IssueAction();
106  $templateMgr->register_function('print_issue_id', array($issueAction, 'smartyPrintIssueId'));
107  $templateMgr->assign('helpTopicId', 'editorial.proofreadersRole.submissions');
108  $templateMgr->assign('sort', $sort);
109  $templateMgr->assign('sortDirection', $sortDirection);
110  $templateMgr->display('proofreader/index.tpl');
111  }
112 
117  function setupTemplate($subclass = false, $articleId = 0, $parentPage = null, $showSidebar = true) {
118  parent::setupTemplate();
119  AppLocale::requireComponents(LOCALE_COMPONENT_PKP_SUBMISSION, LOCALE_COMPONENT_OJS_EDITOR);
120  $templateMgr =& TemplateManager::getManager();
121  $pageHierarchy = $subclass ? array(array(Request::url(null, 'user'), 'navigation.user'), array(Request::url(null, 'proofreader'), 'user.role.proofreader'))
122  : array(array(Request::url(null, 'user'), 'navigation.user'), array(Request::url(null, 'proofreader'), 'user.role.proofreader'));
123 
124  import('classes.submission.sectionEditor.SectionEditorAction');
125  $submissionCrumb = SectionEditorAction::submissionBreadcrumb($articleId, $parentPage, 'proofreader');
126  if (isset($submissionCrumb)) {
127  $pageHierarchy = array_merge($pageHierarchy, $submissionCrumb);
128  }
129  $templateMgr->assign('pageHierarchy', $pageHierarchy);
130  }
131 
137  function instructions($args, &$request) {
138  $this->setupTemplate();
139  if (!isset($args[0]) || !ProofreaderAction::instructions($args[0], array('proof'))) {
140  $request->redirect(null, $request->getRequestedPage());
141  }
142  }
143 
150  function validate(&$request, $articleId = null) {
151  parent::validate();
152 
153  if ($articleId !== null) {
154  $isValid = false;
155 
156  $journal =& $request->getJournal();
157  $user =& $request->getUser();
158 
159  $proofreaderDao =& DAORegistry::getDAO('ProofreaderSubmissionDAO');
160  $signoffDao =& DAORegistry::getDAO('SignoffDAO');
161  $submission =& $proofreaderDao->getSubmission($articleId, $journal->getId());
162 
163  if (isset($submission)) {
164  $proofSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_PROOFREADER', ASSOC_TYPE_ARTICLE, $articleId);
165  if ($proofSignoff->getUserId() == $user->getId()) {
166  $isValid = true;
167  }
168  }
169 
170  if (!$isValid) {
171  $request->redirect(null, $request->getRequestedPage());
172  }
173 
174  $this->submission =& $submission;
175  }
176 
177  return true;
178  }
179 }
180 
181 ?>
submissionBreadcrumb($articleId, $parentPage, $section)
instructions($args, &$request)
& getRangeInfo($rangeName, $contextData=null)
Handle requests for proofreader functions.
setupTemplate($subclass=false, $articleId=0, $parentPage=null, $showSidebar=true)
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
Class to validate if a Journal is present.