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

controllers/grid/files/proof/form/ApprovedProofForm.inc.php

00001 <?php
00015 import('lib.pkp.classes.form.Form');
00016 
00017 class ApprovedProofForm extends Form {
00019    var $approvedProof;
00020 
00022    var $monograph;
00023 
00025    var $publicationFormat;
00026 
00033    function ApprovedProofForm($monograph, $publicationFormat, $fileIdAndRevision) {
00034       parent::Form('controllers/grid/files/proof/form/approvedProofForm.tpl');
00035 
00036       $this->monograph =& $monograph;
00037       $this->publicationFormat =& $publicationFormat;
00038 
00039       $submissionFileDao =& DAORegistry::getDAO('SubmissionFileDAO');
00040       list($fileId, $revision) = explode('-', $fileIdAndRevision);
00041       $this->approvedProof =& $submissionFileDao->getRevision($fileId, $revision, MONOGRAPH_FILE_PROOF, $this->monograph->getId());
00042       if (!$this->approvedProof->getViewable()) fatalError('Proof not approved!');
00043 
00044       // matches currencies like:  1,500.50 1500.50 1,112.15 5,99 .99
00045       $this->addCheck(new FormValidatorRegExp($this, 'price', 'optional', 'grid.catalogEntry.validPriceRequired', '/^(([1-9]\d{0,2}(,\d{3})*|[1-9]\d*|0|)(.\d{2})?|([1-9]\d{0,2}(,\d{3})*|[1-9]\d*|0|)(.\d{2})?)$/'));
00046       $this->addCheck(new FormValidatorPost($this));
00047    }
00048 
00049 
00050    //
00051    // Extended methods from Form
00052    //
00053    function fetch($request) {
00054       $templateMgr =& TemplateManager::getManager();
00055       $templateMgr->assign('fileId', $this->approvedProof->getFileIdAndRevision());
00056       $templateMgr->assign('monographId', $this->monograph->getId());
00057       $templateMgr->assign('publicationFormatId', $this->publicationFormat->getId());
00058       return parent::fetch($request);
00059    }
00060 
00064    function readInputData() {
00065       $this->readUserVars(array('price', 'salesType'));
00066    }
00067 
00071    function initData() {
00072       $this->_data = array(
00073          'price' => $this->approvedProof->getDirectSalesPrice()
00074       );
00075    }
00076 
00080    function execute(&$request) {
00081       $submissionFileDao =& DAORegistry::getDAO('SubmissionFileDAO');
00082       $salesType = $this->getData('salesType');
00083       if ($salesType === 'notAvailable') {
00084          // Not available
00085          $this->approvedProof->setDirectSalesPrice(null);
00086       } elseif ($salesType === 'openAccess') {
00087          // Open access
00088          $this->approvedProof->setDirectSalesPrice(0);
00089       } else { /* $salesType === 'directSales' */
00090          // Direct sale
00091          $this->approvedProof->setDirectSalesPrice($this->getData('price'));
00092       }
00093       $submissionFileDao->updateObject($this->approvedProof);
00094 
00095       return $this->approvedProof->getFileIdAndRevision();
00096    }
00097 }
00098 
00099 ?>

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