/** * @copydoc GridCategoryRow::getCategoryLabel() */ function getCategoryLabel() { $stageId = $this->getData(); import('lib.pkp.classes.workflow.WorkflowStageDAO'); $stageTranslationKey = WorkflowStageDAO::getTranslationKeyFromId($stageId); return __($stageTranslationKey); }
/** * Displays the author dashboard. * @param $args array * @param $request PKPRequest */ function submission($args, $request) { // Pass the authorized submission on to the template. $this->setupTemplate($request); $templateMgr = TemplateManager::getManager($request); $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION); $templateMgr->assign('submission', $submission); // Link actions. import('lib.pkp.controllers.modals.submissionMetadata.linkAction.AuthorViewMetadataLinkAction'); $templateMgr->assign('viewMetadataAction', new AuthorViewMetadataLinkAction($request, $submission->getId())); import('lib.pkp.controllers.modals.documentLibrary.linkAction.SubmissionLibraryLinkAction'); $templateMgr->assign('submissionLibraryAction', new SubmissionLibraryLinkAction($request, $submission->getId())); $workflowStages = WorkflowStageDAO::getWorkflowStageKeysAndPaths(); $stageNotifications = array(); foreach (array_keys($workflowStages) as $stageId) { $stageNotifications[$stageId] = false; } $editDecisionDao = DAORegistry::getDAO('EditDecisionDAO'); /* @var $editDecisionDao EditDecisionDAO */ $stageDecisions = $editDecisionDao->getEditorDecisions($submission->getId()); $stagesWithDecisions = array(); foreach ($stageDecisions as $decision) { $stagesWithDecisions[$decision['stageId']] = $decision['stageId']; } $workflowStages = WorkflowStageDAO::getStageStatusesBySubmission($submission, $stagesWithDecisions, $stageNotifications); $templateMgr->assign('workflowStages', $workflowStages); return $templateMgr->display('authorDashboard/authorDashboard.tpl'); }
/** * @see AuthorizationPolicy::effect() */ function effect() { $request = $this->_request; $context = $request->getContext(); $contextId = $context->getId(); $user = $request->getUser(); if (!is_a($user, 'User')) { return AUTHORIZATION_DENY; } $userId = $user->getId(); $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION); $workflowStages = WorkflowStageDAO::getWorkflowStageTranslationKeys(); $accessibleWorkflowStages = array(); foreach ($workflowStages as $stageId => $translationKey) { $accessibleStageRoles = $this->_getAccessibleStageRoles($userId, $contextId, $submission, $stageId); if (!empty($accessibleStageRoles)) { $accessibleWorkflowStages[$stageId] = $accessibleStageRoles; } } if (empty($accessibleWorkflowStages)) { return AUTHORIZATION_DENY; } else { $this->addAuthorizedContextObject(ASSOC_TYPE_ACCESSIBLE_WORKFLOW_STAGES, $accessibleWorkflowStages); return AUTHORIZATION_PERMIT; } }
/** * Handle a singular element import. * @param $node DOMElement */ function handleElement($node) { $deployment = $this->getDeployment(); $context = $deployment->getContext(); $user = $deployment->getUser(); // Create and insert the submission (ID needed for other entities) $submissionDao = Application::getSubmissionDAO(); $submission = $submissionDao->newDataObject(); $submission->setContextId($context->getId()); $submission->setStatus(STATUS_QUEUED); $submissionLocale = $node->getAttribute('locale'); if (empty($submissionLocale)) { $submissionLocale = $context->getPrimaryLocale(); } $submission->setLocale($submissionLocale); $submission->setSubmissionProgress(0); $workflowStageDao = DAORegistry::getDAO('WorkflowStageDAO'); $submission->setStageId(WorkflowStageDAO::getIdFromPath($node->getAttribute('stage'))); $submissionDao->insertObject($submission); $deployment->setSubmission($submission); // Handle any additional attributes etc. $submission = $this->populateObject($submission, $node); for ($n = $node->firstChild; $n !== null; $n = $n->nextSibling) { if (is_a($n, 'DOMElement')) { $this->handleChildElement($n, $submission); } } $submissionDao->updateObject($submission); // Persist setters return $submission; }
/** * @copyDoc GridHandler::renderFilter() */ function renderFilter($request, $filterData = array()) { $workflowStages = WorkflowStageDAO::getWorkflowStageTranslationKeys(); $workflowStages[0] = 'workflow.stage.any'; ksort($workflowStages); $filterColumns = $this->getFilterColumns(); $filterData = array('columns' => $filterColumns, 'workflowStages' => $workflowStages, 'gridId' => $this->getId()); return parent::renderFilter($request, $filterData); }
protected function _saveGeneralPromote($args, $request) { // Redirect to the next workflow page after // promoting the submission. $decision = (int) $request->getUserVar('decision'); $redirectOp = null; if ($decision == SUBMISSION_EDITOR_DECISION_ACCEPT) { $redirectOp = WORKFLOW_STAGE_PATH_EDITING; } elseif ($decision == SUBMISSION_EDITOR_DECISION_EXTERNAL_REVIEW) { $redirectOp = WORKFLOW_STAGE_PATH_EXTERNAL_REVIEW; } elseif ($decision == SUBMISSION_EDITOR_DECISION_SEND_TO_PRODUCTION) { $redirectOp = WORKFLOW_STAGE_PATH_PRODUCTION; } // Make sure user has access to the workflow stage. import('lib.pkp.classes.workflow.WorkflowStageDAO'); $redirectWorkflowStage = WorkflowStageDAO::getIdFromPath($redirectOp); $userAccessibleWorkflowStages = $this->getAuthorizedContextObject(ASSOC_TYPE_ACCESSIBLE_WORKFLOW_STAGES); if (!array_key_exists($redirectWorkflowStage, $userAccessibleWorkflowStages)) { $redirectOp = null; } return $this->_saveEditorDecision($args, $request, 'PromoteForm', $redirectOp); }
/** * Translate the requested operation to a stage id. * @param $request Request * @param $args array * @return integer One of the WORKFLOW_STAGE_* constants. */ protected function identifyStageId($request, $args) { if ($stageId = $request->getUserVar('stageId')) { return (int) $stageId; } // Maintain the old check for previous path urls $router = $request->getRouter(); $workflowPath = $router->getRequestedOp($request); $stageId = WorkflowStageDAO::getIdFromPath($workflowPath); if ($stageId) { return $stageId; } // Finally, retrieve the requested operation, if the stage id is // passed in via an argument in the URL, like index/submissionId/stageId $stageId = $args[1]; // Translate the operation to a workflow stage identifier. assert(WorkflowStageDAO::getPathFromId($stageId) !== null); return $stageId; }
/** * Toggle user group stage assignment. * @param $args array * @param $request PKPRequest * @return JSONMessage JSON object */ private function _toggleAssignment($args, $request) { $userGroup = $this->_userGroup; $stageId = $this->getAuthorizedContextObject(ASSOC_TYPE_WORKFLOW_STAGE); $contextId = $this->_getContextId(); $operation = $request->getRequestedOp(); $userGroupDao = DAORegistry::getDAO('UserGroupDAO'); /* @var $userGroupDao UserGroupDAO */ switch ($operation) { case 'assignStage': $userGroupDao->assignGroupToStage($contextId, $userGroup->getId(), $stageId); $messageKey = 'grid.userGroup.assignedStage'; break; case 'unassignStage': $userGroupDao->removeGroupFromStage($contextId, $userGroup->getId(), $stageId); $messageKey = 'grid.userGroup.unassignedStage'; break; } $notificationMgr = new NotificationManager(); $user = $request->getUser(); $stageLocaleKeys = WorkflowStageDAO::getWorkflowStageTranslationKeys(); $notificationMgr->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SUCCESS, array('contents' => __($messageKey, array('userGroupName' => $userGroup->getLocalizedName(), 'stageName' => __($stageLocaleKeys[$stageId]))))); return DAO::getDataChangedEvent($userGroup->getId()); }
/** * Get the data for an workflow stage by * pending revisions notification type. * @return string */ private function _getStageDataByType() { $stagesData = WorkflowStageDAO::getWorkflowStageKeysAndPaths(); switch ($this->getNotificationType()) { case NOTIFICATION_TYPE_PENDING_INTERNAL_REVISIONS: return $stagesData[WORKFLOW_STAGE_ID_INTERNAL_REVIEW]; case NOTIFICATION_TYPE_PENDING_EXTERNAL_REVISIONS: return $stagesData[WORKFLOW_STAGE_ID_EXTERNAL_REVIEW]; default: assert(false); } }
/** * Return a message string for the notification based on its type * and associated object. * @copydoc INotificationInfoProvider::getNotificationContents() */ public function getNotificationMessage($request, $notification) { $type = $notification->getType(); assert(isset($type)); $submissionDao = Application::getSubmissionDAO(); switch ($type) { case NOTIFICATION_TYPE_SUCCESS: case NOTIFICATION_TYPE_ERROR: case NOTIFICATION_TYPE_WARNING: if (!is_null($this->getNotificationSettings($notification->getId()))) { $notificationSettings = $this->getNotificationSettings($notification->getId()); return $notificationSettings['contents']; } else { return __('common.changesSaved'); } case NOTIFICATION_TYPE_FORM_ERROR: case NOTIFICATION_TYPE_ERROR: $notificationSettings = $this->getNotificationSettings($notification->getId()); assert(!is_null($notificationSettings['contents'])); return $notificationSettings['contents']; case NOTIFICATION_TYPE_PLUGIN_ENABLED: return $this->_getTranslatedKeyWithParameters('common.pluginEnabled', $notification->getId()); case NOTIFICATION_TYPE_PLUGIN_DISABLED: return $this->_getTranslatedKeyWithParameters('common.pluginDisabled', $notification->getId()); case NOTIFICATION_TYPE_LOCALE_INSTALLED: return $this->_getTranslatedKeyWithParameters('admin.languages.localeInstalled', $notification->getId()); case NOTIFICATION_TYPE_NEW_ANNOUNCEMENT: assert($notification->getAssocType() == ASSOC_TYPE_ANNOUNCEMENT); return __('notification.type.newAnnouncement'); case NOTIFICATION_TYPE_ALL_REVIEWS_IN: case NOTIFICATION_TYPE_ALL_REVISIONS_IN: if ($notification->getType() == NOTIFICATION_TYPE_ALL_REVIEWS_IN) { $localeKey = 'notification.type.allReviewsIn'; } else { $localeKey = 'notification.type.allRevisionsIn'; } assert($notification->getAssocType() == ASSOC_TYPE_REVIEW_ROUND && is_numeric($notification->getAssocId())); $reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO'); $reviewRound = $reviewRoundDao->getById($notification->getAssocId()); assert(is_a($reviewRound, 'ReviewRound')); $stagesData = WorkflowStageDAO::getWorkflowStageKeysAndPaths(); return __($localeKey, array('stage' => __($stagesData[$reviewRound->getStageId()]['translationKey']))); case NOTIFICATION_TYPE_APPROVE_SUBMISSION: assert($notification->getAssocType() == ASSOC_TYPE_SUBMISSION && is_numeric($notification->getAssocId())); return __('notification.type.approveSubmission'); case NOTIFICATION_TYPE_REVIEWER_COMMENT: assert($notification->getAssocType() == ASSOC_TYPE_REVIEW_ASSIGNMENT && is_numeric($notification->getAssocId())); $reviewAssignmentDao = DAORegistry::getDAO('ReviewAssignmentDAO'); /* @var $reviewAssignmentDao ReviewAssignmentDAO */ $reviewAssignment = $reviewAssignmentDao->getById($notification->getAssocId()); $submission = $submissionDao->getById($reviewAssignment->getSubmissionId()); /* @var $submission Submission */ return __('notification.type.reviewerComment', array('title' => $submission->getLocalizedTitle())); case NOTIFICATION_TYPE_LAYOUT_ASSIGNMENT: assert($notification->getAssocType() == ASSOC_TYPE_SUBMISSION && is_numeric($notification->getAssocId())); $submission = $submissionDao->getById($notification->getAssocId()); return __('notification.type.layouteditorRequest', array('title' => $submission->getLocalizedTitle())); case NOTIFICATION_TYPE_INDEX_ASSIGNMENT: assert($notification->getAssocType() == ASSOC_TYPE_SUBMISSION && is_numeric($notification->getAssocId())); $submission = $submissionDao->getById($notification->getAssocId()); return __('notification.type.indexRequest', array('title' => $submission->getLocalizedTitle())); case NOTIFICATION_TYPE_REVIEW_ASSIGNMENT: return __('notification.type.reviewAssignment'); case NOTIFICATION_TYPE_REVIEW_ROUND_STATUS: assert($notification->getAssocType() == ASSOC_TYPE_REVIEW_ROUND && is_numeric($notification->getAssocId())); $reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO'); $reviewRound = $reviewRoundDao->getById($notification->getAssocId()); AppLocale::requireComponents(LOCALE_COMPONENT_APP_EDITOR); // load review round status keys. return __($reviewRound->getStatusKey()); default: return $this->getByDelegate($notification->getType(), $notification->getAssocType(), $notification->getAssocId(), __FUNCTION__, array($request, $notification)); } }
/** * Get cell actions associated with this row/column combination * @param $row GridRow * @param $column GridColumn * @return array an array of LinkAction instances */ function getCellActions($request, $row, $column, $position = GRID_ACTION_POSITION_DEFAULT) { $submission = $row->getData(); $user = $request->getUser(); switch ($column->getId()) { case 'editor': $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO'); /* @var $stageAssignmentDao StageAssignmentDAO */ $editorAssignments = $stageAssignmentDao->getEditorsAssignedToStage($submission->getId(), $submission->getStageId()); $assignment = current($editorAssignments); if (!$assignment) { return array(); } $userDao = DAORegistry::getDAO('UserDAO'); /* @var $userDao UserDAO */ $editor = $userDao->getById($assignment->getUserId()); import('lib.pkp.classes.linkAction.request.NullAction'); return array(new LinkAction('editor', new NullAction(), $editor->getInitials(), null, $editor->getFullName())); case 'stage': $stageId = $submission->getStageId(); $stage = null; if ($submission->getSubmissionProgress() > 0) { // Submission process not completed. $stage = __('submissions.incomplete'); } switch ($submission->getStatus()) { case STATUS_DECLINED: $stage = __('submission.status.declined'); break; case STATUS_PUBLISHED: $stage = __('submission.status.published'); break; } if (!$stage) { $stage = __(WorkflowStageDAO::getTranslationKeyFromId($stageId)); } import('lib.pkp.classes.linkAction.request.RedirectAction'); $reviewAssignmentDao = DAORegistry::getDAO('ReviewAssignmentDAO'); $reviewAssignment = $reviewAssignmentDao->getLastReviewRoundReviewAssignmentByReviewer($submission->getId(), $user->getId()); if (is_a($reviewAssignment, 'ReviewAssignment') && $reviewAssignment->getStageId() == $stageId) { return array(new LinkAction('itemWorkflow', new RedirectAction($request->getDispatcher()->url($request, ROUTE_PAGE, null, 'reviewer', 'submission', $submission->getId())), $stage)); } return array(new LinkAction('itemWorkflow', new RedirectAction(SubmissionsListGridCellProvider::getUrlByUserRoles($request, $submission)), $stage)); } return parent::getCellActions($request, $row, $column, $position); }
/** * Get all stages assigned to one user group in one context. * @param $contextId int The context ID. * @param $userGroupId int The user group ID * @return array */ function getAssignedStagesByUserGroupId($contextId, $userGroupId) { $result = $this->retrieve('SELECT stage_id FROM user_group_stage WHERE context_id = ? AND user_group_id = ?', array((int) $contextId, (int) $userGroupId)); $returner = array(); while (!$result->EOF) { $stageId = $result->Fields('stage_id'); $returner[$stageId] = WorkflowStageDAO::getTranslationKeyFromId($stageId); $result->MoveNext(); } return $returner; }
/** * Create and return a submission node. * @param $doc DOMDocument * @param $submission Submission * @return DOMElement */ function createSubmissionNode($doc, $submission) { // Create the root node and attributes $deployment = $this->getDeployment(); $deployment->setSubmission($submission); $submissionNode = $doc->createElementNS($deployment->getNamespace(), $deployment->getSubmissionNodeName()); $submissionNode->setAttribute('locale', $submission->getLocale()); $submissionLanguage = $submission->getLanguage(); if ($submissionLanguage) { $submissionNode->setAttribute('locale', $submissionLanguage); } $submissionNode->setAttribute('date_submitted', strftime('%F', strtotime($submission->getDateSubmitted()))); $workflowStageDao = DAORegistry::getDAO('WorkflowStageDAO'); $submissionNode->setAttribute('stage', WorkflowStageDAO::getPathFromId($submission->getStageId())); if ($datePublished = $submission->getDatePublished()) { $submissionNode->setAttribute('date_published', strftime('%F', strtotime($datePublished))); } // FIXME: language attribute (from old DTD). Necessary? Data migration needed? $this->addIdentifiers($doc, $submissionNode, $submission); $this->addMetadata($doc, $submissionNode, $submission); $this->addAuthors($doc, $submissionNode, $submission); $this->addFiles($doc, $submissionNode, $submission); $this->addRepresentations($doc, $submissionNode, $submission); return $submissionNode; }
/** * Get cell actions associated with this row/column combination * @param $row GridRow * @param $column GridColumn * @return array an array of LinkAction instances */ function getCellActions($request, $row, $column, $position = GRID_ACTION_POSITION_DEFAULT) { $submission = $row->getData(); $user = $request->getUser(); switch ($column->getId()) { case 'editor': $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO'); /* @var $stageAssignmentDao StageAssignmentDAO */ $editorAssignments = $stageAssignmentDao->getEditorsAssignedToStage($submission->getId(), $submission->getStageId()); $assignment = current($editorAssignments); if (!$assignment) { return array(); } $userDao = DAORegistry::getDAO('UserDAO'); /* @var $userDao UserDAO */ $editor = $userDao->getById($assignment->getUserId()); import('lib.pkp.classes.linkAction.request.NullAction'); return array(new LinkAction('editor', new NullAction(), $editor->getInitials(), null, $editor->getFullName())); case 'stage': $stageId = $submission->getStageId(); $stage = null; if ($submission->getSubmissionProgress() > 0) { // Submission process not completed. $stage = __('submissions.incomplete'); } switch ($submission->getStatus()) { case STATUS_DECLINED: $stage = __('submission.status.declined'); break; case STATUS_PUBLISHED: $stage = __('submission.status.published'); break; } $userGroupDao = DAORegistry::getDAO('UserGroupDAO'); if (!$stage) { $stage = __(WorkflowStageDAO::getTranslationKeyFromId($stageId)); } $reviewAssignmentDao = DAORegistry::getDAO('ReviewAssignmentDAO'); $reviewAssignment = $reviewAssignmentDao->getLastReviewRoundReviewAssignmentByReviewer($submission->getId(), $user->getId()); if (is_a($reviewAssignment, 'ReviewAssignment')) { // Reviewer: Add a review link action. return array($this->_getCellLinkAction($request, 'reviewer', 'submission', $submission, $stage)); } else { // Get the right page and operation (authordashboard or workflow). list($page, $operation) = SubmissionsListGridCellProvider::getPageAndOperationByUserRoles($request, $submission); // Return redirect link action. return array($this->_getCellLinkAction($request, $page, $operation, $submission, $stage)); } } return parent::getCellActions($request, $row, $column, $position); }
/** * Setup the stages assignments to a user group in database. * @param $userGroupId int User group id that will receive the stages. * @param $userAssignedStages array of stages currently assigned to a user. */ function _assignStagesToUserGroup($userGroupId, $userAssignedStages) { $contextId = $this->getContextId(); $userGroupDao = DAORegistry::getDAO('UserGroupDAO'); // Current existing workflow stages. $stages = WorkflowStageDAO::getWorkflowStageTranslationKeys(); foreach (array_keys($stages) as $stageId) { $userGroupDao->removeGroupFromStage($contextId, $userGroupId, $stageId); } foreach ($userAssignedStages as $stageId) { // Make sure we don't assign forbidden stages based on // user groups role id. $roleId = $this->getData('roleId'); $roleDao = DAORegistry::getDAO('RoleDAO'); /* @var $roleDao RoleDAO */ $forbiddenStages = $roleDao->getForbiddenStages($roleId); if (in_array($stageId, $forbiddenStages)) { continue; } // Check if is a valid stage. if (in_array($stageId, array_keys($stages))) { $userGroupDao->assignGroupToStage($contextId, $userGroupId, $stageId); } else { fatalError('Invalid stage id'); } } }