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

controllers/grid/files/form/ManageSubmissionFilesForm.inc.php

00001 <?php
00002 
00015 import('lib.pkp.classes.form.Form');
00016 import('classes.monograph.MonographFile');
00017 
00018 class ManageSubmissionFilesForm extends Form {
00020    var $_monographId;
00021 
00025    function ManageSubmissionFilesForm($monographId, $template) {
00026       parent::Form($template);
00027       $this->_monographId = (int)$monographId;
00028 
00029       $this->addCheck(new FormValidatorPost($this));
00030    }
00031 
00032 
00033    //
00034    // Getters / Setters
00035    //
00040    function getMonographId() {
00041       return $this->_monographId;
00042    }
00043 
00044    //
00045    // Overridden template methods
00046    //
00052    function initData($args, &$request) {
00053       $this->setData('monographId', $this->_monographId);
00054    }
00055 
00060    function readInputData() {
00061       $this->readUserVars(array('selectedFiles'));
00062    }
00063 
00071    function execute($args, &$request, &$stageMonographFiles, $fileStage) {
00072       $selectedFiles = (array)$this->getData('selectedFiles');
00073       $submissionFileDao =& DAORegistry::getDAO('SubmissionFileDAO');
00074       $monographFiles =& $submissionFileDao->getLatestRevisions($this->getMonographId());
00075 
00076       foreach ($monographFiles as $monographFile) {
00077          // Get the viewable flag value.
00078          $isViewable = in_array(
00079             $monographFile->getFileIdAndRevision(),
00080             $selectedFiles);
00081 
00082          // If this is a monograph file that belongs to the current stage id...
00083          if (array_key_exists($monographFile->getFileId(), $stageMonographFiles)) {
00084             // ...update the "viewable" flag accordingly.
00085             $monographFile->setViewable($isViewable);
00086          } else {
00087             // If the viewable flag is set to true...
00088             if ($isViewable) {
00089                // Make a copy of the file to the current file stage.
00090                import('classes.file.MonographFileManager');
00091                $press =& $request->getPress();
00092                $monographFileManager = new MonographFileManager($press->getId(), $monographFile->getMonographId());
00093                // Split the file into file id and file revision.
00094                $fileId = $monographFile->getFileId();
00095                $revision = $monographFile->getRevision();
00096                list($newFileId, $newRevision) = $monographFileManager->copyFileToFileStage($fileId, $revision, $fileStage, null, true);
00097                if ($fileStage == MONOGRAPH_FILE_REVIEW_FILE) {
00098                   $submissionFileDao->assignRevisionToReviewRound($newFileId, $newRevision, $this->getReviewRound());
00099                }
00100                $monographFile =& $submissionFileDao->getRevision($newFileId, $newRevision);
00101             }
00102          }
00103          $submissionFileDao->updateObject($monographFile);
00104          unset($monographFile);
00105       }
00106    }
00107 }
00108 
00109 ?>

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