• Main Page
  • Modules
  • Classes
  • Files
  • File List

controllers/modals/editorDecision/form/PromoteForm.inc.php

00001 <?php
00002 
00015 import('controllers.modals.editorDecision.form.EditorDecisionWithEmailForm');
00016 
00017 // Access decision actions constants.
00018 import('classes.workflow.EditorDecisionActionsManager');
00019 
00020 class PromoteForm extends EditorDecisionWithEmailForm {
00021 
00029    function PromoteForm(&$seriesEditorSubmission, $decision, $stageId, $reviewRound = null) {
00030       if (!in_array($decision, $this->_getDecisions())) {
00031          fatalError('Invalid decision!');
00032       }
00033 
00034       $this->setSaveFormOperation('savePromote');
00035 
00036       parent::EditorDecisionWithEmailForm(
00037          $seriesEditorSubmission, $decision, $stageId,
00038          'controllers/modals/editorDecision/form/promoteForm.tpl',
00039          $reviewRound
00040       );
00041    }
00042 
00043 
00044    //
00045    // Implement protected template methods from Form
00046    //
00050    function initData($args, &$request) {
00051       $actionLabels = EditorDecisionActionsManager::getActionLabels($this->_getDecisions());
00052 
00053       $seriesEditorSubmission =& $this->getSeriesEditorSubmission();
00054       $this->setData('stageId', $this->getStageId());
00055 
00056       return parent::initData($args, $request, $actionLabels);
00057    }
00058 
00062    function execute($args, &$request) {
00063       // Retrieve the submission.
00064       $seriesEditorSubmission =& $this->getSeriesEditorSubmission();
00065 
00066       // Get this form decision actions labels.
00067       $actionLabels = EditorDecisionActionsManager::getActionLabels($this->_getDecisions());
00068 
00069       // Record the decision.
00070       $reviewRound = $this->getReviewRound();
00071       $decision = $this->getDecision();
00072       import('classes.submission.seriesEditor.SeriesEditorAction');
00073       $seriesEditorAction = new SeriesEditorAction();
00074       $seriesEditorAction->recordDecision($request, $seriesEditorSubmission, $decision, $actionLabels, $reviewRound);
00075 
00076       // Identify email key and status of round.
00077       import('classes.file.MonographFileManager');
00078       $monographFileManager = new MonographFileManager($seriesEditorSubmission->getPressId(), $seriesEditorSubmission->getId());
00079       switch ($decision) {
00080          case SUBMISSION_EDITOR_DECISION_ACCEPT:
00081             $emailKey = 'EDITOR_DECISION_ACCEPT';
00082             $status = REVIEW_ROUND_STATUS_ACCEPTED;
00083 
00084             $this->_updateReviewRoundStatus($seriesEditorSubmission, $status, $reviewRound);
00085 
00086             // Move to the editing stage.
00087             $seriesEditorAction->incrementWorkflowStage($seriesEditorSubmission, WORKFLOW_STAGE_ID_EDITING, $request);
00088 
00089             // Bring in the MONOGRAPH_FILE_* constants.
00090             import('classes.monograph.MonographFile');
00091             // Bring in the Manager (we need it).
00092             import('classes.file.MonographFileManager');
00093 
00094             $selectedFiles = $this->getData('selectedFiles');
00095             if(is_array($selectedFiles)) {
00096                foreach ($selectedFiles as $selectedFile) {
00097                   // Split the file into file id and file revision.
00098                   list($fileId, $revision) = explode('-', $selectedFile);
00099                   $monographFileManager->copyFileToFileStage($fileId, $revision, MONOGRAPH_FILE_FINAL, null, true);
00100                }
00101             }
00102 
00103             // Send email to the author.
00104             $this->_sendReviewMailToAuthor($seriesEditorSubmission, $emailKey, $request);
00105             break;
00106 
00107          case SUBMISSION_EDITOR_DECISION_EXTERNAL_REVIEW:
00108             $emailKey = 'EDITOR_DECISION_SEND_TO_EXTERNAL';
00109             $status = REVIEW_ROUND_STATUS_SENT_TO_EXTERNAL;
00110 
00111             $this->_updateReviewRoundStatus($seriesEditorSubmission, $status, $reviewRound);
00112 
00113             // Move to the external review stage.
00114             $seriesEditorAction->incrementWorkflowStage($seriesEditorSubmission, WORKFLOW_STAGE_ID_EXTERNAL_REVIEW, $request);
00115 
00116             // Create an initial external review round.
00117             $this->_initiateReviewRound($seriesEditorSubmission, WORKFLOW_STAGE_ID_EXTERNAL_REVIEW, $request, REVIEW_ROUND_STATUS_PENDING_REVIEWERS);
00118 
00119             // Send email to the author.
00120             $this->_sendReviewMailToAuthor($seriesEditorSubmission, $emailKey, $request);
00121             break;
00122          case SUBMISSION_EDITOR_DECISION_SEND_TO_PRODUCTION:
00123             $emailKey = 'EDITOR_DECISION_SEND_TO_PRODUCTION';
00124             // FIXME: this is copy-pasted from above, save the FILE_GALLEY.
00125 
00126             // Move to the editing stage.
00127             $seriesEditorAction->incrementWorkflowStage($seriesEditorSubmission, WORKFLOW_STAGE_ID_PRODUCTION, $request);
00128 
00129             // Bring in the MONOGRAPH_FILE_* constants.
00130             import('classes.monograph.MonographFile');
00131             // Bring in the Manager (we need it).
00132             import('classes.file.MonographFileManager');
00133 
00134             // Move the revisions to the next stage
00135             $selectedFiles = $this->getData('selectedFiles');
00136             if(is_array($selectedFiles)) {
00137                foreach ($selectedFiles as $selectedFile) {
00138                   // Split the file into file id and file revision.
00139                   list($fileId, $revision) = explode('-', $selectedFile);
00140                   $monographFileManager->copyFileToFileStage($fileId, $revision, MONOGRAPH_FILE_PRODUCTION_READY);
00141                }
00142             }
00143             // Send email to the author.
00144             $this->_sendReviewMailToAuthor($seriesEditorSubmission, $emailKey, $request);
00145             break;
00146          default:
00147             fatalError('Unsupported decision!');
00148       }
00149    }
00150 
00151    //
00152    // Private functions
00153    //
00158    function _getDecisions() {
00159       return array(
00160          SUBMISSION_EDITOR_DECISION_EXTERNAL_REVIEW,
00161          SUBMISSION_EDITOR_DECISION_ACCEPT,
00162          SUBMISSION_EDITOR_DECISION_SEND_TO_PRODUCTION
00163       );
00164    }
00165 }
00166 
00167 ?>

Generated on Mon Sep 17 2012 13:58:56 for Open Monograph Press by  doxygen 1.7.1