copyFileToFileStage() public method

Copies an existing ArticleFile and renames it.
public copyFileToFileStage ( $sourceFileId, $sourceRevision, $newFileStage, $destFileId = null, $viewable = false )
$sourceFileId int
$sourceRevision int
$destFileId int (optional)
$viewable boolean (optional)
 /**
  * Make a copy of the file to the specified file stage.
  * @param $context Context
  * @param $submissionFile SubmissionFile
  * @param $fileStage int SUBMISSION_FILE_...
  * @return SubmissionFile Resultant new submission file
  */
 protected function importFile($context, $submissionFile, $fileStage)
 {
     $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO');
     import('lib.pkp.classes.file.SubmissionFileManager');
     $submissionFileManager = new SubmissionFileManager($context->getId(), $submissionFile->getSubmissionId());
     // Split the file into file id and file revision.
     $fileId = $submissionFile->getFileId();
     $revision = $submissionFile->getRevision();
     list($newFileId, $newRevision) = $submissionFileManager->copyFileToFileStage($fileId, $revision, $fileStage, null, true);
     return $submissionFileDao->getRevision($newFileId, $newRevision);
 }
Esempio n. 2
0
 /**
  * @copydoc Form::execute()
  */
 function execute($args, $request)
 {
     // Retrieve the submission.
     $submission = $this->getSubmission();
     // Get this form decision actions labels.
     $actionLabels = EditorDecisionActionsManager::getActionLabels($this->_getDecisions());
     // Record the decision.
     $reviewRound = $this->getReviewRound();
     $decision = $this->getDecision();
     import('lib.pkp.classes.submission.action.EditorAction');
     $editorAction = new EditorAction();
     $editorAction->recordDecision($request, $submission, $decision, $actionLabels, $reviewRound);
     // Identify email key and status of round.
     import('lib.pkp.classes.file.SubmissionFileManager');
     $submissionFileManager = new SubmissionFileManager($submission->getContextId(), $submission->getId());
     switch ($decision) {
         case SUBMISSION_EDITOR_DECISION_ACCEPT:
             $emailKey = 'EDITOR_DECISION_ACCEPT';
             $status = REVIEW_ROUND_STATUS_ACCEPTED;
             $this->_updateReviewRoundStatus($submission, $status, $reviewRound);
             // Move to the editing stage.
             $editorAction->incrementWorkflowStage($submission, WORKFLOW_STAGE_ID_EDITING, $request);
             // Bring in the SUBMISSION_FILE_* constants.
             import('lib.pkp.classes.submission.SubmissionFile');
             // Bring in the Manager (we need it).
             import('lib.pkp.classes.file.SubmissionFileManager');
             $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO');
             /* @var $submissionFileDao SubmissionFileDAO */
             $selectedFiles = $this->getData('selectedFiles');
             if (is_array($selectedFiles)) {
                 foreach ($selectedFiles as $fileId) {
                     $revisionNumber = $submissionFileDao->getLatestRevisionNumber($fileId);
                     $submissionFileManager->copyFileToFileStage($fileId, $revisionNumber, SUBMISSION_FILE_FINAL, null, true);
                 }
             }
             // Send email to the author.
             $this->_sendReviewMailToAuthor($submission, $emailKey, $request);
             break;
         case SUBMISSION_EDITOR_DECISION_EXTERNAL_REVIEW:
             $emailKey = 'EDITOR_DECISION_SEND_TO_EXTERNAL';
             $status = REVIEW_ROUND_STATUS_SENT_TO_EXTERNAL;
             $this->_updateReviewRoundStatus($submission, $status, $reviewRound);
             // Move to the external review stage.
             $editorAction->incrementWorkflowStage($submission, WORKFLOW_STAGE_ID_EXTERNAL_REVIEW, $request);
             // Create an initial external review round.
             $this->_initiateReviewRound($submission, WORKFLOW_STAGE_ID_EXTERNAL_REVIEW, $request, REVIEW_ROUND_STATUS_PENDING_REVIEWERS);
             // Send email to the author.
             $this->_sendReviewMailToAuthor($submission, $emailKey, $request);
             break;
         case SUBMISSION_EDITOR_DECISION_SEND_TO_PRODUCTION:
             $emailKey = 'EDITOR_DECISION_SEND_TO_PRODUCTION';
             // FIXME: this is copy-pasted from above, save the FILE_GALLEY.
             // Move to the editing stage.
             $editorAction->incrementWorkflowStage($submission, WORKFLOW_STAGE_ID_PRODUCTION, $request);
             // Bring in the SUBMISSION_FILE_* constants.
             import('lib.pkp.classes.submission.SubmissionFile');
             // Bring in the Manager (we need it).
             import('lib.pkp.classes.file.SubmissionFileManager');
             // Move the revisions to the next stage
             $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO');
             /* @var $submissionFileDao SubmissionFileDAO */
             $selectedFiles = $this->getData('selectedFiles');
             if (is_array($selectedFiles)) {
                 foreach ($selectedFiles as $fileId) {
                     $revisionNumber = $submissionFileDao->getLatestRevisionNumber($fileId);
                     $submissionFileManager->copyFileToFileStage($fileId, $revisionNumber, SUBMISSION_FILE_PRODUCTION_READY);
                 }
             }
             // Send email to the author.
             $this->_sendReviewMailToAuthor($submission, $emailKey, $request);
             break;
         default:
             fatalError('Unsupported decision!');
     }
 }
 /**
  * Initiate a new review round and add selected files
  * to it. Also saves the new round to the submission.
  * @param $submission Submission
  * @param $stageId integer One of the WORKFLOW_STAGE_ID_* constants.
  * @param $request Request
  * @param $status integer One of the REVIEW_ROUND_STATUS_* constants.
  * @return $newRound integer The round number of the new review round.
  */
 function _initiateReviewRound($submission, $stageId, $request, $status = null)
 {
     // If we already have review round for this stage,
     // we create a new round after the last one.
     $reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO');
     /* @var $reviewRoundDao ReviewRoundDAO */
     $lastReviewRound = $reviewRoundDao->getLastReviewRoundBySubmissionId($submission->getId(), $stageId);
     if ($lastReviewRound) {
         $newRound = $lastReviewRound->getRound() + 1;
     } else {
         // If we don't have any review round, we create the first one.
         $newRound = 1;
     }
     // Create a new review round.
     $reviewRound = $reviewRoundDao->build($submission->getId(), $stageId, $newRound, $status);
     // Check for a notification already in place for the current review round.
     $notificationDao = DAORegistry::getDAO('NotificationDAO');
     $notificationFactory = $notificationDao->getByAssoc(ASSOC_TYPE_REVIEW_ROUND, $reviewRound->getId(), null, NOTIFICATION_TYPE_REVIEW_ROUND_STATUS, $submission->getContextId());
     // Create round status notification if there is no notification already.
     if ($notificationFactory->wasEmpty()) {
         $notificationMgr = new NotificationManager();
         $notificationMgr->createNotification($request, null, NOTIFICATION_TYPE_REVIEW_ROUND_STATUS, $submission->getContextId(), ASSOC_TYPE_REVIEW_ROUND, $reviewRound->getId(), NOTIFICATION_LEVEL_NORMAL);
     }
     // Add the selected files to the new round.
     $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO');
     /* @var $submissionFileDao SubmissionFileDAO */
     // Bring in the SUBMISSION_FILE_* constants.
     import('lib.pkp.classes.submission.SubmissionFile');
     // Bring in the Manager (we need it).
     import('lib.pkp.classes.file.SubmissionFileManager');
     $submissionFileManager = new SubmissionFileManager($submission->getContextId(), $submission->getId());
     foreach (array('selectedFiles', 'selectedAttachments') as $userVar) {
         $selectedFiles = $this->getData($userVar);
         if (is_array($selectedFiles)) {
             foreach ($selectedFiles as $fileId) {
                 // Retrieve the file last revision number.
                 $revisionNumber = $submissionFileDao->getLatestRevisionNumber($fileId);
                 list($newFileId, $newRevision) = $submissionFileManager->copyFileToFileStage($fileId, $revisionNumber, SUBMISSION_FILE_REVIEW_FILE, null, true);
                 $submissionFileDao->assignRevisionToReviewRound($newFileId, $newRevision, $reviewRound);
             }
         }
     }
     return $newRound;
 }
 /**
  * Save review round files
  * @param $args array
  * @param $request PKPRequest
  * @stageSubmissionFiles array The files that belongs to a file stage
  * that is currently being used by a grid inside this form.
  */
 function execute($args, $request, $stageSubmissionFiles, $fileStage)
 {
     $selectedFiles = (array) $this->getData('selectedFiles');
     $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO');
     $submissionFiles = $submissionFileDao->getLatestRevisions($this->getSubmissionId());
     foreach ($submissionFiles as $submissionFile) {
         // Get the viewable flag value.
         $isViewable = in_array($submissionFile->getFileId(), $selectedFiles);
         // If this is a submission file that belongs to the current stage id...
         if (array_key_exists($submissionFile->getFileId(), $stageSubmissionFiles)) {
             // ...update the "viewable" flag accordingly.
             $submissionFile->setViewable($isViewable);
         } else {
             // If the viewable flag is set to true...
             if ($isViewable) {
                 // Make a copy of the file to the current file stage.
                 import('lib.pkp.classes.file.SubmissionFileManager');
                 $context = $request->getContext();
                 $submissionFileManager = new SubmissionFileManager($context->getId(), $submissionFile->getSubmissionId());
                 // Split the file into file id and file revision.
                 $fileId = $submissionFile->getFileId();
                 $revision = $submissionFile->getRevision();
                 list($newFileId, $newRevision) = $submissionFileManager->copyFileToFileStage($fileId, $revision, $fileStage, null, true);
                 if ($fileStage == SUBMISSION_FILE_REVIEW_FILE) {
                     $submissionFileDao->assignRevisionToReviewRound($newFileId, $newRevision, $this->getReviewRound());
                 }
                 $submissionFile = $submissionFileDao->getRevision($newFileId, $newRevision);
             }
         }
         $submissionFileDao->updateObject($submissionFile);
     }
 }