addCheck(new HandlerValidatorJournal($this)); $this->addCheck(new HandlerValidatorRoles($this, true, null, null, array(ROLE_ID_COPYEDITOR))); } /** * Display copyeditor index page. * @param $args array * @param $request PKPRequest */ function index($args, &$request) { $this->validate($request); $this->setupTemplate(); $journal =& $request->getJournal(); $user =& $request->getUser(); $copyeditorSubmissionDao =& DAORegistry::getDAO('CopyeditorSubmissionDAO'); // Get the user's search conditions, if any $searchField = $request->getUserVar('searchField'); $dateSearchField = $request->getUserVar('dateSearchField'); $searchMatch = $request->getUserVar('searchMatch'); $search = $request->getUserVar('search'); $fromDate = $request->getUserDateVar('dateFrom', 1, 1); if ($fromDate !== null) $fromDate = date('Y-m-d H:i:s', $fromDate); $toDate = $request->getUserDateVar('dateTo', 32, 12, null, 23, 59, 59); if ($toDate !== null) $toDate = date('Y-m-d H:i:s', $toDate); $rangeInfo = $this->getRangeInfo('submissions'); $page = isset($args[0]) ? $args[0] : ''; switch($page) { case 'completed': $active = false; break; default: $page = 'active'; $active = true; } $sort = $request->getUserVar('sort'); $sort = isset($sort) ? $sort : 'title'; $sortDirection = $request->getUserVar('sortDirection'); $submissions = $copyeditorSubmissionDao->getCopyeditorSubmissionsByCopyeditorId($user->getId(), $journal->getId(), $searchField, $searchMatch, $search, $dateSearchField, $fromDate, $toDate, $active, $rangeInfo, $sort, $sortDirection); // If only result is returned from a search, fast-forward to it if ($search && $submissions && $submissions->getCount() == 1) { $submission =& $submissions->next(); $request->redirect(null, null, 'submission', array($submission->getId())); } $templateMgr =& TemplateManager::getManager(); $templateMgr->assign('pageToDisplay', $page); $templateMgr->assign_by_ref('submissions', $submissions); // Set search parameters $duplicateParameters = array( 'searchField', 'searchMatch', 'search', 'dateFromMonth', 'dateFromDay', 'dateFromYear', 'dateToMonth', 'dateToDay', 'dateToYear', 'dateSearchField' ); foreach ($duplicateParameters as $param) $templateMgr->assign($param, $request->getUserVar($param)); $templateMgr->assign('dateFrom', $fromDate); $templateMgr->assign('dateTo', $toDate); $templateMgr->assign('fieldOptions', array( SUBMISSION_FIELD_TITLE => 'article.title', SUBMISSION_FIELD_ID => 'article.submissionId', SUBMISSION_FIELD_AUTHOR => 'user.role.author', SUBMISSION_FIELD_EDITOR => 'user.role.editor' )); $templateMgr->assign('dateFieldOptions', array( SUBMISSION_FIELD_DATE_SUBMITTED => 'submissions.submitted', SUBMISSION_FIELD_DATE_COPYEDIT_COMPLETE => 'submissions.copyeditComplete', SUBMISSION_FIELD_DATE_LAYOUT_COMPLETE => 'submissions.layoutComplete', SUBMISSION_FIELD_DATE_PROOFREADING_COMPLETE => 'submissions.proofreadingComplete' )); import('classes.issue.IssueAction'); $issueAction = new IssueAction(); $templateMgr->register_function('print_issue_id', array($issueAction, 'smartyPrintIssueId')); $templateMgr->assign('helpTopicId', 'editorial.copyeditorsRole.submissions'); $templateMgr->assign('sort', $sort); $templateMgr->assign('sortDirection', $sortDirection); $templateMgr->display('copyeditor/index.tpl'); } /** * Setup common template variables. * @param $subclass boolean set to true if caller is below this handler in the hierarchy */ function setupTemplate($subclass = false, $articleId = 0, $parentPage = null) { parent::setupTemplate(); AppLocale::requireComponents(LOCALE_COMPONENT_PKP_SUBMISSION); $templateMgr =& TemplateManager::getManager(); $pageHierarchy = $subclass ? array(array(Request::url(null, 'user'), 'navigation.user'), array(Request::url(null, 'copyeditor'), 'user.role.copyeditor')) : array(array('user', 'navigation.user'), array('copyeditor', 'user.role.copyeditor')); import('classes.submission.sectionEditor.SectionEditorAction'); $submissionCrumb = SectionEditorAction::submissionBreadcrumb($articleId, $parentPage, 'copyeditor'); if (isset($submissionCrumb)) { $pageHierarchy = array_merge($pageHierarchy, $submissionCrumb); } $templateMgr->assign('pageHierarchy', $pageHierarchy); } /** * Display submission management instructions. * @param $args array * @param $request PKPRequest */ function instructions($args, &$request) { $this->setupTemplate(); import('classes.submission.proofreader.ProofreaderAction'); if (!isset($args[0]) || !ProofreaderAction::instructions($args[0], array('copy'))) { $request->redirect(null, $request->getRequestedPage()); } } /** * Validate that the user is the assigned copyeditor for * the article, if specified. Validate user role. * @param $request PKPRequest * @param $articleId int optional */ function validate($request, $articleId = null) { parent::validate(); if ($articleId !== null) { $copyeditorSubmissionDao =& DAORegistry::getDAO('CopyeditorSubmissionDAO'); $journal =& $request->getJournal(); $user =& $request->getUser(); $isValid = true; $copyeditorSubmission =& $copyeditorSubmissionDao->getCopyeditorSubmission($articleId, $user->getId()); if ($copyeditorSubmission == null) { $isValid = false; } else { if ($copyeditorSubmission->getJournalId() != $journal->getId()) { $isValid = false; } else { if ($copyeditorSubmission->getUserIdBySignoffType('SIGNOFF_COPYEDITING_INITIAL') != $user->getId()) { $isValid = false; } } } if (!$isValid) { $request->redirect(null, $request->getRequestedPage()); } $this->submission =& $copyeditorSubmission; } } } ?>