Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function __construct() {
// Managers and Editors additionally get administrative access
$this->addRoleAssignment(
array(ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR),
array_merge($peOps, array('addParticipant', 'deleteParticipant', 'saveParticipant', 'fetchUserList'))
array_merge($peOps, array('addParticipant', 'saveParticipant', 'fetchUserList', 'removeParticipant', 'removeStageAssignment'))
);
$this->setTitle('editor.submission.stageParticipants');
}
Expand Down Expand Up @@ -356,12 +356,34 @@ function saveParticipant($args, $request) {
}

/**
* Delete the participant from the user groups
* @param $args
* @param $request
* @return JSONMessage JSON object
* Show a confirmation form to remove a stage participant, with optional email notification.
* @param $args array
* @param $request PKPRequest
* @return JSONMessage
*/
function removeParticipant($args, $request) {
$submission = $this->getSubmission();
$assignmentId = (int) $request->getUserVar('assignmentId');

$stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO'); /* @var $stageAssignmentDao StageAssignmentDAO */
$stageAssignment = $stageAssignmentDao->getById($assignmentId);
if (!$stageAssignment || $stageAssignment->getSubmissionId() != $submission->getId()) {
return new JSONMessage(false);
}

import('lib.pkp.controllers.grid.users.stageParticipant.form.RemoveParticipantForm');
$form = new RemoveParticipantForm($submission, $stageAssignment, $this->getStageId());
$form->initData();
return new JSONMessage(true, $form->fetch($request));
}

/**
* Handle removal form submission: optionally email the user and then remove the assignment.
* @param $args array
* @param $request PKPRequest
* @return JSONMessage
*/
function deleteParticipant($args, $request) {
function removeStageAssignment($args, $request) {
$submission = $this->getSubmission();
$stageId = $this->getStageId();
$assignmentId = (int) $request->getUserVar('assignmentId');
Expand All @@ -372,48 +394,29 @@ function deleteParticipant($args, $request) {
return new JSONMessage(false);
}

// Delete the assignment
$stageAssignmentDao->deleteObject($stageAssignment);
import('lib.pkp.controllers.grid.users.stageParticipant.form.RemoveParticipantForm');
$form = new RemoveParticipantForm($submission, $stageAssignment, $stageId);
$form->readInputData();
if (!$form->validate()) {
return new JSONMessage(true, $form->fetch($request));
}

// FIXME: perhaps we can just insert the notification on page load
// instead of having it there all the time?
$notificationMgr = new NotificationManager();
import('classes.workflow.EditorDecisionActionsManager');
$notificationMgr->updateNotification(
$request,
(new EditorDecisionActionsManager())->getStageNotifications(),
null,
ASSOC_TYPE_SUBMISSION,
$submission->getId()
);
$form->execute();

if ($stageId == WORKFLOW_STAGE_ID_EDITING ||
$stageId == WORKFLOW_STAGE_ID_PRODUCTION) {
$stageAssignmentDao->deleteObject($stageAssignment);

// Update submission notifications
$notificationMgr->updateNotification(
$request,
array(
NOTIFICATION_TYPE_ASSIGN_COPYEDITOR,
NOTIFICATION_TYPE_AWAITING_COPYEDITS,
NOTIFICATION_TYPE_ASSIGN_PRODUCTIONUSER,
NOTIFICATION_TYPE_AWAITING_REPRESENTATIONS,
),
null,
ASSOC_TYPE_SUBMISSION,
$submission->getId()
);
}
$notificationMgr = new NotificationManager();

// Log removal.
$userDao = DAORegistry::getDAO('UserDAO'); /* @var $userDao UserDAO */
$assignedUser = $userDao->getById($stageAssignment->getUserId());
$userGroupDao = DAORegistry::getDAO('UserGroupDAO'); /* @var $userGroupDao UserGroupDAO */
$userGroup = $userGroupDao->getById($stageAssignment->getUserGroupId());
import('lib.pkp.classes.log.SubmissionLog');
SubmissionLog::logEvent($request, $submission, SUBMISSION_LOG_REMOVE_PARTICIPANT, 'submission.event.participantRemoved', array('name' => $assignedUser->getFullName(), 'username' => $assignedUser->getUsername(), 'userGroupName' => $userGroup->getLocalizedName()));

// Redraw the category
$currentUser = $request->getUser();
$notificationMgr->createTrivialNotification($currentUser->getId(), NOTIFICATION_TYPE_SUCCESS);

return DAO::getDataChangedEvent($stageAssignment->getUserGroupId());
}

Expand Down Expand Up @@ -547,6 +550,4 @@ function fetchTemplateBody($args, $request) {
public function getJSHandler() {
return '$.pkp.controllers.grid.users.stageParticipant.StageParticipantGridHandler';
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,14 @@ function initialize($request, $template = null) {
if ($this->_canAdminister) {
$this->addAction(new LinkAction(
'delete',
new RemoteActionConfirmationModal(
$request->getSession(),
__('editor.submission.removeStageParticipant.description'),
__('editor.submission.removeStageParticipant'),
$router->url($request, null, null, 'deleteParticipant', null, $this->getRequestArgs()),
'modal_delete'
),
__('grid.action.remove'),
'delete'
)
);
new AjaxModal(
$router->url($request, null, null, 'removeParticipant', null, $this->getRequestArgs()),
__('editor.submission.removeStageParticipant'),
'modal_delete'
),
__('grid.action.remove'),
'delete'
));

$this->addAction(new LinkAction(
'requestAccount',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<?php

/**
* @file lib/pkp/controllers/grid/users/stageParticipant/form/RemoveParticipantForm.inc.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 RemoveParticipantForm
* @ingroup controllers_grid_users_stageParticipant_form
*
* @brief Form to optionally notify a user when removing them as a stage participant.
*/

import('lib.pkp.classes.form.Form');

class RemoveParticipantForm extends Form {
/** @var Submission */
var $_submission;

/** @var int */
var $_stageId;

/** @var StageAssignment */
var $_stageAssignment;

/**
* Constructor
* @param $submission Submission
* @param $stageAssignment StageAssignment
* @param $stageId int
*/
function __construct($submission, $stageAssignment, $stageId) {
parent::__construct('controllers/grid/users/stageParticipant/removeParticipantForm.tpl');
$this->_submission = $submission;
$this->_stageAssignment = $stageAssignment;
$this->_stageId = $stageId;

$this->addCheck(new FormValidatorPost($this));
$this->addCheck(new FormValidatorCSRF($this));
}

/**
* Initialize form data
*/
function initData() {
$request = Application::get()->getRequest();
$user = $request->getUser();
$submission = $this->_submission;
$userTobeRemovedId = $this->_stageAssignment->getUserId();
$userDao = DAORegistry::getDAO('UserDAO'); /* @var $userDao UserDAO */
$userToBeRemoved = $userDao->getById($userTobeRemovedId);

$defaultMessage = __('editor.submission.removeStageParticipant.email.body', [
'userName' => $userToBeRemoved->getFullName(),
'contextName' => $request->getContext()->getLocalizedName(),
'submissionTitle' => $submission->getLocalizedTitle()
]);
$defaultMessage .= $user->getContactSignature();

$this->setData('assignmentId', $this->_stageAssignment->getId());
$this->setData('stageId', $this->_stageId);
$this->setData('submissionId', $submission->getId());
$this->setData('personalMessage', $defaultMessage);
$this->setData('skipEmail', false);
}

/**
* @copydoc Form::fetch()
*/
function fetch($request, $template = null, $display = false) {
$templateMgr = TemplateManager::getManager($request);
$templateMgr->assign(array(
'reviewRoundId' => null,
'reviewerId' => $this->_stageAssignment->getUserId(),
'assignmentId' => $this->_stageAssignment->getId(),
'stageId' => $this->_stageId,
'submissionId' => $this->_submission->getId(),
'personalMessage' => $this->getData('personalMessage'),
));
return parent::fetch($request, $template, $display);
}

/**
* @copydoc Form::readInputData()
*/
function readInputData() {
$this->readUserVars(array('assignmentId', 'stageId', 'submissionId', 'personalMessage', 'skipEmail'));
}

/**
* @copydoc Form::validate()
*/
function validate(...$functionArgs) {
return parent::validate(...$functionArgs);
}

/**
* @copydoc Form::execute()
*/
function execute(...$functionArgs) {
$request = Application::get()->getRequest();
if ($this->getData('skipEmail')) return parent::execute(...$functionArgs);

$submission = $this->_submission;
$fromUser = $request->getUser();

$userDao = DAORegistry::getDAO('UserDAO'); /* @var $userDao UserDAO */
$user = $userDao->getById($this->_stageAssignment->getUserId());
if (!$user) return parent::execute(...$functionArgs);

import('classes.mail.ArticleMailTemplate');
$mail = new ArticleMailTemplate($submission, 'NOTIFICATION_CENTER_DEFAULT');
$mail->addRecipient($user->getEmail(), $user->getFullName());
$mail->setSubject(__('editor.submission.removeStageParticipant'));
$mail->setBody($this->getData('personalMessage'));

if ($mail->isEnabled() && !$mail->send($request)) {
$notificationMgr = new NotificationManager();
$notificationMgr->createTrivialNotification($fromUser->getId(), NOTIFICATION_TYPE_ERROR, array('contents' => __('email.compose.error')));
}

return parent::execute(...$functionArgs);
}
}
9 changes: 9 additions & 0 deletions locale/en_US/submission.po
Original file line number Diff line number Diff line change
Expand Up @@ -1388,6 +1388,15 @@ msgstr ""
msgid "editor.submission.removeStageParticipant"
msgstr "Remove Participant"

msgid "editor.submission.removeStageParticipant.email.body"
msgstr ""
"\n"
"\t\t\t{$userName}:<br />\n"
"<br />\n"
"You have been removed as a participant in the &quot;{$submissionTitle}&quot; submission, "
"on the {$contextName}.<br />\n"
"<br />\n"

msgid "editor.submission.removeStageParticipant.description"
msgstr ""
"You are about to remove this participant from <strong>all</strong> stages."
Expand Down
11 changes: 10 additions & 1 deletion locale/es_ES/submission.po
Original file line number Diff line number Diff line change
Expand Up @@ -1412,6 +1412,15 @@ msgstr ""
msgid "editor.submission.removeStageParticipant"
msgstr "Eliminar participante"

msgid "editor.submission.removeStageParticipant.email.body"
msgstr ""
"\n"
"\t\t\t{$userName}:<br />\n"
"<br />\n"
"Has sido eliminado como participante de lo envío &quot;{$submissionTitle}&quot;, "
"en {$contextName}.<br />\n"
"<br />\n"

msgid "editor.submission.removeStageParticipant.description"
msgstr ""
"Está a punto de eliminar a este participante de <strong>todas</strong> las "
Expand Down Expand Up @@ -2209,4 +2218,4 @@ msgstr ""
#~ msgstr "Explorar {$numTitles} títulos"

#~ msgid "catalog.noTitlesSection"
#~ msgstr "No se ha publicado ningún título aún para esta sección."
#~ msgstr "No se ha publicado ningún título aún para esta sección."
11 changes: 10 additions & 1 deletion locale/pt_BR/submission.po
Original file line number Diff line number Diff line change
Expand Up @@ -1398,6 +1398,15 @@ msgstr ""
msgid "editor.submission.removeStageParticipant"
msgstr "Remover Participante"

msgid "editor.submission.removeStageParticipant.email.body"
msgstr ""
"\n"
"\t\t\t{$userName}:<br />\n"
"<br />\n"
"Você foi removido como participante da submissão &quot;{$submissionTitle}&quot;, "
"em {$contextName}.<br />\n"
"<br />\n"

msgid "editor.submission.removeStageParticipant.description"
msgstr ""
"Você está prestes a remover este participante de <strong>todos</strong> os "
Expand Down Expand Up @@ -2555,4 +2564,4 @@ msgstr "Por favor, divulgue quaisquer conflitos de interesse que este autor poss
#~ msgstr "{$numTitles} títulos"

#~ msgid "catalog.noTitlesSection"
#~ msgstr "Sem publicações para esta seção no momento."
#~ msgstr "Sem publicações para esta seção no momento."
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{**
* templates/controllers/grid/users/stageParticipant/removeParticipantForm.tpl
*
* 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.
*
* Form to optionally notify a user when removing them as a stage participant.
*}

<script type="text/javascript">
$(function() {ldelim}
$('#removeParticipantForm').pkpHandler('$.pkp.controllers.form.AjaxFormHandler');
{rdelim});
</script>

<form class="pkp_form" id="removeParticipantForm" method="post" action="{url op="removeStageAssignment"}" >
{csrf}
<input type="hidden" name="assignmentId" value="{$assignmentId|escape}" />
<input type="hidden" name="stageId" value="{$stageId|escape}" />
<input type="hidden" name="submissionId" value="{$submissionId|escape}" />

{fbvFormSection title="stageParticipants.notify.message" for="personalMessage"}
{fbvElement type="textarea" name="personalMessage" id="personalMessage" value=$personalMessage rich=true}
{/fbvFormSection}

{fbvFormSection for="skipEmail" size=$fbvStyles.size.MEDIUM list=true}
{fbvElement type="checkbox" id="skipEmail" name="skipEmail" label="email.skip"}
{/fbvFormSection}

{fbvFormButtons submitText="grid.action.remove"}
</form>