/** * Delete the participant from the user groups * @param $args * @param $request * @return JSONMessage JSON object */ function deleteParticipant($args, $request) { $submission = $this->getSubmission(); $stageId = $this->getStageId(); $assignmentId = (int) $request->getUserVar('assignmentId'); $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO'); /* @var $stageAssignmentDao StageAssignmentDAO */ $stageAssignment = $stageAssignmentDao->getById($assignmentId); if (!$request->checkCSRF() || !$stageAssignment || $stageAssignment->getSubmissionId() != $submission->getId()) { return new JSONMessage(false); } // Delete the assignment $stageAssignmentDao->deleteObject($stageAssignment); // 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, EditorDecisionActionsManager::getStageNotifications(), null, ASSOC_TYPE_SUBMISSION, $submission->getId()); // 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()); // Log removal. $userDao = DAORegistry::getDAO('UserDAO'); $assignedUser = $userDao->getById($stageAssignment->getUserId()); $userGroupDao = DAORegistry::getDAO('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 return DAO::getDataChangedEvent($stageAssignment->getUserGroupId()); }
/** * Delete the participant from the user groups * @param $args * @param $request * @return JSONMessage JSON object */ function deleteParticipant($args, $request) { $submission = $this->getSubmission(); $stageId = $this->getStageId(); $assignmentId = (int) $request->getUserVar('assignmentId'); $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO'); /* @var $stageAssignmentDao StageAssignmentDAO */ $stageAssignment = $stageAssignmentDao->getById($assignmentId); if (!$stageAssignment || $stageAssignment->getSubmissionId() != $submission->getId()) { fatalError('Invalid Assignment'); } // Delete the assignment $stageAssignmentDao->deleteObject($stageAssignment); // FIXME: perhaps we can just insert the notification on page load // instead of having it there all the time? $stages = Application::getApplicationStages(); foreach ($stages as $workingStageId) { // remove user's assignment from this user group from all the stages // (no need to check if user group is assigned, since nothing will be deleted if there isn't) $stageAssignmentDao->deleteByAll($submission->getId(), $workingStageId, $stageAssignment->getUserGroupId(), $stageAssignment->getUserId()); } $notificationMgr = new NotificationManager(); import('classes.workflow.EditorDecisionActionsManager'); $notificationMgr->updateNotification($request, EditorDecisionActionsManager::getStageNotifications(), null, ASSOC_TYPE_SUBMISSION, $submission->getId()); // Log removal. $userDao = DAORegistry::getDAO('UserDAO'); $assignedUser = $userDao->getById($userId); $userGroupDao = DAORegistry::getDAO('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 return DAO::getDataChangedEvent($stageAssignment->getUserGroupId()); }
/** * Save changes to submission. * @param $args array * @param $request PKPRequest * @return int the submission ID */ function execute($args, $request) { $submissionDao = Application::getSubmissionDAO(); // Set other submission data. if ($this->submission->getSubmissionProgress() <= $this->step) { $this->submission->setDateSubmitted(Core::getCurrentDate()); $this->submission->stampStatusModified(); $this->submission->setSubmissionProgress(0); } parent::execute($this->submission); // Save the submission. $submissionDao->updateObject($this->submission); // Assign the default stage participants. $userGroupDao = DAORegistry::getDAO('UserGroupDAO'); // Assistant roles -- For each assistant role user group assigned to this // stage in setup, iff there is only one user for the group, // automatically assign the user to the stage // But skip authors and reviewers, since these are very submission specific $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO'); $submissionStageGroups = $userGroupDao->getUserGroupsByStage($this->submission->getContextId(), WORKFLOW_STAGE_ID_SUBMISSION, true, true); $managerFound = false; while ($userGroup = $submissionStageGroups->next()) { $users = $userGroupDao->getUsersById($userGroup->getId(), $this->submission->getContextId()); if ($users->getCount() == 1) { $user = $users->next(); $stageAssignmentDao->build($this->submission->getId(), $userGroup->getId(), $user->getId()); if ($userGroup->getRoleId() == ROLE_ID_MANAGER) { $managerFound = true; } } } // Author roles // Assign only the submitter in whatever ROLE_ID_AUTHOR capacity they were assigned previously $user = $request->getUser(); $submitterAssignments = $stageAssignmentDao->getBySubmissionAndStageId($this->submission->getId(), null, null, $user->getId()); while ($assignment = $submitterAssignments->next()) { $userGroup = $userGroupDao->getById($assignment->getUserGroupId()); if ($userGroup->getRoleId() == ROLE_ID_AUTHOR) { $stageAssignmentDao->build($this->submission->getId(), $userGroup->getId(), $assignment->getUserId()); // Only assign them once, since otherwise we'll one assignment for each previous stage. // And as long as they are assigned once, they will get access to their submission. break; } } $notificationManager = new NotificationManager(); // Assign sub editors for that section $submissionSubEditorFound = false; $subEditorsDao = DAORegistry::getDAO('SubEditorsDAO'); $subEditors = $subEditorsDao->getBySectionId($this->submission->getSectionId(), $this->submission->getContextId()); foreach ($subEditors as $subEditor) { $userGroups = $userGroupDao->getByUserId($subEditor->getId(), $this->submission->getContextId()); while ($userGroup = $userGroups->next()) { if ($userGroup->getRoleId() != ROLE_ID_SUB_EDITOR) { continue; } $stageAssignmentDao->build($this->submission->getId(), $userGroup->getId(), $subEditor->getId()); // If we assign a stage assignment in the Submission stage to a sub editor, make note. if ($userGroupDao->userGroupAssignedToStage($userGroup->getId(), WORKFLOW_STAGE_ID_SUBMISSION)) { $submissionSubEditorFound = true; } } } // Update assignment notifications import('classes.workflow.EditorDecisionActionsManager'); $notificationManager->updateNotification($request, EditorDecisionActionsManager::getStageNotifications(), null, ASSOC_TYPE_SUBMISSION, $this->submission->getId()); // Send a notification to associated users if an editor needs assigning if (!$managerFound && !$submissionSubEditorFound) { $roleDao = DAORegistry::getDAO('RoleDAO'); /* @var $roleDao RoleDAO */ // Get the managers. $managers = $roleDao->getUsersByRoleId(ROLE_ID_MANAGER, $this->submission->getContextId()); $managersArray = $managers->toAssociativeArray(); $allUserIds = array_keys($managersArray); foreach ($allUserIds as $userId) { $notificationManager->createNotification($request, $userId, NOTIFICATION_TYPE_SUBMISSION_SUBMITTED, $this->submission->getContextId(), ASSOC_TYPE_SUBMISSION, $this->submission->getId()); // Add TASK notification indicating that a submission is unassigned $notificationManager->createNotification($request, $userId, NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_REQUIRED, $this->submission->getContextId(), ASSOC_TYPE_SUBMISSION, $this->submission->getId(), NOTIFICATION_LEVEL_TASK); } } $notificationManager->updateNotification($request, array(NOTIFICATION_TYPE_APPROVE_SUBMISSION), null, ASSOC_TYPE_SUBMISSION, $this->submission->getId()); return $this->submissionId; }