Open Journal Systems  2.4.4
 All Classes Namespaces Functions Variables Groups Pages
SectionEditorHandler.inc.php
1 <?php
2 
16 // Filter section
17 define('FILTER_SECTION_ALL', 0);
18 
19 import('classes.submission.sectionEditor.SectionEditorAction');
20 import('classes.handler.Handler');
21 
25 
29  function SectionEditorHandler() {
30  parent::Handler();
31 
32  $this->addCheck(new HandlerValidatorJournal($this));
33  // FIXME This is kind of evil
34  $page = Request::getRequestedPage();
35  if ( $page == 'sectionEditor' )
36  $this->addCheck(new HandlerValidatorRoles($this, true, null, null, array(ROLE_ID_SECTION_EDITOR)));
37  elseif ( $page == 'editor' )
38  $this->addCheck(new HandlerValidatorRoles($this, true, null, null, array(ROLE_ID_EDITOR)));
39 
40  }
41 
47  function index($args, &$request) {
48  $this->validate();
49  $this->setupTemplate();
50 
51  $journal =& $request->getJournal();
52  $journalId = $journal->getId();
53  $user =& $request->getUser();
54 
55  $rangeInfo = $this->getRangeInfo('submissions');
56 
57  // Get the user's search conditions, if any
58  $searchField = $request->getUserVar('searchField');
59  $dateSearchField = $request->getUserVar('dateSearchField');
60  $searchMatch = $request->getUserVar('searchMatch');
61  $search = $request->getUserVar('search');
62 
63  $fromDate = $request->getUserDateVar('dateFrom', 1, 1);
64  if ($fromDate !== null) $fromDate = date('Y-m-d H:i:s', $fromDate);
65  $toDate = $request->getUserDateVar('dateTo', 32, 12, null, 23, 59, 59);
66  if ($toDate !== null) $toDate = date('Y-m-d H:i:s', $toDate);
67 
68  $sectionDao =& DAORegistry::getDAO('SectionDAO');
69  $sectionEditorSubmissionDao =& DAORegistry::getDAO('SectionEditorSubmissionDAO');
70 
71  $page = isset($args[0]) ? $args[0] : '';
72  $sections =& $sectionDao->getSectionTitles($journal->getId());
73 
74  $sort = $request->getUserVar('sort');
75  $sort = isset($sort) ? $sort : 'id';
76  $sortDirection = $request->getUserVar('sortDirection');
77 
78  $filterSectionOptions = array(
79  FILTER_SECTION_ALL => AppLocale::Translate('editor.allSections')
80  ) + $sections;
81 
82  switch($page) {
83  case 'submissionsInEditing':
84  $functionName = 'getSectionEditorSubmissionsInEditing';
85  $helpTopicId = 'editorial.sectionEditorsRole.submissions.inEditing';
86  break;
87  case 'submissionsArchives':
88  $functionName = 'getSectionEditorSubmissionsArchives';
89  $helpTopicId = 'editorial.sectionEditorsRole.submissions.archives';
90  break;
91  default:
92  $page = 'submissionsInReview';
93  $functionName = 'getSectionEditorSubmissionsInReview';
94  $helpTopicId = 'editorial.sectionEditorsRole.submissions.inReview';
95  }
96 
97  $filterSection = $request->getUserVar('filterSection');
98  if ($filterSection != '' && array_key_exists($filterSection, $filterSectionOptions)) {
99  $user->updateSetting('filterSection', $filterSection, 'int', $journalId);
100  } else {
101  $filterSection = $user->getSetting('filterSection', $journalId);
102  if ($filterSection == null) {
103  $filterSection = FILTER_SECTION_ALL;
104  $user->updateSetting('filterSection', $filterSection, 'int', $journalId);
105  }
106  }
107 
108  $submissions =& $sectionEditorSubmissionDao->$functionName(
109  $user->getId(),
110  $journal->getId(),
111  $filterSection,
112  $searchField,
113  $searchMatch,
114  $search,
115  $dateSearchField,
116  $fromDate,
117  $toDate,
118  $rangeInfo,
119  $sort,
120  $sortDirection
121  );
122 
123  // If only result is returned from a search, fast-forward to it
124  if ($search && $submissions && $submissions->getCount() == 1) {
125  $submission =& $submissions->next();
126  $request->redirect(null, null, 'submission', array($submission->getId()));
127  }
128 
129  $templateMgr =& TemplateManager::getManager();
130  $templateMgr->assign('helpTopicId', $helpTopicId);
131  $templateMgr->assign('sectionOptions', $filterSectionOptions);
132  $templateMgr->assign_by_ref('submissions', $submissions);
133  $templateMgr->assign('filterSection', $filterSection);
134  $templateMgr->assign('pageToDisplay', $page);
135  $templateMgr->assign('sectionEditor', $user->getFullName());
136 
137  // Set search parameters
138  $duplicateParameters = array(
139  'searchField', 'searchMatch', 'search',
140  'dateFromMonth', 'dateFromDay', 'dateFromYear',
141  'dateToMonth', 'dateToDay', 'dateToYear',
142  'dateSearchField'
143  );
144  foreach ($duplicateParameters as $param)
145  $templateMgr->assign($param, $request->getUserVar($param));
146 
147  $templateMgr->assign('dateFrom', $fromDate);
148  $templateMgr->assign('dateTo', $toDate);
149  $templateMgr->assign('fieldOptions', array(
150  SUBMISSION_FIELD_TITLE => 'article.title',
151  SUBMISSION_FIELD_ID => 'article.submissionId',
152  SUBMISSION_FIELD_AUTHOR => 'user.role.author',
153  SUBMISSION_FIELD_EDITOR => 'user.role.editor'
154  ));
155  $templateMgr->assign('dateFieldOptions', array(
156  SUBMISSION_FIELD_DATE_SUBMITTED => 'submissions.submitted',
157  SUBMISSION_FIELD_DATE_COPYEDIT_COMPLETE => 'submissions.copyeditComplete',
158  SUBMISSION_FIELD_DATE_LAYOUT_COMPLETE => 'submissions.layoutComplete',
159  SUBMISSION_FIELD_DATE_PROOFREADING_COMPLETE => 'submissions.proofreadingComplete'
160  ));
161 
162  import('classes.issue.IssueAction');
163  $issueAction = new IssueAction();
164  $templateMgr->register_function('print_issue_id', array($issueAction, 'smartyPrintIssueId'));
165  $templateMgr->assign('sort', $sort);
166  $templateMgr->assign('sortDirection', $sortDirection);
167 
168  $templateMgr->display('sectionEditor/index.tpl');
169  }
170 
178  function setupTemplate($subclass = false, $articleId = 0, $parentPage = null, $showSidebar = true) {
179  parent::setupTemplate();
180  AppLocale::requireComponents(LOCALE_COMPONENT_PKP_SUBMISSION, LOCALE_COMPONENT_OJS_EDITOR, LOCALE_COMPONENT_PKP_MANAGER, LOCALE_COMPONENT_OJS_AUTHOR, LOCALE_COMPONENT_OJS_MANAGER);
181  $templateMgr =& TemplateManager::getManager();
182  $isEditor = Validation::isEditor();
183 
184  if (Request::getRequestedPage() == 'editor') {
185  $templateMgr->assign('helpTopicId', 'editorial.editorsRole');
186 
187  } else {
188  $templateMgr->assign('helpTopicId', 'editorial.sectionEditorsRole');
189  }
190 
191  $roleSymbolic = $isEditor ? 'editor' : 'sectionEditor';
192  $roleKey = $isEditor ? 'user.role.editor' : 'user.role.sectionEditor';
193  $pageHierarchy = $subclass ? array(array(Request::url(null, 'user'), 'navigation.user'), array(Request::url(null, $roleSymbolic), $roleKey), array(Request::url(null, $roleSymbolic), 'article.submissions'))
194  : array(array(Request::url(null, 'user'), 'navigation.user'), array(Request::url(null, $roleSymbolic), $roleKey));
195 
196  import('classes.submission.sectionEditor.SectionEditorAction');
197  $submissionCrumb = SectionEditorAction::submissionBreadcrumb($articleId, $parentPage, $roleSymbolic);
198  if (isset($submissionCrumb)) {
199  $pageHierarchy = array_merge($pageHierarchy, $submissionCrumb);
200  }
201  $templateMgr->assign('pageHierarchy', $pageHierarchy);
202  }
203 
209  function instructions($args, &$request) {
210  $this->setupTemplate();
211  import('classes.submission.proofreader.ProofreaderAction');
212  if (!isset($args[0]) || !ProofreaderAction::instructions($args[0], array('copy', 'layout', 'proof', 'referenceLinking'))) {
213  $request->redirect(null, null, 'index');
214  }
215  }
216 
217  //
218  // Validation
219  //
220 
228  function validate($articleId = null, $access = null) {
229  parent::validate();
230  $isValid = true;
231 
232  $sectionEditorSubmissionDao =& DAORegistry::getDAO('SectionEditorSubmissionDAO');
233  $journal =& Request::getJournal();
234  $user =& Request::getUser();
235 
236  if ($articleId !== null) {
237  $sectionEditorSubmission =& $sectionEditorSubmissionDao->getSectionEditorSubmission($articleId);
238 
239  if ($sectionEditorSubmission == null) {
240  $isValid = false;
241 
242  } else if ($sectionEditorSubmission->getJournalId() != $journal->getId()) {
243  $isValid = false;
244 
245  } else if ($sectionEditorSubmission->getDateSubmitted() == null) {
246  $isValid = false;
247 
248  } else {
249  $templateMgr =& TemplateManager::getManager();
250 
251  if (Validation::isEditor()) {
252  // Make canReview and canEdit available to templates.
253  // Since this user is an editor, both are available.
254  $templateMgr->assign('canReview', true);
255  $templateMgr->assign('canEdit', true);
256  } else {
257  // If this user isn't the submission's editor, they don't have access.
258  $editAssignments =& $sectionEditorSubmission->getEditAssignments();
259  $wasFound = false;
260  foreach ($editAssignments as $editAssignment) {
261  if ($editAssignment->getEditorId() == $user->getId()) {
262  $templateMgr->assign('canReview', $editAssignment->getCanReview());
263  $templateMgr->assign('canEdit', $editAssignment->getCanEdit());
264  switch ($access) {
265  case SECTION_EDITOR_ACCESS_EDIT:
266  if ($editAssignment->getCanEdit()) {
267  $wasFound = true;
268  }
269  break;
270  case SECTION_EDITOR_ACCESS_REVIEW:
271  if ($editAssignment->getCanReview()) {
272  $wasFound = true;
273  }
274  break;
275 
276  default:
277  $wasFound = true;
278  }
279  break;
280  }
281  }
282 
283  if (!$wasFound) $isValid = false;
284  }
285  }
286 
287  if (!$isValid) {
289  }
290 
291  // If necessary, note the current date and time as the "underway" date/time
292  $editAssignmentDao =& DAORegistry::getDAO('EditAssignmentDAO');
293  $editAssignments =& $sectionEditorSubmission->getEditAssignments();
294  foreach ($editAssignments as $editAssignment) {
295  if ($editAssignment->getEditorId() == $user->getId() && $editAssignment->getDateUnderway() === null) {
296  $editAssignment->setDateUnderway(Core::getCurrentDate());
297  $editAssignmentDao->updateEditAssignment($editAssignment);
298  }
299  }
300 
301  $this->submission =& $sectionEditorSubmission;
302  return true;
303  }
304  }
305 }
306 
307 ?>
submissionBreadcrumb($articleId, $parentPage, $section)
setupTemplate($subclass=false, $articleId=0, $parentPage=null, $showSidebar=true)
isEditor($journalId=-1)
& getJournal()
Definition: Request.inc.php:42
& getRangeInfo($rangeName, $contextData=null)
redirect($context=null, $page=null, $op=null, $path=null, $params=null, $anchor=null)
getCurrentDate($ts=null)
Definition: Core.inc.php:94
IssueAction class.
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
Handle requests for section editor functions.
Class to validate if a Journal is present.
validate($articleId=null, $access=null)