17 import(
'lib.pkp.classes.controllers.grid.CategoryGridHandler');
20 import(
'lib.pkp.controllers.grid.users.stageParticipant.StageParticipantGridRow');
21 import(
'lib.pkp.controllers.grid.users.stageParticipant.StageParticipantGridCategoryRow');
22 import(
'classes.log.SubmissionEventLogEntry');
24 import(
'lib.pkp.classes.linkAction.request.RemoteActionConfirmationModal');
31 parent::__construct();
35 array(ROLE_ID_ASSISTANT),
36 $peOps = array(
'fetchGrid',
'fetchCategory',
'fetchRow',
'viewNotify',
'fetchTemplateBody',
'sendNotification')
41 array(ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR),
42 array_merge($peOps, array(
'addParticipant',
'deleteParticipant',
'saveParticipant',
'fetchUserList'))
44 $this->
setTitle(
'editor.submission.stageParticipants');
73 function authorize($request, &$args, $roleAssignments) {
74 $stageId = (int) $request->getUserVar(
'stageId');
75 import(
'lib.pkp.classes.security.authorization.WorkflowStageAccessPolicy');
77 return parent::authorize($request, $args, $roleAssignments);
87 return (
boolean) array_intersect(
88 array(ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR),
98 parent::initialize($request, $args);
102 LOCALE_COMPONENT_APP_EDITOR,
103 LOCALE_COMPONENT_PKP_USER,
104 LOCALE_COMPONENT_APP_DEFAULT,
105 LOCALE_COMPONENT_PKP_DEFAULT,
106 LOCALE_COMPONENT_PKP_SUBMISSION
110 import(
'lib.pkp.controllers.grid.users.stageParticipant.StageParticipantGridCellProvider');
120 $submissionId = $submission->getId();
122 $router = $request->getRouter();
123 $dispatcher = $router->getDispatcher();
124 $user = $request->getUser();
125 $redirectUrl = $dispatcher->url(
133 import(
'lib.pkp.classes.linkAction.request.RedirectAction');
138 $dispatcher->url($request, ROUTE_PAGE,
null,
'login',
'signOutAsUser',
null, array(
'redirectUrl' => $redirectUrl))
140 __(
'user.logOutAs').
' '. $user->getUsername(),
150 $router = $request->getRouter();
155 $router->url($request,
null,
null,
'addParticipant',
null, $this->getRequestArgs()),
156 __(
'editor.submission.addStageParticipant'),
181 $stageAssignments = $stageAssignmentDao->getBySubmissionAndStageId(
182 $submission->getId(),
187 return $stageAssignments->toAssociativeArray();
216 return 'userGroupId';
225 parent::getRequestArgs(),
227 'submissionId' => $submission->getId(),
228 'stageId' => $this->getStageId(),
239 $stageAssignments = $stageAssignmentDao->getBySubmissionAndStageId(
245 $userGroupIds = array();
246 while ($stageAssignment = $stageAssignments->next()) {
247 $userGroupIds[] = $stageAssignment->getUserGroupId();
252 $context = $request->getContext();
254 $userGroups = $userGroupDao->getUserGroupsByStage(
255 $request->getContext()->getId(),
258 while ($userGroup = $userGroups->next()) {
259 if ($userGroup->getRoleId() == ROLE_ID_REVIEWER)
continue;
260 if (!in_array($userGroup->getId(), $userGroupIds))
continue;
261 $result[$userGroup->getId()] = $userGroup;
279 $assignmentId =
null;
280 if (array_key_exists(
'assignmentId', $args)) {
281 $assignmentId = $args[
'assignmentId'];
285 import(
'lib.pkp.controllers.grid.users.stageParticipant.form.AddParticipantForm');
289 return new JSONMessage(
true, $form->fetch($request));
301 $assignmentId = $args[
'assignmentId'];
304 import(
'lib.pkp.controllers.grid.users.stageParticipant.form.AddParticipantForm');
306 $form->readInputData();
307 if ($form->validate()) {
308 list($userGroupId, $userId, $stageAssignmentId) = $form->execute();
316 $userGroup = $userGroupDao->getById($userGroupId);
317 import(
'classes.workflow.EditorDecisionActionsManager');
318 if ($userGroup->getRoleId() == ROLE_ID_MANAGER) {
319 $notificationMgr->updateNotification(
323 ASSOC_TYPE_SUBMISSION,
329 foreach ($stages as $workingStageId) {
331 if ($stageAssignmentDao->editorAssignedToStage($submission->getId(), $workingStageId)) {
333 $notificationDao->deleteByAssoc(ASSOC_TYPE_SUBMISSION, $submission->getId(),
null, NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_REQUIRED);
338 $user = $request->getUser();
339 if ($stageAssignmentId != $assignmentId) {
340 $notificationMgr->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SUCCESS, array(
'contents' => __(
'notification.addedStageParticipant')));
342 $notificationMgr->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SUCCESS, array(
'contents' => __(
'notification.editStageParticipant')));
348 $assignedUser = $userDao->getById($userId);
349 import(
'lib.pkp.classes.log.SubmissionLog');
350 SubmissionLog::logEvent($request, $submission, SUBMISSION_LOG_ADD_PARTICIPANT,
'submission.event.participantAdded', array(
'name' => $assignedUser->getFullName(),
'username' => $assignedUser->getUsername(),
'userGroupName' => $userGroup->getLocalizedName()));
354 return new JSONMessage(
true, $form->fetch($request));
367 $assignmentId = (int) $request->getUserVar(
'assignmentId');
370 $stageAssignment = $stageAssignmentDao->getById($assignmentId);
371 if (!$request->checkCSRF() || !$stageAssignment || $stageAssignment->getSubmissionId() != $submission->getId()) {
376 $stageAssignmentDao->deleteObject($stageAssignment);
381 import(
'classes.workflow.EditorDecisionActionsManager');
382 $notificationMgr->updateNotification(
386 ASSOC_TYPE_SUBMISSION,
390 if ($stageId == WORKFLOW_STAGE_ID_EDITING ||
391 $stageId == WORKFLOW_STAGE_ID_PRODUCTION) {
394 $notificationMgr->updateNotification(
397 NOTIFICATION_TYPE_ASSIGN_COPYEDITOR,
398 NOTIFICATION_TYPE_AWAITING_COPYEDITS,
399 NOTIFICATION_TYPE_ASSIGN_PRODUCTIONUSER,
400 NOTIFICATION_TYPE_AWAITING_REPRESENTATIONS,
403 ASSOC_TYPE_SUBMISSION,
410 $assignedUser = $userDao->getById($stageAssignment->getUserId());
412 $userGroup = $userGroupDao->getById($stageAssignment->getUserGroupId());
413 import(
'lib.pkp.classes.log.SubmissionLog');
414 SubmissionLog::logEvent($request, $submission, SUBMISSION_LOG_REMOVE_PARTICIPANT,
'submission.event.participantRemoved', array(
'name' => $assignedUser->getFullName(),
'username' => $assignedUser->getUsername(),
'userGroupName' => $userGroup->getLocalizedName()));
430 $userGroupId = (int) $request->getUserVar(
'userGroupId');
433 $users = $userStageAssignmentDao->getUsersNotAssignedToStageInUserGroup($submission->getId(), $stageId, $userGroupId);
436 $userGroup = $userGroupDao->getById($userGroupId);
437 $roleId = $userGroup->getRoleId();
439 $sectionId = $submission->getSectionId();
440 $contextId = $submission->getContextId();
443 while($user = $users->next()) $userList[$user->getId()] = $user->getFullName();
444 if (count($userList) == 0) {
445 $userList[0] = __(
'common.noMatches');
460 import(
'controllers.grid.users.stageParticipant.form.StageParticipantNotifyForm');
462 $notifyForm->initData();
464 return new JSONMessage(
true, $notifyForm->fetch($request));
476 import(
'controllers.grid.users.stageParticipant.form.StageParticipantNotifyForm');
478 $notifyForm->readInputData();
480 if ($notifyForm->validate()) {
481 $noteId = $notifyForm->execute();
483 if ($this->
getStageId() == WORKFLOW_STAGE_ID_EDITING ||
484 $this->
getStageId() == WORKFLOW_STAGE_ID_PRODUCTION) {
488 $notificationMgr->updateNotification(
491 NOTIFICATION_TYPE_ASSIGN_COPYEDITOR,
492 NOTIFICATION_TYPE_AWAITING_COPYEDITS,
493 NOTIFICATION_TYPE_ASSIGN_PRODUCTIONUSER,
494 NOTIFICATION_TYPE_AWAITING_REPRESENTATIONS,
497 ASSOC_TYPE_SUBMISSION,
503 $json->setGlobalEvent(
'stageStatusUpdated');
518 $templateId = $request->getUserVar(
'template');
519 import(
'lib.pkp.classes.mail.SubmissionMailTemplate');
522 $user = $request->getUser();
523 $dispatcher = $request->getDispatcher();
524 $context = $request->getContext();
525 $template->assignParams(array(
526 'editorialContactSignature' => $user->getContactSignature(),
527 'signatureFullName' => $user->getFullname(),
529 $template->replaceParams();
531 import(
'controllers.grid.users.stageParticipant.form.StageParticipantNotifyForm');
536 'body' => $template->getBody(),
537 'variables' => $notifyForm->getEmailVariableNames($templateId),
548 return '$.pkp.controllers.grid.users.stageParticipant.StageParticipantGridHandler';