/** * Send a notification from the notify tab. * @param $args array * @param $request PKPRequest * @return JSONMessage JSON object */ function sendNotification($args, $request) { $this->setupTemplate($request); import('controllers.grid.users.stageParticipant.form.StageParticipantNotifyForm'); // exists in each app. $notifyForm = new StageParticipantNotifyForm($this->getSubmission()->getId(), ASSOC_TYPE_SUBMISSION, $this->getAuthorizedContextObject(ASSOC_TYPE_WORKFLOW_STAGE)); $notifyForm->readInputData($request); if ($notifyForm->validate()) { $noteId = $notifyForm->execute($request); // Return a JSON string indicating success // (will clear the form on return) $this->_logEventAndCreateNotification($request); return new JSONMessage(true); } else { // Return a JSON string indicating failure return new JSONMessage(false); } }
/** * @see Form::execute() * @param $request PKPRequest * @return array ($userGroupId, $userId) */ function execute($request) { $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO'); /* @var $stageAssignmentDao StageAssignmentDAO */ $userGroupDao = DAORegistry::getDAO('UserGroupDAO'); /* @var $userGroupDao UserGroupDAO */ $submission = $this->getSubmission(); $userGroupId = (int) $this->getData('userGroupId'); $userId = (int) $this->getData('userId'); // sanity check if ($userGroupDao->userGroupAssignedToStage($userGroupId, $this->getStageId())) { // insert the assignment $stageAssignment = $stageAssignmentDao->build($submission->getId(), $userGroupId, $userId); } parent::execute($request); return array($userGroupId, $userId, $stageAssignment->getId()); }
/** * Send a notification from the notify tab. * @param $args array * @param $request PKPRequest * @return JSONMessage JSON object */ function sendNotification($args, $request) { $this->setupTemplate($request); import('controllers.grid.users.stageParticipant.form.StageParticipantNotifyForm'); // exists in each app. $notifyForm = new StageParticipantNotifyForm($this->getSubmission()->getId(), ASSOC_TYPE_SUBMISSION, $this->getAuthorizedContextObject(ASSOC_TYPE_WORKFLOW_STAGE)); $notifyForm->readInputData($request); if ($notifyForm->validate()) { $noteId = $notifyForm->execute($request); // Return a JSON string indicating success // (will clear the form on return) $this->_logEventAndCreateNotification($request); // Update submission notifications $notificationMgr = new NotificationManager(); $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_ASSIGN_COPYEDITOR, NOTIFICATION_TYPE_AWAITING_COPYEDITS, NOTIFICATION_TYPE_ASSIGN_PRODUCTIONUSER, NOTIFICATION_TYPE_AWAITING_REPRESENTATIONS), null, ASSOC_TYPE_SUBMISSION, $this->getSubmission()->getId()); return new JSONMessage(true); } else { // Return a JSON string indicating failure return new JSONMessage(false); } }