4 * @file AcquisitionsEditorHandler.inc.php
6 * Copyright (c) 2003-2008 John Willinsky
7 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
9 * @class AcquisitionsEditorHandler
10 * @ingroup pages_acquisitionsEditor
12 * @brief Handle requests for acquistions editor functions.
15 // $Id: AcquisitionsEditorHandler.inc.php,v 1.14 2009/06/23 00:56:37 jalperin Exp $
19 define('FILTER_ARRANGEMENT_ALL', 0);
21 import('handler.Handler');
23 class AcquisitionsEditorHandler
extends Handler
{
27 function AcquisitionsEditorHandler() {
30 $this->addCheck(new HandlerValidatorPress($this));
31 // FIXME This is kind of evil
32 $page = Request
::getRequestedPage();
33 if ( $page == 'acquisitionsEditor' )
34 $this->addCheck(new HandlerValidatorRoles($this, true, null, null, array(ROLE_ID_ACQUISITIONS_EDITOR
)));
35 elseif ( $page == 'editor' )
36 $this->addCheck(new HandlerValidatorRoles($this, true, null, null, array(ROLE_ID_EDITOR
)));
40 * Display acquisitions editor index page.
42 function index($args) {
44 $this->setupTemplate();
46 $press =& Request
::getPress();
47 $pressId = $press->getId();
48 $user =& Request
::getUser();
50 $rangeInfo = Handler
::getRangeInfo('submissions');
52 // Get the user's search conditions, if any
53 $searchField = Request
::getUserVar('searchField');
54 $dateSearchField = Request
::getUserVar('dateSearchField');
55 $searchMatch = Request
::getUserVar('searchMatch');
56 $search = Request
::getUserVar('search');
58 $fromDate = Request
::getUserDateVar('dateFrom', 1, 1);
59 if ($fromDate !== null) $fromDate = date('Y-m-d H:i:s', $fromDate);
60 $toDate = Request
::getUserDateVar('dateTo', 32, 12, null, 23, 59, 59);
61 if ($toDate !== null) $toDate = date('Y-m-d H:i:s', $toDate);
63 $arrangementDao =& DAORegistry
::getDAO('AcquisitionsArrangementDAO');
64 $acquisitionsEditorSubmissionDao =& DAORegistry
::getDAO('AcquisitionsEditorSubmissionDAO');
66 $page = isset($args[0]) ?
$args[0] : '';
67 $arrangements =& $arrangementDao->getTitlesByPressId($press->getId());
69 $sort = Request
::getUserVar('sort');
70 $sort = isset($sort) ?
$sort : 'id';
71 $sortDirection = Request
::getUserVar('sortDirection');
73 $filterArrangementOptions = array(
74 FILTER_ARRANGEMENT_ALL
=> Locale
::Translate('editor.allArrangements')
78 case 'submissionsInEditing':
79 $functionName = 'getAcquisitionsEditorSubmissionsInEditing';
80 $helpTopicId = 'editorial.acquisitionsEditorsRole.submissions.inEditing';
82 case 'submissionsArchives':
83 $functionName = 'getAcquisitionsEditorSubmissionsArchives';
84 $helpTopicId = 'editorial.acquisitionsEditorsRole.submissions.archives';
87 $page = 'submissionsInReview';
88 $functionName = 'getAcquisitionsEditorSubmissionsInReview';
89 $helpTopicId = 'editorial.acquisitionsEditorsRole.submissions.inReview';
92 $filterArrangement = Request
::getUserVar('filterArrangement');
93 if ($filterArrangement != '' && array_key_exists($filterArrangement, $filterArrangementOptions)) {
94 $user->updateSetting('filterArrangement', $filterArrangement, 'int', $pressId);
96 $filterArrangement = $user->getSetting('filterArrangement', $pressId);
97 if ($filterArrangement == null) {
98 $filterArrangement = FILTER_ARRANGEMENT_ALL
;
99 $user->updateSetting('filterArrangement', $filterArrangement, 'int', $pressId);
103 $submissions =& $acquisitionsEditorSubmissionDao->$functionName(
114 $acquisitionsEditorSubmissionDao->getSortMapping($sort)
117 $templateMgr =& TemplateManager
::getManager();
118 $templateMgr->assign('helpTopicId', $helpTopicId);
119 $templateMgr->assign('arrangementOptions', $filterArrangementOptions);
120 $templateMgr->assign_by_ref('submissions', $submissions);
121 $templateMgr->assign('filterArrangement', $filterArrangement);
122 $templateMgr->assign('pageToDisplay', $page);
123 $templateMgr->assign('acquisitionsEditor', $user->getFullName());
125 // Set search parameters
126 $duplicateParameters = array(
127 'searchField', 'searchMatch', 'search',
128 'dateFromMonth', 'dateFromDay', 'dateFromYear',
129 'dateToMonth', 'dateToDay', 'dateToYear',
132 foreach ($duplicateParameters as $param)
133 $templateMgr->assign($param, Request
::getUserVar($param));
135 $templateMgr->assign('dateFrom', $fromDate);
136 $templateMgr->assign('dateTo', $toDate);
137 $templateMgr->assign('fieldOptions', Array(
138 SUBMISSION_FIELD_TITLE
=> 'monograph.title',
139 SUBMISSION_FIELD_AUTHOR
=> 'user.role.author',
140 SUBMISSION_FIELD_EDITOR
=> 'user.role.editor'
142 $templateMgr->assign('dateFieldOptions', Array(
143 SUBMISSION_FIELD_DATE_SUBMITTED
=> 'submissions.submitted',
144 SUBMISSION_FIELD_DATE_COPYEDIT_COMPLETE
=> 'submissions.copyeditComplete',
145 SUBMISSION_FIELD_DATE_LAYOUT_COMPLETE
=> 'submissions.layoutComplete',
146 SUBMISSION_FIELD_DATE_PROOFREADING_COMPLETE
=> 'submissions.proofreadingComplete'
149 $templateMgr->assign('sort', $sort);
150 $templateMgr->assign('sortDirection', $sortDirection);
152 $templateMgr->display('acquisitionsEditor/index.tpl');
156 * Setup common template variables.
157 * @param $subclass boolean set to true if caller is below this handler in the hierarchy
159 function setupTemplate($subclass = false, $monographId = 0, $parentPage = null, $showSidebar = true) {
160 parent
::setupTemplate();
161 Locale
::requireComponents(array(LOCALE_COMPONENT_PKP_SUBMISSION
, LOCALE_COMPONENT_OMP_EDITOR
));
162 $templateMgr =& TemplateManager
::getManager();
163 $isEditor = Validation
::isEditor();
165 if (($page = Request
::getRequestedPage()) == 'editor') {
166 $templateMgr->assign('helpTopicId', 'editorial.editorsRole');
169 $templateMgr->assign('helpTopicId', 'editorial.acquisitionsEditorsRole');
172 $pageHierarchy = $subclass ?
array(array(Request
::url(null, 'user'), 'navigation.user'), array(Request
::url(null, $isEditor?
'editor':'acquisitionsEditor'), $isEditor?
'user.role.editor':'user.role.acquisitionsEditor'), array(Request
::url(null, 'acquisitionsEditor'), 'manuscript.submissions'))
173 : array(array(Request
::url(null, 'user'), 'navigation.user'), array(Request
::url(null, $isEditor?
'editor':'acquisitionsEditor'), $isEditor?
'user.role.editor':'user.role.acquisitionsEditor'));
175 import('submission.acquisitionsEditor.AcquisitionsEditorAction');
176 $submissionCrumb = AcquisitionsEditorAction
::submissionBreadcrumb($monographId, $parentPage, $page);
177 if (isset($submissionCrumb)) {
178 $pageHierarchy = array_merge($pageHierarchy, $submissionCrumb);
180 $templateMgr->assign('pageHierarchy', $pageHierarchy);