/**
  * Upload the file in an app-specific manner.
  * @param PKPRequest $request
  * @param PKPUser $user
  * @param $uploaderUserGroupId int
  * @param $revisedFileId int
  * @param $fileGenre int
  * @param $assocType int
  * @param $assocType int
  * @return SubmissionFile
  */
 function _uploadFile($request, $user, $uploaderUserGroupId, $revisedFileId, $fileGenre, $assocType, $assocId)
 {
     $context = $request->getContext();
     import('lib.pkp.classes.file.SubmissionFileManager');
     $articleFileManager = new SubmissionFileManager($context->getId(), $this->getData('submissionId'));
     $fileStage = $this->getData('fileStage');
     $submissionFile = $articleFileManager->uploadSubmissionFile('uploadedFile', $fileStage, $user->getId(), $uploaderUserGroupId, $revisedFileId, $fileGenre, $assocType, $assocId);
     return $submissionFile;
 }
 /**
  * Internal method to create the necessary notifications, with user validation.
  * @param PKPRquest $request
  * @param Submission $submission
  * @param PKPUser $user
  * @param string $template
  */
 function _createNotifications($request, $submission, $user, $template)
 {
     $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO');
     $userGroupDao = DAORegistry::getDAO('UserGroupDAO');
     $stageAssignments = $stageAssignmentDao->getBySubmissionAndStageId($submission->getId(), $this->getStageId(), null, $user->getId());
     $notificationMgr = new NotificationManager();
     switch ($template) {
         case 'COPYEDIT_REQUEST':
             while ($stageAssignment = $stageAssignments->next()) {
                 $userGroup = $userGroupDao->getById($stageAssignment->getUserGroupId());
                 if (in_array($userGroup->getRoleId(), array(ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR, ROLE_ID_ASSISTANT))) {
                     import('lib.pkp.classes.submission.SubmissionFile');
                     $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO');
                     $submissionFileSignoffDao = DAORegistry::getDAO('SubmissionFileSignoffDAO');
                     $submissionFiles = $submissionFileDao->getLatestRevisions($submission->getId(), SUBMISSION_FILE_COPYEDIT);
                     foreach ($submissionFiles as $submissionFile) {
                         $signoffFactory = $submissionFileSignoffDao->getAllBySymbolic('SIGNOFF_COPYEDITING', $submissionFile->getFileId());
                         while ($signoff = $signoffFactory->next()) {
                             $notificationMgr->updateNotification($request, array(NOTIFICATION_TYPE_COPYEDIT_ASSIGNMENT), array($user->getId()), ASSOC_TYPE_SIGNOFF, $signoff->getId());
                         }
                     }
                     return;
                 }
             }
             // User not in valid role for this task/notification.
             break;
         case 'LAYOUT_REQUEST':
             while ($stageAssignment = $stageAssignments->next()) {
                 $userGroup = $userGroupDao->getById($stageAssignment->getUserGroupId());
                 if (in_array($userGroup->getRoleId(), array(ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR, ROLE_ID_ASSISTANT))) {
                     $this->_addUploadTaskNotification($request, NOTIFICATION_TYPE_LAYOUT_ASSIGNMENT, $user->getId(), $submission->getId());
                     return;
                 }
             }
             // User not in valid role for this task/notification.
             break;
         case 'INDEX_REQUEST':
             while ($stageAssignment = $stageAssignments->next()) {
                 $userGroup = $userGroupDao->getById($stageAssignment->getUserGroupId());
                 if (in_array($userGroup->getRoleId(), array(ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR, ROLE_ID_ASSISTANT))) {
                     $this->_addUploadTaskNotification($request, NOTIFICATION_TYPE_INDEX_ASSIGNMENT, $user->getId(), $submission->getId());
                     return;
                 }
             }
             // User not in valid role for this task/notification.
             break;
     }
 }
Exemple #3
0
 /**
  * Determine if a particular stage has a notification pending.  If so, return true.
  * This is used to set the CSS class of the submission progress bar.
  * @param PKPUser $user
  * @param int $stageId
  */
 function _notificationOptionsByStage(&$user, $stageId, $contextId)
 {
     $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION);
     $notificationDao = DAORegistry::getDAO('NotificationDAO');
     $signOffNotificationType = $this->_getSignoffNotificationTypeByStageId($stageId);
     $editorAssignmentNotificationType = $this->_getEditorAssignmentNotificationTypeByStageId($stageId);
     $editorAssignments = $notificationDao->getByAssoc(ASSOC_TYPE_SUBMISSION, $submission->getId(), null, $editorAssignmentNotificationType, $contextId);
     if (isset($signOffNotificationType)) {
         $signoffAssignments = $notificationDao->getByAssoc(ASSOC_TYPE_SUBMISSION, $submission->getId(), $user->getId(), $signOffNotificationType, $contextId);
     }
     // if the User has assigned TASKs in this stage check, return true
     if (!$editorAssignments->wasEmpty() || isset($signoffAssignments) && !$signoffAssignments->wasEmpty()) {
         return true;
     }
     // check for more specific notifications on those stages that have them.
     if ($stageId == WORKFLOW_STAGE_ID_PRODUCTION) {
         $submissionApprovalNotification = $notificationDao->getByAssoc(ASSOC_TYPE_SUBMISSION, $submission->getId(), null, NOTIFICATION_TYPE_APPROVE_SUBMISSION, $contextId);
         if (!$submissionApprovalNotification->wasEmpty()) {
             return true;
         }
     }
     if ($stageId == WORKFLOW_STAGE_ID_EXTERNAL_REVIEW) {
         $reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO');
         $reviewRounds = $reviewRoundDao->getBySubmissionId($submission->getId(), $stageId);
         $notificationTypes = array(NOTIFICATION_TYPE_REVIEW_ROUND_STATUS, NOTIFICATION_TYPE_ALL_REVIEWS_IN);
         while ($reviewRound = $reviewRounds->next()) {
             foreach ($notificationTypes as $type) {
                 $notifications = $notificationDao->getByAssoc(ASSOC_TYPE_REVIEW_ROUND, $reviewRound->getId(), null, $type, $contextId);
                 if (!$notifications->wasEmpty()) {
                     return true;
                 }
             }
         }
     }
     return false;
 }