Open Journal Systems  2.4.4
 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  $templateMgr =& TemplateManager::getManager();
90  $templateMgr->assign('pageToDisplay', $page);
91  $templateMgr->assign_by_ref('submissions', $submissions);
92 
93  // Set search parameters
94  $duplicateParameters = array(
95  'searchField', 'searchMatch', 'search',
96  'dateFromMonth', 'dateFromDay', 'dateFromYear',
97  'dateToMonth', 'dateToDay', 'dateToYear',
98  'dateSearchField'
99  );
100  foreach ($duplicateParameters as $param)
101  $templateMgr->assign($param, $request->getUserVar($param));
102 
103  $templateMgr->assign('dateFrom', $fromDate);
104  $templateMgr->assign('dateTo', $toDate);
105  $templateMgr->assign('fieldOptions', array(
106  SUBMISSION_FIELD_TITLE => 'article.title',
107  SUBMISSION_FIELD_ID => 'article.submissionId',
108  SUBMISSION_FIELD_AUTHOR => 'user.role.author',
109  SUBMISSION_FIELD_EDITOR => 'user.role.editor'
110  ));
111  $templateMgr->assign('dateFieldOptions', array(
112  SUBMISSION_FIELD_DATE_SUBMITTED => 'submissions.submitted',
113  SUBMISSION_FIELD_DATE_COPYEDIT_COMPLETE => 'submissions.copyeditComplete',
114  SUBMISSION_FIELD_DATE_LAYOUT_COMPLETE => 'submissions.layoutComplete',
115  SUBMISSION_FIELD_DATE_PROOFREADING_COMPLETE => 'submissions.proofreadingComplete'
116  ));
117 
118  import('classes.issue.IssueAction');
119  $issueAction = new IssueAction();
120  $templateMgr->register_function('print_issue_id', array($issueAction, 'smartyPrintIssueId'));
121  $templateMgr->assign('helpTopicId', 'editorial.layoutEditorsRole.submissions');
122  $templateMgr->assign('sort', $sort);
123  $templateMgr->assign('sortDirection', $sortDirection);
124  $templateMgr->display('layoutEditor/submissions.tpl');
125  }
126 
132  function futureIssues($args, &$request) {
133  $this->validate($request);
134  $this->setupTemplate(true);
135 
136  $journal =& $request->getJournal();
137  $issueDao =& DAORegistry::getDAO('IssueDAO');
138  $rangeInfo = $this->getRangeInfo('issues');
139  $templateMgr =& TemplateManager::getManager();
140  $templateMgr->assign_by_ref('issues', $issueDao->getUnpublishedIssues($journal->getId(), $rangeInfo));
141  $templateMgr->assign('helpTopicId', 'publishing.index');
142  $templateMgr->display('layoutEditor/futureIssues.tpl');
143  }
144 
150  function backIssues($args, &$request) {
151  $this->validate($request);
152  $this->setupTemplate(true);
153 
154  $journal =& $request->getJournal();
155  $issueDao =& DAORegistry::getDAO('IssueDAO');
156 
157  $rangeInfo = $this->getRangeInfo('issues');
158  $sort = $request->getUserVar('sort');
159  $sort = isset($sort) ? $sort : 'title';
160  $sortDirection = $request->getUserVar('sortDirection');
161 
162  $templateMgr =& TemplateManager::getManager();
163  $templateMgr->assign_by_ref('issues', $issueDao->getPublishedIssues($journal->getId(), $rangeInfo));
164 
165  $allIssuesIterator = $issueDao->getPublishedIssues($journal->getId());
166  $issueMap = array();
167  while ($issue =& $allIssuesIterator->next()) {
168  $issueMap[$issue->getId()] = $issue->getIssueIdentification();
169  unset($issue);
170  }
171  $templateMgr->assign('allIssues', $issueMap);
172 
173  $currentIssue =& $issueDao->getCurrentIssue($journal->getId());
174  $currentIssueId = $currentIssue?$currentIssue->getId():null;
175  $templateMgr->assign('currentIssueId', $currentIssueId);
176 
177  $templateMgr->assign('helpTopicId', 'publishing.index');
178  $templateMgr->assign('usesCustomOrdering', $issueDao->customIssueOrderingExists($journal->getId()));
179  $templateMgr->assign('sort', $sort);
180  $templateMgr->assign('sortDirection', $sortDirection);
181  $templateMgr->display('layoutEditor/backIssues.tpl');
182  }
183 
189  function completeProofreader($args, &$request) {
190  $articleId = (int) $request->getUserVar('articleId');
191 
192  $this->validate($request, $articleId);
193  $this->setupTemplate($request, true);
194 
195  // set the date notified for this signoff so proofreading can no longer be initiated.
196  $signoffDao =& DAORegistry::getDAO('SignoffDAO');
197  $signoff = $signoffDao->build('SIGNOFF_PROOFREADING_PROOFREADER', ASSOC_TYPE_ARTICLE, $articleId);
198  $signoff->setDateNotified(Core::getCurrentDate());
199  $signoffDao->updateObject($signoff);
200 
201  $signoff = $signoffDao->build('SIGNOFF_PROOFREADING_LAYOUT', ASSOC_TYPE_ARTICLE, $articleId);
202  $signoff->setDateCompleted(Core::getCurrentDate());
203  $signoffDao->updateObject($signoff);
204 
205  if (ProofreaderAction::proofreadEmail($articleId, 'PROOFREAD_COMPLETE', $request, $request->getUserVar('send')?'':$request->url(null, 'layoutEditor', 'completeProofreader'))) {
206  $request->redirect(null, null, 'submission', $articleId);
207  }
208  }
209 
216  function setupTemplate($subclass = false, $articleId = 0, $parentPage = null) {
217  parent::setupTemplate();
218  AppLocale::requireComponents(LOCALE_COMPONENT_PKP_SUBMISSION, LOCALE_COMPONENT_OJS_EDITOR);
219  $templateMgr =& TemplateManager::getManager();
220  $pageHierarchy = $subclass ? array(array(Request::url(null, 'user'), 'navigation.user'), array(Request::url(null, 'layoutEditor'), 'user.role.layoutEditor'))
221  : array(array(Request::url(null, 'user'), 'navigation.user'));
222 
223  import('classes.submission.sectionEditor.SectionEditorAction');
224  $submissionCrumb = SectionEditorAction::submissionBreadcrumb($articleId, $parentPage, 'layoutEditor');
225  if (isset($submissionCrumb)) {
226  $pageHierarchy = array_merge($pageHierarchy, $submissionCrumb);
227  }
228  $templateMgr->assign('pageHierarchy', $pageHierarchy);
229  }
230 
236  function instructions($args, &$request) {
237  $this->setupTemplate();
238  import('classes.submission.proofreader.ProofreaderAction');
239  if (!isset($args[0]) || !LayoutEditorAction::instructions($args[0], array('layout', 'proof', 'referenceLinking'))) {
240  $request->redirect(null, $request->getRequestedPage());
241  }
242  }
243 
244 
245  //
246  // Validation
247  //
248 
249 
257  function validate($request, $articleId = null, $checkEdit = false) {
258  parent::validate();
259 
260  if ($articleId !== null) {
261  $isValid = false;
262 
263  $journal =& $request->getJournal();
264  $user =& $request->getUser();
265 
266  $layoutDao =& DAORegistry::getDAO('LayoutEditorSubmissionDAO');
267  $signoffDao =& DAORegistry::getDAO('SignoffDAO');
268  $submission =& $layoutDao->getSubmission($articleId, $journal->getId());
269 
270  if (isset($submission)) {
271  $layoutSignoff = $signoffDao->getBySymbolic('SIGNOFF_LAYOUT', ASSOC_TYPE_ARTICLE, $articleId);
272  if (!isset($layoutSignoff)) $isValid = false;
273  elseif ($layoutSignoff->getUserId() == $user->getId()) {
274  if ($checkEdit) {
275  $isValid = $this->_layoutEditingEnabled($submission);
276  } else {
277  $isValid = true;
278  }
279  }
280  }
281 
282  if (!$isValid) {
283  $request->redirect(null, $request->getRequestedPage());
284  }
285 
286  $this->submission =& $submission;
287  return true;
288  }
289  }
290 
299  $signoffDao =& DAORegistry::getDAO('SignoffDAO');
300  $layoutEditorProofreadSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_LAYOUT', ASSOC_TYPE_ARTICLE, $submission->getId());
301  $layoutSignoff = $signoffDao->build('SIGNOFF_LAYOUT', ASSOC_TYPE_ARTICLE, $submission->getId());
302 
303  return(($layoutSignoff->getDateNotified() != null
304  && $layoutSignoff->getDateCompleted() == null)
305  || ($layoutEditorProofreadSignoff->getDateNotified() != null
306  && $layoutEditorProofreadSignoff->getDateCompleted() == null));
307  }
308 }
309 
310 ?>
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.