first commit
This commit is contained in:
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file controllers/tab/authorDashboard/AuthorDashboardReviewRoundTabHandler.php
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2003-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class AuthorDashboardReviewRoundTabHandler
|
||||
*
|
||||
* @ingroup controllers_tab_authorDashboard
|
||||
*
|
||||
* @brief Handle AJAX operations for review round tabs on author dashboard page.
|
||||
*/
|
||||
|
||||
namespace PKP\controllers\tab\authorDashboard;
|
||||
|
||||
use APP\core\Application;
|
||||
use APP\core\Request;
|
||||
use APP\notification\Notification;
|
||||
use APP\pages\authorDashboard\AuthorDashboardHandler;
|
||||
use APP\template\TemplateManager;
|
||||
use PKP\core\JSONMessage;
|
||||
use PKP\db\DAORegistry;
|
||||
use PKP\log\SubmissionEmailLogDAO;
|
||||
use PKP\log\SubmissionEmailLogEntry;
|
||||
use PKP\notification\PKPNotification;
|
||||
use PKP\security\authorization\internal\ReviewRoundRequiredPolicy;
|
||||
use PKP\security\authorization\internal\WorkflowStageRequiredPolicy;
|
||||
use PKP\security\Role;
|
||||
use PKP\submission\reviewAssignment\ReviewAssignmentDAO;
|
||||
|
||||
class AuthorDashboardReviewRoundTabHandler extends AuthorDashboardHandler
|
||||
{
|
||||
/** @var bool Overwrite backend page handling of AuthorDashboardHandler */
|
||||
public $_isBackendPage = false;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->addRoleAssignment([Role::ROLE_ID_AUTHOR], ['fetchReviewRoundInfo']);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Extended methods from Handler
|
||||
//
|
||||
/**
|
||||
* @copydoc PKPHandler::authorize()
|
||||
*/
|
||||
public function authorize($request, &$args, $roleAssignments)
|
||||
{
|
||||
$stageId = (int)$request->getUserVar('stageId');
|
||||
|
||||
// Authorize stage id.
|
||||
$this->addPolicy(new WorkflowStageRequiredPolicy($stageId));
|
||||
|
||||
// We need a review round id in request.
|
||||
$this->addPolicy(new ReviewRoundRequiredPolicy($request, $args));
|
||||
|
||||
return parent::authorize($request, $args, $roleAssignments);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Public handler operations
|
||||
//
|
||||
/**
|
||||
* Fetch information for the author on the specified review round
|
||||
*
|
||||
* @param array $args
|
||||
* @param Request $request
|
||||
*
|
||||
* @return JSONMessage JSON object
|
||||
*/
|
||||
public function fetchReviewRoundInfo($args, $request)
|
||||
{
|
||||
$this->setupTemplate($request);
|
||||
$templateMgr = TemplateManager::getManager($request);
|
||||
|
||||
$reviewRound = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_REVIEW_ROUND);
|
||||
$submission = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_SUBMISSION);
|
||||
$stageId = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_WORKFLOW_STAGE);
|
||||
if ($stageId !== WORKFLOW_STAGE_ID_INTERNAL_REVIEW && $stageId !== WORKFLOW_STAGE_ID_EXTERNAL_REVIEW) {
|
||||
fatalError('Invalid Stage Id');
|
||||
}
|
||||
|
||||
$templateMgr->assign([
|
||||
'stageId' => $stageId,
|
||||
'reviewRoundId' => $reviewRound->getId(),
|
||||
'submission' => $submission,
|
||||
'reviewRoundNotificationRequestOptions' => [
|
||||
Notification::NOTIFICATION_LEVEL_NORMAL => [
|
||||
PKPNotification::NOTIFICATION_TYPE_REVIEW_ROUND_STATUS => [Application::ASSOC_TYPE_REVIEW_ROUND, $reviewRound->getId()]],
|
||||
Notification::NOTIFICATION_LEVEL_TRIVIAL => []
|
||||
],
|
||||
]);
|
||||
|
||||
// If open reviews exist, show the reviewers grid
|
||||
$reviewAssignmentDao = DAORegistry::getDAO('ReviewAssignmentDAO'); /** @var ReviewAssignmentDAO $reviewAssignmentDao */
|
||||
if ($reviewAssignmentDao->getOpenReviewsByReviewRoundId($reviewRound->getId())) {
|
||||
$templateMgr->assign('showReviewerGrid', true);
|
||||
}
|
||||
|
||||
// Display notification emails to the author related to editorial decisions
|
||||
$submissionEmailLogDao = DAORegistry::getDAO('SubmissionEmailLogDAO'); /** @var SubmissionEmailLogDAO $submissionEmailLogDao */
|
||||
$templateMgr->assign([
|
||||
'submissionEmails' => $submissionEmailLogDao->getByEventType(
|
||||
$submission->getId(),
|
||||
SubmissionEmailLogEntry::SUBMISSION_EMAIL_EDITOR_NOTIFY_AUTHOR,
|
||||
$request->getUser()->getId()
|
||||
),
|
||||
'showReviewAttachments' => true,
|
||||
]);
|
||||
|
||||
return $templateMgr->fetchJson('authorDashboard/reviewRoundInfo.tpl');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file controllers/tab/authorDashboard/AuthorDashboardTabHandler.php
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2003-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class AuthorDashboardTabHandler
|
||||
*
|
||||
* @ingroup controllers_tab_authorDashboard
|
||||
*
|
||||
* @brief Handle AJAX operations for authorDashboard tabs.
|
||||
*/
|
||||
|
||||
namespace PKP\controllers\tab\authorDashboard;
|
||||
|
||||
use APP\core\Application;
|
||||
use APP\core\Request;
|
||||
use APP\handler\Handler;
|
||||
use APP\notification\Notification;
|
||||
use APP\submission\Submission;
|
||||
use APP\template\TemplateManager;
|
||||
use PKP\core\JSONMessage;
|
||||
use PKP\db\DAORegistry;
|
||||
use PKP\log\SubmissionEmailLogDAO;
|
||||
use PKP\log\SubmissionEmailLogEntry;
|
||||
use PKP\notification\PKPNotification;
|
||||
use PKP\security\authorization\AuthorDashboardAccessPolicy;
|
||||
use PKP\security\Role;
|
||||
use PKP\submission\reviewRound\ReviewRoundDAO;
|
||||
|
||||
class AuthorDashboardTabHandler extends Handler
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->addRoleAssignment([Role::ROLE_ID_AUTHOR], ['fetchTab']);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Extended methods from Handler
|
||||
//
|
||||
/**
|
||||
* @copydoc PKPHandler::authorize()
|
||||
*/
|
||||
public function authorize($request, &$args, $roleAssignments)
|
||||
{
|
||||
$this->addPolicy(new AuthorDashboardAccessPolicy($request, $args, $roleAssignments), true);
|
||||
|
||||
return parent::authorize($request, $args, $roleAssignments);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Public handler operations
|
||||
//
|
||||
/**
|
||||
* Fetch the specified authorDashboard tab.
|
||||
*
|
||||
* @param array $args
|
||||
* @param Request $request
|
||||
*
|
||||
* @return JSONMessage JSON object
|
||||
*/
|
||||
public function fetchTab($args, $request)
|
||||
{
|
||||
$this->setupTemplate($request);
|
||||
$templateMgr = TemplateManager::getManager($request);
|
||||
|
||||
$stageId = $request->getUserVar('stageId');
|
||||
$templateMgr->assign('stageId', $stageId);
|
||||
|
||||
$submission = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_SUBMISSION);
|
||||
$templateMgr->assign('submission', $submission);
|
||||
|
||||
// Check if current author can access CopyeditFilesGrid within copyedit stage
|
||||
$canAccessCopyeditingStage = true;
|
||||
$userAllowedStages = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_ACCESSIBLE_WORKFLOW_STAGES);
|
||||
if (!array_key_exists(WORKFLOW_STAGE_ID_EDITING, $userAllowedStages)) {
|
||||
$canAccessCopyeditingStage = false;
|
||||
}
|
||||
$templateMgr->assign('canAccessCopyeditingStage', $canAccessCopyeditingStage);
|
||||
|
||||
// Workflow-stage specific "upload file" action.
|
||||
$currentStage = $submission->getStageId();
|
||||
|
||||
$templateMgr->assign('lastReviewRoundNumber', $this->_getLastReviewRoundNumber($submission, $currentStage));
|
||||
|
||||
if (in_array($stageId, [WORKFLOW_STAGE_ID_INTERNAL_REVIEW, WORKFLOW_STAGE_ID_EXTERNAL_REVIEW])) {
|
||||
$reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO'); /** @var ReviewRoundDAO $reviewRoundDao */
|
||||
$templateMgr->assign('reviewRounds', $reviewRoundDao->getBySubmissionId($submission->getId(), $stageId)->toArray());
|
||||
}
|
||||
|
||||
// If the submission is in or past the editorial stage,
|
||||
// assign the editor's copyediting emails to the template
|
||||
$submissionEmailLogDao = DAORegistry::getDAO('SubmissionEmailLogDAO'); /** @var SubmissionEmailLogDAO $submissionEmailLogDao */
|
||||
$user = $request->getUser();
|
||||
|
||||
// Define the notification options.
|
||||
$templateMgr->assign(
|
||||
'authorDashboardNotificationRequestOptions',
|
||||
$this->_getNotificationRequestOptions($submission)
|
||||
);
|
||||
|
||||
switch ($stageId) {
|
||||
case WORKFLOW_STAGE_ID_SUBMISSION:
|
||||
return $templateMgr->fetchJson('controllers/tab/authorDashboard/submission.tpl');
|
||||
case WORKFLOW_STAGE_ID_INTERNAL_REVIEW:
|
||||
return $templateMgr->fetchJson('controllers/tab/authorDashboard/internalReview.tpl');
|
||||
case WORKFLOW_STAGE_ID_EXTERNAL_REVIEW:
|
||||
return $templateMgr->fetchJson('controllers/tab/authorDashboard/externalReview.tpl');
|
||||
case WORKFLOW_STAGE_ID_EDITING:
|
||||
$templateMgr->assign('copyeditingEmails', $submissionEmailLogDao->getByEventType($submission->getId(), SubmissionEmailLogEntry::SUBMISSION_EMAIL_COPYEDIT_NOTIFY_AUTHOR, $user->getId()));
|
||||
return $templateMgr->fetchJson('controllers/tab/authorDashboard/editorial.tpl');
|
||||
case WORKFLOW_STAGE_ID_PRODUCTION:
|
||||
$templateMgr->assign([
|
||||
'productionEmails' => $submissionEmailLogDao->getByEventType($submission->getId(), SubmissionEmailLogEntry::SUBMISSION_EMAIL_PROOFREAD_NOTIFY_AUTHOR, $user->getId()),
|
||||
]);
|
||||
return $templateMgr->fetchJson('controllers/tab/authorDashboard/production.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last review round numbers in an array by stage name.
|
||||
*
|
||||
* @param Submission $submission
|
||||
* @param int $stageId WORKFLOW_STAGE_ID_...
|
||||
*
|
||||
* @return int Round number, 0 if none.
|
||||
*/
|
||||
protected function _getLastReviewRoundNumber($submission, $stageId)
|
||||
{
|
||||
$reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO'); /** @var ReviewRoundDAO $reviewRoundDao */
|
||||
$lastExternalReviewRound = $reviewRoundDao->getLastReviewRoundBySubmissionId($submission->getId(), $stageId);
|
||||
if ($lastExternalReviewRound) {
|
||||
return $lastExternalReviewRound->getRound();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification request options.
|
||||
*
|
||||
* @param Submission $submission
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function _getNotificationRequestOptions($submission)
|
||||
{
|
||||
$submissionAssocTypeAndIdArray = [Application::ASSOC_TYPE_SUBMISSION, $submission->getId()];
|
||||
return [
|
||||
Notification::NOTIFICATION_LEVEL_TASK => [
|
||||
PKPNotification::NOTIFICATION_TYPE_PENDING_EXTERNAL_REVISIONS => $submissionAssocTypeAndIdArray],
|
||||
Notification::NOTIFICATION_LEVEL_NORMAL => [
|
||||
PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_ACCEPT => $submissionAssocTypeAndIdArray,
|
||||
PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_EXTERNAL_REVIEW => $submissionAssocTypeAndIdArray,
|
||||
PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_PENDING_REVISIONS => $submissionAssocTypeAndIdArray,
|
||||
PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_RESUBMIT => $submissionAssocTypeAndIdArray,
|
||||
PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_NEW_ROUND => $submissionAssocTypeAndIdArray,
|
||||
PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_DECLINE => $submissionAssocTypeAndIdArray,
|
||||
PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_REVERT_DECLINE => $submissionAssocTypeAndIdArray,
|
||||
PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_SEND_TO_PRODUCTION => $submissionAssocTypeAndIdArray],
|
||||
Notification::NOTIFICATION_LEVEL_TRIVIAL => []
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,283 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file controllers/tab/pubIds/form/PKPPublicIdentifiersForm.php
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2003-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class PKPPublicIdentifiersForm
|
||||
*
|
||||
* @ingroup controllers_tab_pubIds_form
|
||||
*
|
||||
* @brief Displays a pub ids form.
|
||||
*/
|
||||
|
||||
namespace PKP\controllers\tab\pubIds\form;
|
||||
|
||||
use APP\core\Application;
|
||||
use APP\facades\Repo;
|
||||
use APP\publication\Publication;
|
||||
use APP\submission\Submission;
|
||||
use APP\template\TemplateManager;
|
||||
use PKP\form\Form;
|
||||
use PKP\plugins\PKPPubIdPluginHelper;
|
||||
use PKP\plugins\PluginRegistry;
|
||||
use PKP\submission\Representation;
|
||||
use PKP\submissionFile\SubmissionFile;
|
||||
|
||||
class PKPPublicIdentifiersForm extends Form
|
||||
{
|
||||
/** @var int The context id */
|
||||
public $_contextId;
|
||||
|
||||
/** @var object The pub object the identifiers are edited of
|
||||
* Submission, Representation, SubmissionFile, OJS Issue and OMP Chapter
|
||||
*/
|
||||
public $_pubObject;
|
||||
|
||||
/** @var int The current stage id, WORKFLOW_STAGE_ID_ */
|
||||
public $_stageId;
|
||||
|
||||
/**
|
||||
* @var array Parameters to configure the form template.
|
||||
*/
|
||||
public $_formParams;
|
||||
|
||||
/** @var bool indicates whether the form should be editable */
|
||||
public bool $_isEditable = true;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param object $pubObject
|
||||
* @param int $stageId
|
||||
* @param array $formParams
|
||||
*/
|
||||
public function __construct($pubObject, $stageId = null, $formParams = null, bool $isEditable = true)
|
||||
{
|
||||
parent::__construct('controllers/tab/pubIds/form/publicIdentifiersForm.tpl');
|
||||
|
||||
$this->_pubObject = $pubObject;
|
||||
$this->_stageId = $stageId;
|
||||
$this->_formParams = $formParams;
|
||||
$this->_isEditable = $isEditable;
|
||||
|
||||
$request = Application::get()->getRequest();
|
||||
$context = $request->getContext();
|
||||
$this->_contextId = $context->getId();
|
||||
|
||||
$this->addCheck(new \PKP\form\validation\FormValidatorPost($this));
|
||||
$this->addCheck(new \PKP\form\validation\FormValidatorCSRF($this));
|
||||
|
||||
// action links for pub id reset requests
|
||||
$pubIdPluginHelper = new PKPPubIdPluginHelper();
|
||||
$pubIdPluginHelper->setLinkActions($this->getContextId(), $this, $pubObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc Form::fetch()
|
||||
*
|
||||
* @param null|mixed $template
|
||||
*/
|
||||
public function fetch($request, $template = null, $display = false)
|
||||
{
|
||||
$templateMgr = TemplateManager::getManager($request);
|
||||
$templateMgr->assign([
|
||||
'pubIdPlugins' => PluginRegistry::loadCategory('pubIds', true, $this->getContextId()),
|
||||
'pubObject' => $this->getPubObject(),
|
||||
'stageId' => $this->getStageId(),
|
||||
'formParams' => $this->getFormParams(),
|
||||
'formDisabled' => !$this->_isEditable,
|
||||
]);
|
||||
if ($this->getPubObject() instanceof Representation || $this->getPubObject() instanceof \APP\monograph\Chapter) {
|
||||
$publicationId = $this->getPubObject()->getData('publicationId');
|
||||
$publication = Repo::publication()->get($publicationId);
|
||||
$templateMgr->assign([
|
||||
'submissionId' => $publication->getData('submissionId'),
|
||||
]);
|
||||
}
|
||||
// consider JavaScripts
|
||||
$pubIdPluginHelper = new PKPPubIdPluginHelper();
|
||||
$pubIdPluginHelper->addJavaScripts($this->getContextId(), $request, $templateMgr);
|
||||
return parent::fetch($request, $template, $display);
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc Form::initData()
|
||||
*/
|
||||
public function initData()
|
||||
{
|
||||
$pubObject = $this->getPubObject();
|
||||
$this->setData('publisherId', $pubObject->getStoredPubId('publisher-id'));
|
||||
$pubIdPluginHelper = new PKPPubIdPluginHelper();
|
||||
$pubIdPluginHelper->init($this->getContextId(), $this, $pubObject);
|
||||
return parent::initData();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Getters
|
||||
//
|
||||
/**
|
||||
* Get the pub object
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function getPubObject()
|
||||
{
|
||||
return $this->_pubObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the stage id
|
||||
*
|
||||
* @return int WORKFLOW_STAGE_ID_
|
||||
*/
|
||||
public function getStageId()
|
||||
{
|
||||
return $this->_stageId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the context id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getContextId()
|
||||
{
|
||||
return $this->_contextId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the extra form parameters.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getFormParams()
|
||||
{
|
||||
return $this->_formParams;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Form methods
|
||||
//
|
||||
/**
|
||||
* @copydoc Form::readInputData()
|
||||
*/
|
||||
public function readInputData()
|
||||
{
|
||||
$this->readUserVars(['publisherId']);
|
||||
$pubIdPluginHelper = new PKPPubIdPluginHelper();
|
||||
$pubIdPluginHelper->readInputData($this->getContextId(), $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc Form::validate()
|
||||
*/
|
||||
public function validate($callHooks = true)
|
||||
{
|
||||
$pubObject = $this->getPubObject();
|
||||
$assocType = $this->getAssocType($pubObject);
|
||||
$publisherId = $this->getData('publisherId');
|
||||
$pubObjectId = $pubObject->getId();
|
||||
if ($assocType == Application::ASSOC_TYPE_SUBMISSION_FILE) {
|
||||
$pubObjectId = $pubObject->getId();
|
||||
}
|
||||
$contextDao = Application::getContextDAO();
|
||||
if ($publisherId) {
|
||||
if (ctype_digit((string) $publisherId)) {
|
||||
$this->addError('publisherId', __('editor.publicIdentificationNumericNotAllowed', ['publicIdentifier' => $publisherId]));
|
||||
$this->addErrorField('$publisherId');
|
||||
} elseif (count(explode('/', $publisherId)) > 1) {
|
||||
$this->addError('publisherId', __('editor.publicIdentificationPatternNotAllowed', ['pattern' => '"/"']));
|
||||
$this->addErrorField('$publisherId');
|
||||
} elseif ($pubObject instanceof SubmissionFile && preg_match('/^(\d+)-(\d+)$/', $publisherId)) {
|
||||
$this->addError('publisherId', __('editor.publicIdentificationPatternNotAllowed', ['pattern' => '\'/^(\d+)-(\d+)$/\' i.e. \'number-number\'']));
|
||||
$this->addErrorField('$publisherId');
|
||||
} elseif ($contextDao->anyPubIdExists($this->getContextId(), 'publisher-id', $publisherId, $assocType, $pubObjectId, true)) {
|
||||
$this->addError('publisherId', __('editor.publicIdentificationExistsForTheSameType', ['publicIdentifier' => $publisherId]));
|
||||
$this->addErrorField('$publisherId');
|
||||
}
|
||||
}
|
||||
$pubIdPluginHelper = new PKPPubIdPluginHelper();
|
||||
$pubIdPluginHelper->validate($this->getContextId(), $this, $this->getPubObject());
|
||||
|
||||
if (!$this->_isEditable) {
|
||||
$this->addError('', __('galley.cantEditPublished'));
|
||||
}
|
||||
|
||||
return parent::validate($callHooks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store objects with pub ids.
|
||||
*
|
||||
* @copydoc Form::execute()
|
||||
*/
|
||||
public function execute(...$functionArgs)
|
||||
{
|
||||
parent::execute(...$functionArgs);
|
||||
|
||||
$pubObject = $this->getPubObject();
|
||||
$pubObject->setStoredPubId('publisher-id', $this->getData('publisherId'));
|
||||
|
||||
$pubIdPluginHelper = new PKPPubIdPluginHelper();
|
||||
$pubIdPluginHelper->execute($this->getContextId(), $this, $pubObject);
|
||||
|
||||
if ($pubObject instanceof Representation) {
|
||||
$representationDao = Application::getRepresentationDAO();
|
||||
$representationDao->updateObject($pubObject);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($pubObject instanceof SubmissionFile) {
|
||||
Repo::submissionFile()->edit($pubObject, []);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear pub id.
|
||||
*
|
||||
* @param string $pubIdPlugInClassName
|
||||
*/
|
||||
public function clearPubId($pubIdPlugInClassName)
|
||||
{
|
||||
$pubIdPluginHelper = new PKPPubIdPluginHelper();
|
||||
$pubIdPluginHelper->clearPubId($this->getContextId(), $pubIdPlugInClassName, $this->getPubObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get assoc type of the given object.
|
||||
*
|
||||
* @param object $pubObject
|
||||
*
|
||||
* @return ?int Application::ASSOC_TYPE_
|
||||
*/
|
||||
public function getAssocType($pubObject)
|
||||
{
|
||||
if ($pubObject instanceof Submission) {
|
||||
return Application::ASSOC_TYPE_SUBMISSION;
|
||||
}
|
||||
|
||||
if ($pubObject instanceof Publication) {
|
||||
return Application::ASSOC_TYPE_PUBLICATION;
|
||||
}
|
||||
|
||||
if ($pubObject instanceof Representation) {
|
||||
return Application::ASSOC_TYPE_REPRESENTATION;
|
||||
}
|
||||
|
||||
if ($pubObject instanceof SubmissionFile) {
|
||||
return Application::ASSOC_TYPE_SUBMISSION_FILE;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,372 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @defgroup controllers_tab_user
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file controllers/tab/user/ProfileTabHandler.php
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2003-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class ProfileTabHandler
|
||||
*
|
||||
* @ingroup controllers_tab_user
|
||||
*
|
||||
* @brief Handle requests for profile tab operations.
|
||||
*/
|
||||
|
||||
namespace PKP\controllers\tab\user;
|
||||
|
||||
use APP\handler\Handler;
|
||||
use APP\notification\form\NotificationSettingsForm;
|
||||
use APP\notification\NotificationManager;
|
||||
use PKP\core\JSONMessage;
|
||||
use PKP\core\PKPApplication;
|
||||
use PKP\core\PKPRequest;
|
||||
use PKP\security\authorization\UserRequiredPolicy;
|
||||
use PKP\session\SessionManager;
|
||||
use PKP\user\form\APIProfileForm;
|
||||
use PKP\user\form\ChangePasswordForm;
|
||||
use PKP\user\form\ContactForm;
|
||||
use PKP\user\form\IdentityForm;
|
||||
use PKP\user\form\PublicProfileForm;
|
||||
use PKP\user\form\RolesForm;
|
||||
|
||||
class ProfileTabHandler extends Handler
|
||||
{
|
||||
//
|
||||
// Implement template methods from PKPHandler
|
||||
//
|
||||
/**
|
||||
* @copydoc PKPHandler::authorize()
|
||||
*/
|
||||
public function authorize($request, &$args, $roleAssignments)
|
||||
{
|
||||
// User must be logged in
|
||||
$this->addPolicy(new UserRequiredPolicy($request));
|
||||
|
||||
return parent::authorize($request, $args, $roleAssignments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display form to edit user's identity.
|
||||
*
|
||||
* @param array $args
|
||||
* @param PKPRequest $request
|
||||
*
|
||||
* @return JSONMessage JSON-formatted response
|
||||
*/
|
||||
public function identity($args, $request)
|
||||
{
|
||||
$this->setupTemplate($request);
|
||||
$identityForm = new IdentityForm($request->getUser());
|
||||
$identityForm->initData();
|
||||
return new JSONMessage(true, $identityForm->fetch($request));
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate and save changes to user's identity info.
|
||||
*
|
||||
* @param array $args
|
||||
* @param PKPRequest $request
|
||||
*
|
||||
* @return JSONMessage JSON-formatted response
|
||||
*/
|
||||
public function saveIdentity($args, $request)
|
||||
{
|
||||
$this->setupTemplate($request);
|
||||
|
||||
$identityForm = new IdentityForm($request->getUser());
|
||||
$identityForm->readInputData();
|
||||
if ($identityForm->validate()) {
|
||||
$identityForm->execute();
|
||||
$notificationMgr = new NotificationManager();
|
||||
$notificationMgr->createTrivialNotification($request->getUser()->getId());
|
||||
return new JSONMessage(true);
|
||||
}
|
||||
return new JSONMessage(true, $identityForm->fetch($request));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display form to edit user's contact information.
|
||||
*
|
||||
* @param array $args
|
||||
* @param PKPRequest $request
|
||||
*
|
||||
* @return JSONMessage JSON-formatted response
|
||||
*/
|
||||
public function contact($args, $request)
|
||||
{
|
||||
$this->setupTemplate($request);
|
||||
$contactForm = new ContactForm($request->getUser());
|
||||
$contactForm->initData();
|
||||
return new JSONMessage(true, $contactForm->fetch($request));
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate and save changes to user's contact info.
|
||||
*
|
||||
* @param array $args
|
||||
* @param PKPRequest $request
|
||||
*
|
||||
* @return JSONMessage JSON-formatted response
|
||||
*/
|
||||
public function saveContact($args, $request)
|
||||
{
|
||||
$this->setupTemplate($request);
|
||||
|
||||
$contactForm = new ContactForm($request->getUser());
|
||||
$contactForm->readInputData();
|
||||
if ($contactForm->validate()) {
|
||||
$contactForm->execute();
|
||||
$notificationMgr = new NotificationManager();
|
||||
$notificationMgr->createTrivialNotification($request->getUser()->getId());
|
||||
return new JSONMessage(true);
|
||||
}
|
||||
return new JSONMessage(true, $contactForm->fetch($request));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display form to edit user's roles information.
|
||||
*
|
||||
* @param array $args
|
||||
* @param PKPRequest $request
|
||||
*
|
||||
* @return JSONMessage JSON-formatted response
|
||||
*/
|
||||
public function roles($args, $request)
|
||||
{
|
||||
$this->setupTemplate($request);
|
||||
$rolesForm = new RolesForm($request->getUser());
|
||||
$rolesForm->initData();
|
||||
return new JSONMessage(true, $rolesForm->fetch($request));
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate and save changes to user's roles info.
|
||||
*
|
||||
* @param array $args
|
||||
* @param PKPRequest $request
|
||||
*
|
||||
* @return JSONMessage JSON-formatted response
|
||||
*/
|
||||
public function saveRoles($args, $request)
|
||||
{
|
||||
$this->setupTemplate($request);
|
||||
|
||||
$rolesForm = new RolesForm($request->getUser());
|
||||
$rolesForm->readInputData();
|
||||
if ($rolesForm->validate()) {
|
||||
$rolesForm->execute();
|
||||
$notificationMgr = new NotificationManager();
|
||||
$notificationMgr->createTrivialNotification($request->getUser()->getId());
|
||||
return new JSONMessage(true);
|
||||
}
|
||||
return new JSONMessage(false, $rolesForm->fetch($request));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display form to edit user's publicProfile information.
|
||||
*
|
||||
* @param array $args
|
||||
* @param PKPRequest $request
|
||||
*
|
||||
* @return JSONMessage JSON-formatted response
|
||||
*/
|
||||
public function publicProfile($args, $request)
|
||||
{
|
||||
$this->setupTemplate($request);
|
||||
$publicProfileForm = new PublicProfileForm($request->getUser());
|
||||
$publicProfileForm->initData();
|
||||
return new JSONMessage(true, $publicProfileForm->fetch($request));
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload a public profile image.
|
||||
*
|
||||
* @param array $args
|
||||
* @param PKPRequest $request
|
||||
*
|
||||
* @return JSONMessage JSON-formatted response
|
||||
*/
|
||||
public function uploadProfileImage($args, $request)
|
||||
{
|
||||
$publicProfileForm = new PublicProfileForm($request->getUser());
|
||||
$result = $publicProfileForm->uploadProfileImage();
|
||||
if ($result) {
|
||||
return $request->redirectUrlJson($request->getDispatcher()->url($request, PKPApplication::ROUTE_PAGE, null, 'user', 'profile', null, ['uniq' => uniqid()], 'publicProfile'));
|
||||
} else {
|
||||
return new JSONMessage(false, __('common.uploadFailed'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a public profile image.
|
||||
*
|
||||
* @param array $args
|
||||
* @param PKPRequest $request
|
||||
*/
|
||||
public function deleteProfileImage($args, $request)
|
||||
{
|
||||
$publicProfileForm = new PublicProfileForm($request->getUser());
|
||||
$publicProfileForm->deleteProfileImage();
|
||||
$request->redirectUrl($request->getDispatcher()->url($request, PKPApplication::ROUTE_PAGE, null, 'user', 'profile', null, ['uniq' => uniqid()], 'publicProfile'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate and save changes to user's publicProfile info.
|
||||
*
|
||||
* @param array $args
|
||||
* @param PKPRequest $request
|
||||
*
|
||||
* @return JSONMessage JSON-formatted response
|
||||
*/
|
||||
public function savePublicProfile($args, $request)
|
||||
{
|
||||
$this->setupTemplate($request);
|
||||
|
||||
$publicProfileForm = new PublicProfileForm($request->getUser());
|
||||
$publicProfileForm->readInputData();
|
||||
if ($publicProfileForm->validate()) {
|
||||
$publicProfileForm->execute();
|
||||
$notificationMgr = new NotificationManager();
|
||||
$notificationMgr->createTrivialNotification($request->getUser()->getId());
|
||||
return new JSONMessage(true);
|
||||
}
|
||||
return new JSONMessage(true, $publicProfileForm->fetch($request));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display form to edit user's API key settings.
|
||||
*
|
||||
* @param array $args
|
||||
* @param PKPRequest $request
|
||||
*
|
||||
* @return JSONMessage JSON-formatted response
|
||||
*/
|
||||
public function apiProfile($args, $request)
|
||||
{
|
||||
$this->setupTemplate($request);
|
||||
$apiProfileForm = new APIProfileForm($request->getUser());
|
||||
$apiProfileForm->initData();
|
||||
return new JSONMessage(true, $apiProfileForm->fetch($request));
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate and save changes to user's API key settings.
|
||||
*
|
||||
* @param array $args
|
||||
* @param PKPRequest $request
|
||||
*
|
||||
* @return JSONMessage JSON-formatted response
|
||||
*/
|
||||
public function saveAPIProfile($args, $request)
|
||||
{
|
||||
$this->setupTemplate($request);
|
||||
|
||||
$apiProfileForm = new APIProfileForm($request->getUser());
|
||||
$apiProfileForm->readInputData();
|
||||
if ($apiProfileForm->validate()) {
|
||||
$apiProfileForm->execute();
|
||||
$notificationMgr = new NotificationManager();
|
||||
$notificationMgr->createTrivialNotification($request->getUser()->getId());
|
||||
return new JSONMessage(true, $apiProfileForm->fetch($request));
|
||||
}
|
||||
return new JSONMessage(true, $apiProfileForm->fetch($request));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display form to change user's password.
|
||||
*
|
||||
* @param array $args
|
||||
* @param PKPRequest $request
|
||||
*
|
||||
* @return JSONMessage JSON-formatted response
|
||||
*/
|
||||
public function changePassword($args, $request)
|
||||
{
|
||||
$this->setupTemplate($request);
|
||||
$passwordForm = new ChangePasswordForm($request->getUser(), $request->getSite());
|
||||
$passwordForm->initData();
|
||||
return new JSONMessage(true, $passwordForm->fetch($request));
|
||||
}
|
||||
|
||||
/**
|
||||
* Save user's new password.
|
||||
*
|
||||
* @param array $args
|
||||
* @param PKPRequest $request
|
||||
*
|
||||
* @return JSONMessage JSON-formatted response
|
||||
*/
|
||||
public function savePassword($args, $request)
|
||||
{
|
||||
$this->setupTemplate($request);
|
||||
|
||||
$user = $request->getUser();
|
||||
|
||||
$passwordForm = new ChangePasswordForm($user, $request->getSite());
|
||||
$passwordForm->readInputData();
|
||||
|
||||
if ($passwordForm->validate()) {
|
||||
$passwordForm->execute();
|
||||
|
||||
$sessionManager = SessionManager::getManager();
|
||||
$sessionManager->invalidateSessions($user->getId(), $sessionManager->getUserSession()->getId());
|
||||
|
||||
$notificationMgr = new NotificationManager();
|
||||
$notificationMgr->createTrivialNotification($user->getId());
|
||||
|
||||
return new JSONMessage(true);
|
||||
}
|
||||
|
||||
return new JSONMessage(true, $passwordForm->fetch($request));
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch notifications tab content.
|
||||
*
|
||||
* @param array $args
|
||||
* @param PKPRequest $request
|
||||
*
|
||||
* @return JSONMessage JSON-formatted response
|
||||
*/
|
||||
public function notificationSettings($args, $request)
|
||||
{
|
||||
$this->setupTemplate($request);
|
||||
|
||||
$user = $request->getUser();
|
||||
$notificationSettingsForm = new NotificationSettingsForm();
|
||||
return new JSONMessage(true, $notificationSettingsForm->fetch($request));
|
||||
}
|
||||
|
||||
/**
|
||||
* Save user notification settings.
|
||||
*
|
||||
* @param array $args
|
||||
* @param PKPRequest $request
|
||||
*
|
||||
* @return JSONMessage JSON-formatted response
|
||||
*/
|
||||
public function saveNotificationSettings($args, $request)
|
||||
{
|
||||
$this->setupTemplate($request);
|
||||
|
||||
$notificationSettingsForm = new NotificationSettingsForm();
|
||||
$notificationSettingsForm->readInputData();
|
||||
|
||||
$json = new JSONMessage();
|
||||
if ($notificationSettingsForm->validate()) {
|
||||
$notificationSettingsForm->execute();
|
||||
$notificationMgr = new NotificationManager();
|
||||
$notificationMgr->createTrivialNotification($request->getUser()->getId());
|
||||
} else {
|
||||
$json->setStatus(false);
|
||||
}
|
||||
|
||||
return $json;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file controllers/tab/workflow/PKPWorkflowTabHandler.php
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2003-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class PKPWorkflowTabHandler
|
||||
*
|
||||
* @ingroup controllers_tab_workflow
|
||||
*
|
||||
* @brief Handle AJAX operations for workflow tabs.
|
||||
*/
|
||||
|
||||
namespace PKP\controllers\tab\workflow;
|
||||
|
||||
use APP\core\Application;
|
||||
use APP\core\Request;
|
||||
use APP\handler\Handler;
|
||||
use APP\notification\Notification;
|
||||
use APP\notification\NotificationManager;
|
||||
use APP\submission\Submission;
|
||||
use APP\template\TemplateManager;
|
||||
use PKP\core\JSONMessage;
|
||||
use PKP\core\PKPApplication;
|
||||
use PKP\db\DAORegistry;
|
||||
use PKP\decision\DecisionType;
|
||||
use PKP\notification\PKPNotification;
|
||||
use PKP\security\authorization\WorkflowStageAccessPolicy;
|
||||
use PKP\security\Role;
|
||||
use PKP\submission\reviewRound\ReviewRoundDAO;
|
||||
|
||||
abstract class PKPWorkflowTabHandler extends Handler
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->addRoleAssignment([Role::ROLE_ID_SUB_EDITOR, Role::ROLE_ID_MANAGER, Role::ROLE_ID_SITE_ADMIN, Role::ROLE_ID_ASSISTANT], ['fetchTab']);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Extended methods from Handler
|
||||
//
|
||||
/**
|
||||
* @copydoc PKPHandler::authorize()
|
||||
*/
|
||||
public function authorize($request, &$args, $roleAssignments)
|
||||
{
|
||||
// Authorize stage id.
|
||||
$this->addPolicy(new WorkflowStageAccessPolicy($request, $args, $roleAssignments, 'submissionId', $this->_identifyStageId($request), PKPApplication::WORKFLOW_TYPE_EDITORIAL));
|
||||
|
||||
return parent::authorize($request, $args, $roleAssignments);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Public handler operations
|
||||
//
|
||||
/**
|
||||
* Fetch the specified workflow tab.
|
||||
*
|
||||
* @param array $args
|
||||
* @param Request $request
|
||||
*
|
||||
* @return JSONMessage JSON object
|
||||
*/
|
||||
public function fetchTab($args, $request)
|
||||
{
|
||||
$this->setupTemplate($request);
|
||||
$templateMgr = TemplateManager::getManager($request);
|
||||
|
||||
$stageId = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_WORKFLOW_STAGE);
|
||||
$templateMgr->assign('stageId', $stageId);
|
||||
|
||||
/** @var Submission $submission */
|
||||
$submission = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_SUBMISSION);
|
||||
$templateMgr->assign('submission', $submission);
|
||||
|
||||
switch ($stageId) {
|
||||
case WORKFLOW_STAGE_ID_SUBMISSION:
|
||||
return $templateMgr->fetchJson('controllers/tab/workflow/submission.tpl');
|
||||
case WORKFLOW_STAGE_ID_INTERNAL_REVIEW:
|
||||
case WORKFLOW_STAGE_ID_EXTERNAL_REVIEW:
|
||||
// Retrieve the authorized submission and stage id.
|
||||
$selectedStageId = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_WORKFLOW_STAGE);
|
||||
|
||||
// Get all review rounds for this submission, on the current stage.
|
||||
$reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO'); /** @var ReviewRoundDAO $reviewRoundDao */
|
||||
$reviewRoundsFactory = $reviewRoundDao->getBySubmissionId($submission->getId(), $selectedStageId);
|
||||
$reviewRoundsArray = $reviewRoundsFactory->toAssociativeArray();
|
||||
$lastReviewRound = $reviewRoundDao->getLastReviewRoundBySubmissionId($submission->getId(), $selectedStageId);
|
||||
|
||||
// Get the review round number of the last review round to be used
|
||||
// as the current review round tab index, if we have review rounds.
|
||||
if ($lastReviewRound) {
|
||||
$lastReviewRoundNumber = $lastReviewRound->getRound();
|
||||
$templateMgr->assign('lastReviewRoundNumber', $lastReviewRoundNumber);
|
||||
}
|
||||
|
||||
// Add the round information to the template.
|
||||
$templateMgr->assign('reviewRounds', $reviewRoundsArray);
|
||||
$templateMgr->assign('reviewRoundOp', $this->_identifyReviewRoundOp($stageId));
|
||||
|
||||
if ($submission->getStageId() == $selectedStageId && count($reviewRoundsArray) > 0) {
|
||||
$newReviewRoundType = $this->getNewReviewRoundDecisionType($stageId);
|
||||
$templateMgr->assign(
|
||||
'newRoundUrl',
|
||||
$newReviewRoundType->getUrl($request, $request->getContext(), $submission, $lastReviewRound->getId())
|
||||
);
|
||||
}
|
||||
|
||||
// Render the view.
|
||||
return $templateMgr->fetchJson('controllers/tab/workflow/review.tpl');
|
||||
case WORKFLOW_STAGE_ID_EDITING:
|
||||
// Assign banner notifications to the template.
|
||||
$notificationRequestOptions = [
|
||||
Notification::NOTIFICATION_LEVEL_NORMAL => [
|
||||
PKPNotification::NOTIFICATION_TYPE_ASSIGN_COPYEDITOR => [Application::ASSOC_TYPE_SUBMISSION, $submission->getId()],
|
||||
PKPNotification::NOTIFICATION_TYPE_AWAITING_COPYEDITS => [Application::ASSOC_TYPE_SUBMISSION, $submission->getId()]],
|
||||
Notification::NOTIFICATION_LEVEL_TRIVIAL => []
|
||||
];
|
||||
$templateMgr->assign('editingNotificationRequestOptions', $notificationRequestOptions);
|
||||
return $templateMgr->fetchJson('controllers/tab/workflow/editorial.tpl');
|
||||
case WORKFLOW_STAGE_ID_PRODUCTION:
|
||||
$templateMgr = TemplateManager::getManager($request);
|
||||
$notificationRequestOptions = $this->getProductionNotificationOptions($submission->getId());
|
||||
$selectedStageId = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_WORKFLOW_STAGE);
|
||||
$templateMgr->assign('productionNotificationRequestOptions', $notificationRequestOptions);
|
||||
|
||||
return $templateMgr->fetchJson('controllers/tab/workflow/production.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup variables for the template
|
||||
*
|
||||
* @param Request $request
|
||||
*/
|
||||
public function setupTemplate($request)
|
||||
{
|
||||
parent::setupTemplate($request);
|
||||
|
||||
$submission = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_SUBMISSION);
|
||||
$stageId = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_WORKFLOW_STAGE);
|
||||
|
||||
$templateMgr = TemplateManager::getManager($request);
|
||||
|
||||
// Assign the authorized submission.
|
||||
$templateMgr->assign('submission', $submission);
|
||||
|
||||
// Assign workflow stages related data.
|
||||
$templateMgr->assign('stageId', $stageId);
|
||||
$templateMgr->assign('submissionStageId', $submission->getStageId());
|
||||
|
||||
// Get the right notifications type based on current stage id.
|
||||
$notificationMgr = new NotificationManager();
|
||||
$editorAssignmentNotificationType = $this->getEditorAssignmentNotificationTypeByStageId($stageId);
|
||||
|
||||
// Define the workflow notification options.
|
||||
$notificationRequestOptions = [
|
||||
Notification::NOTIFICATION_LEVEL_TASK => [
|
||||
$editorAssignmentNotificationType => [Application::ASSOC_TYPE_SUBMISSION, $submission->getId()]
|
||||
],
|
||||
Notification::NOTIFICATION_LEVEL_TRIVIAL => []
|
||||
];
|
||||
|
||||
$templateMgr->assign('workflowNotificationRequestOptions', $notificationRequestOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the editor assignment notification type based on stage id.
|
||||
*
|
||||
* @param int $stageId
|
||||
*
|
||||
* @return ?int
|
||||
*/
|
||||
protected function getEditorAssignmentNotificationTypeByStageId($stageId)
|
||||
{
|
||||
switch ($stageId) {
|
||||
case WORKFLOW_STAGE_ID_SUBMISSION:
|
||||
return PKPNotification::NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_SUBMISSION;
|
||||
case WORKFLOW_STAGE_ID_EXTERNAL_REVIEW:
|
||||
return PKPNotification::NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_EXTERNAL_REVIEW;
|
||||
case WORKFLOW_STAGE_ID_EDITING:
|
||||
return PKPNotification::NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_EDITING;
|
||||
case WORKFLOW_STAGE_ID_PRODUCTION:
|
||||
return PKPNotification::NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_PRODUCTION;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all production notification options to be used in the production stage tab.
|
||||
*
|
||||
* @param int $submissionId
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
abstract protected function getProductionNotificationOptions($submissionId);
|
||||
|
||||
/**
|
||||
* Get the decision type to create a new review round in this stage id
|
||||
*
|
||||
* @param int $stageId Must be one of the review stages, WORKFLOW_STAGE_ID_
|
||||
*/
|
||||
abstract protected function getNewReviewRoundDecisionType(int $stageId): DecisionType;
|
||||
|
||||
/**
|
||||
* Translate the requested operation to a stage id.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return int One of the WORKFLOW_STAGE_* constants.
|
||||
*/
|
||||
private function _identifyStageId($request)
|
||||
{
|
||||
if ($stageId = $request->getUserVar('stageId')) {
|
||||
return (int) $stageId;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Identifies the review round.
|
||||
*
|
||||
* @param int $stageId
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function _identifyReviewRoundOp($stageId)
|
||||
{
|
||||
switch ($stageId) {
|
||||
case WORKFLOW_STAGE_ID_INTERNAL_REVIEW:
|
||||
return 'internalReviewRound';
|
||||
case WORKFLOW_STAGE_ID_EXTERNAL_REVIEW:
|
||||
return 'externalReviewRound';
|
||||
default:
|
||||
fatalError('unknown review round id.');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user