Open Journal Systems  2.4.8
 All Classes Namespaces Functions Variables Groups Pages
LayoutEditorHandler.inc.php
1 <?php
2 
16 import('classes.submission.layoutEditor.LayoutEditorAction');
17 import('classes.submission.proofreader.ProofreaderAction');
18 import('classes.handler.Handler');
19 
23 
27  function LayoutEditorHandler() {
28  parent::Handler();
29 
30  $this->addCheck(new HandlerValidatorJournal($this));
31  $this->addCheck(new HandlerValidatorRoles($this, true, null, null, array(ROLE_ID_LAYOUT_EDITOR)));
32  }
33 
39  function index($args, &$request) {
40  $this->validate($request);
41  $this->setupTemplate();
42 
43  $templateMgr =& TemplateManager::getManager();
44  $templateMgr->assign('helpTopicId', 'editorial.layoutEditorsRole');
45  $templateMgr->display('layoutEditor/index.tpl');
46  }
47 
53  function submissions($args, &$request) {
54  $this->validate($request);
55  $this->setupTemplate(true);
56 
57  $journal =& $request->getJournal();
58  $user =& $request->getUser();
59  $layoutEditorSubmissionDao =& DAORegistry::getDAO('LayoutEditorSubmissionDAO');
60 
61  $page = isset($args[0]) ? $args[0] : '';
62  switch($page) {
63  case 'completed':
64  $active = false;
65  break;
66  default:
67  $page = 'active';
68  $active = true;
69  }
70 
71  $sort = $request->getUserVar('sort');
72  $sort = isset($sort) ? $sort : 'title';
73  $sortDirection = $request->getUserVar('sortDirection');
74 
75  // Get the user's search conditions, if any
76  $searchField = $request->getUserVar('searchField');
77  $dateSearchField = $request->getUserVar('dateSearchField');
78  $searchMatch = $request->getUserVar('searchMatch');
79  $search = $request->getUserVar('search');
80 
81  $fromDate = $request->getUserDateVar('dateFrom', 1, 1);
82  if ($fromDate !== null) $fromDate = date('Y-m-d H:i:s', $fromDate);
83  $toDate = $request->getUserDateVar('dateTo', 32, 12, null, 23, 59, 59);
84  if ($toDate !== null) $toDate = date('Y-m-d H:i:s', $toDate);
85 
86  $rangeInfo = $this->getRangeInfo('submissions');
87  $submissions = $layoutEditorSubmissionDao->getSubmissions($user->getId(), $journal->getId(), $searchField, $searchMatch, $search, $dateSearchField, $fromDate, $toDate, $active, $rangeInfo, $sort, $sortDirection);
88 
89  // If only result is returned from a search, fast-forward to it
90  if ($search && $submissions && $submissions->getCount() == 1) {
91  $submission =& $submissions->next();
92  $request->redirect(null, null, 'submission', array($submission->getId()));
93  }
94 
95  $templateMgr =& TemplateManager::getManager();
96  $templateMgr->assign('pageToDisplay', $page);
97  $templateMgr->assign_by_ref('submissions', $submissions);
98 
99  // Set search parameters
100  $duplicateParameters = array(
101  'searchField', 'searchMatch', 'search',
102  'dateFromMonth', 'dateFromDay', 'dateFromYear',
103  'dateToMonth', 'dateToDay', 'dateToYear',
104  'dateSearchField'
105  );
106  foreach ($duplicateParameters as $param)
107  $templateMgr->assign($param, $request->getUserVar($param));
108 
109  $templateMgr->assign('dateFrom', $fromDate);
110  $templateMgr->assign('dateTo', $toDate);
111  $templateMgr->assign('fieldOptions', array(
112  SUBMISSION_FIELD_TITLE => 'article.title',
113  SUBMISSION_FIELD_ID => 'article.submissionId',
114  SUBMISSION_FIELD_AUTHOR => 'user.role.author',
115  SUBMISSION_FIELD_EDITOR => 'user.role.editor'
116  ));
117  $templateMgr->assign('dateFieldOptions', array(
118  SUBMISSION_FIELD_DATE_SUBMITTED => 'submissions.submitted',
119  SUBMISSION_FIELD_DATE_COPYEDIT_COMPLETE => 'submissions.copyeditComplete',
120  SUBMISSION_FIELD_DATE_LAYOUT_COMPLETE => 'submissions.layoutComplete',
121  SUBMISSION_FIELD_DATE_PROOFREADING_COMPLETE => 'submissions.proofreadingComplete'
122  ));
123 
124  import('classes.issue.IssueAction');
125  $issueAction = new IssueAction();
126  $templateMgr->register_function('print_issue_id', array($issueAction, 'smartyPrintIssueId'));
127  $templateMgr->assign('helpTopicId', 'editorial.layoutEditorsRole.submissions');
128  $templateMgr->assign('sort', $sort);
129  $templateMgr->assign('sortDirection', $sortDirection);
130  $templateMgr->display('layoutEditor/submissions.tpl');
131  }
132 
138  function futureIssues($args, &$request) {
139  $this->validate($request);
140  $this->setupTemplate(true);
141 
142  $journal =& $request->getJournal();
143  $issueDao =& DAORegistry::getDAO('IssueDAO');
144  $rangeInfo = $this->getRangeInfo('issues');
145  $templateMgr =& TemplateManager::getManager();
146  $templateMgr->assign_by_ref('issues', $issueDao->getUnpublishedIssues($journal->getId(), $rangeInfo));
147  $templateMgr->assign('helpTopicId', 'publishing.index');
148  $templateMgr->display('layoutEditor/futureIssues.tpl');
149  }
150 
156  function backIssues($args, &$request) {
157  $this->validate($request);
158  $this->setupTemplate(true);
159 
160  $journal =& $request->getJournal();
161  $issueDao =& DAORegistry::getDAO('IssueDAO');
162 
163  $rangeInfo = $this->getRangeInfo('issues');
164  $sort = $request->getUserVar('sort');
165  $sort = isset($sort) ? $sort : 'title';
166  $sortDirection = $request->getUserVar('sortDirection');
167 
168  $templateMgr =& TemplateManager::getManager();
169  $templateMgr->assign_by_ref('issues', $issueDao->getPublishedIssues($journal->getId(), $rangeInfo));
170 
171  $allIssuesIterator = $issueDao->getPublishedIssues($journal->getId());
172  $issueMap = array();
173  while ($issue =& $allIssuesIterator->next()) {
174  $issueMap[$issue->getId()] = $issue->getIssueIdentification();
175  unset($issue);
176  }
177  $templateMgr->assign('allIssues', $issueMap);
178 
179  $currentIssue =& $issueDao->getCurrentIssue($journal->getId());
180  $currentIssueId = $currentIssue?$currentIssue->getId():null;
181  $templateMgr->assign('currentIssueId', $currentIssueId);
182 
183  $templateMgr->assign('helpTopicId', 'publishing.index');
184  $templateMgr->assign('usesCustomOrdering', $issueDao->customIssueOrderingExists($journal->getId()));
185  $templateMgr->assign('sort', $sort);
186  $templateMgr->assign('sortDirection', $sortDirection);
187  $templateMgr->display('layoutEditor/backIssues.tpl');
188  }
189 
195  function completeProofreader($args, &$request) {
196  $articleId = (int) $request->getUserVar('articleId');
197 
198  $this->validate($request, $articleId);
199  $this->setupTemplate($request, true);
200 
201  // set the date notified for this signoff so proofreading can no longer be initiated.
202  $signoffDao =& DAORegistry::getDAO('SignoffDAO');
203  $signoff = $signoffDao->build('SIGNOFF_PROOFREADING_PROOFREADER', ASSOC_TYPE_ARTICLE, $articleId);
204  $signoff->setDateNotified(Core::getCurrentDate());
205  $signoffDao->updateObject($signoff);
206 
207  $signoff = $signoffDao->build('SIGNOFF_PROOFREADING_LAYOUT', ASSOC_TYPE_ARTICLE, $articleId);
208  $signoff->setDateCompleted(Core::getCurrentDate());
209  $signoffDao->updateObject($signoff);
210 
211  if (ProofreaderAction::proofreadEmail($articleId, 'PROOFREAD_COMPLETE', $request, $request->getUserVar('send')?'':$request->url(null, 'layoutEditor', 'completeProofreader'))) {
212  $request->redirect(null, null, 'submission', $articleId);
213  }
214  }
215 
222  function setupTemplate($subclass = false, $articleId = 0, $parentPage = null) {
223  parent::setupTemplate();
224  AppLocale::requireComponents(LOCALE_COMPONENT_PKP_SUBMISSION, LOCALE_COMPONENT_OJS_EDITOR);
225  $templateMgr =& TemplateManager::getManager();
226  $pageHierarchy = $subclass ? array(array(Request::url(null, 'user'), 'navigation.user'), array(Request::url(null, 'layoutEditor'), 'user.role.layoutEditor'))
227  : array(array(Request::url(null, 'user'), 'navigation.user'));
228 
229  import('classes.submission.sectionEditor.SectionEditorAction');
230  $submissionCrumb = SectionEditorAction::submissionBreadcrumb($articleId, $parentPage, 'layoutEditor');
231  if (isset($submissionCrumb)) {
232  $pageHierarchy = array_merge($pageHierarchy, $submissionCrumb);
233  }
234  $templateMgr->assign('pageHierarchy', $pageHierarchy);
235  }
236 
242  function instructions($args, &$request) {
243  $this->setupTemplate();
244  import('classes.submission.proofreader.ProofreaderAction');
245  if (!isset($args[0]) || !LayoutEditorAction::instructions($args[0], array('layout', 'proof', 'referenceLinking'))) {
246  $request->redirect(null, $request->getRequestedPage());
247  }
248  }
249 
250 
251  //
252  // Validation
253  //
254 
255 
263  function validate($request, $articleId = null, $checkEdit = false) {
264  parent::validate();
265 
266  if ($articleId !== null) {
267  $isValid = false;
268 
269  $journal =& $request->getJournal();
270  $user =& $request->getUser();
271 
272  $layoutDao =& DAORegistry::getDAO('LayoutEditorSubmissionDAO');
273  $signoffDao =& DAORegistry::getDAO('SignoffDAO');
274  $submission =& $layoutDao->getSubmission($articleId, $journal->getId());
275 
276  if (isset($submission)) {
277  $layoutSignoff = $signoffDao->getBySymbolic('SIGNOFF_LAYOUT', ASSOC_TYPE_ARTICLE, $articleId);
278  if (!isset($layoutSignoff)) $isValid = false;
279  elseif ($layoutSignoff->getUserId() == $user->getId()) {
280  if ($checkEdit) {
281  $isValid = $this->_layoutEditingEnabled($submission);
282  } else {
283  $isValid = true;
284  }
285  }
286  }
287 
288  if (!$isValid) {
289  $request->redirect(null, $request->getRequestedPage());
290  }
291 
292  $this->submission =& $submission;
293  return true;
294  }
295  }
296 
305  $signoffDao =& DAORegistry::getDAO('SignoffDAO');
306  $layoutEditorProofreadSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_LAYOUT', ASSOC_TYPE_ARTICLE, $submission->getId());
307  $layoutSignoff = $signoffDao->build('SIGNOFF_LAYOUT', ASSOC_TYPE_ARTICLE, $submission->getId());
308 
309  return(($layoutSignoff->getDateNotified() != null
310  && $layoutSignoff->getDateCompleted() == null)
311  || ($layoutEditorProofreadSignoff->getDateNotified() != null
312  && $layoutEditorProofreadSignoff->getDateCompleted() == null));
313  }
314 }
315 
316 ?>
submissionBreadcrumb($articleId, $parentPage, $section)
submissions($args, &$request)
& getRangeInfo($rangeName, $contextData=null)
getCurrentDate($ts=null)
Definition: Core.inc.php:94
proofreadEmail($articleId, $mailType, $request, $actionPath= '')
Handle requests for layout editor functions.
IssueAction class.
completeProofreader($args, &$request)
Base request handler application class.
Definition: Handler.inc.php:21
setupTemplate($subclass=false, $articleId=0, $parentPage=null)
addCheck(&$handlerValidator)
& getDAO($name, $dbconn=null)
futureIssues($args, &$request)
instructions($args, &$request)
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
validate($request, $articleId=null, $checkEdit=false)
Class to validate if a Journal is present.