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

controllers/grid/files/proof/ApprovedProofFilesGridHandler.inc.php

00001 <?php
00002 
00015 // import grid signoff files grid base classes
00016 import('lib.pkp.classes.controllers.grid.GridHandler');
00017 
00018 // Import monograph file class which contains the MONOGRAPH_FILE_* constants.
00019 import('classes.monograph.MonographFile');
00020 
00021 // Import the various classes for this grid
00022 import('controllers.grid.files.proof.ApprovedProofFilesGridDataProvider');
00023 import('controllers.grid.files.proof.ApprovedProofFilesGridRow');
00024 
00025 
00026 class ApprovedProofFilesGridHandler extends GridHandler {
00028    var $monograph;
00029 
00031    var $publicationFormat;
00032 
00036    function ApprovedProofFilesGridHandler() {
00037       parent::GridHandler(new ApprovedProofFilesGridDataProvider());
00038 
00039       $this->addRoleAssignment(
00040          array(ROLE_ID_PRESS_MANAGER, ROLE_ID_SERIES_EDITOR),
00041          array(
00042             'fetchGrid', 'fetchRow',
00043             'editApprovedProof', 'saveApprovedProof',
00044          )
00045       );
00046    }
00047 
00048    //
00049    // Implement template methods from PKPHandler
00050    //
00055    function initialize(&$request) {
00056       // Basic grid configuration
00057       $this->setId('proofFiles-' . $this->publicationFormat->getId());
00058       AppLocale::requireComponents(LOCALE_COMPONENT_OMP_EDITOR);
00059       $this->setTitle('payment.directSales');
00060 
00061       parent::initialize($request);
00062 
00063       // Columns
00064       $press =& $request->getPress();
00065       import('controllers.grid.files.proof.ApprovedProofFilesGridCellProvider');
00066       $cellProvider = new ApprovedProofFilesGridCellProvider($press->getSetting('pressCurrency'));
00067       $this->addColumn(new GridColumn(
00068          'name',
00069          'common.name',
00070          null,
00071          'controllers/grid/gridCell.tpl',
00072          $cellProvider,
00073          array('width' => 60, 'alignment' => COLUMN_ALIGNMENT_LEFT)
00074       ));
00075       $this->addColumn(new GridColumn(
00076          'approved',
00077          'payment.directSales.approved',
00078          null,
00079          'controllers/grid/common/cell/statusCell.tpl',
00080          $cellProvider
00081       ));
00082       $this->addColumn(new GridColumn(
00083          'price',
00084          'payment.directSales.availability',
00085          null,
00086          'controllers/grid/gridCell.tpl',
00087          $cellProvider
00088       ));
00089    }
00090 
00094    function authorize(&$request, &$args, $roleAssignments) {
00095       import('classes.security.authorization.OmpWorkflowStageAccessPolicy');
00096       $this->addPolicy(new OmpWorkflowStageAccessPolicy($request, $args, $roleAssignments, 'monographId', WORKFLOW_STAGE_ID_PRODUCTION));
00097 
00098       if (parent::authorize($request, $args, $roleAssignments)) {
00099          $publicationFormatId = (int) $request->getUserVar('publicationFormatId');
00100          $publicationFormatDao =& DAORegistry::getDAO('PublicationFormatDAO');
00101          $this->monograph =& $this->getAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH);
00102          $this->publicationFormat =& $publicationFormatDao->getById($publicationFormatId, $this->monograph->getId());
00103 
00104          return true;
00105       }
00106       return false;
00107    }
00108 
00113    function &getRowInstance() {
00114       $row = new ApprovedProofFilesGridRow();
00115       return $row;
00116    }
00120    function getRequestArgs() {
00121       return array_merge(
00122          parent::getRequestArgs(),
00123          array('publicationFormatId' => $this->publicationFormat->getId())
00124       );
00125    }
00126 
00127    //
00128    // Public handler methods
00129    //
00130    function editApprovedProof($args, &$request) {
00131       $this->initialize($request);
00132 
00133       import('controllers.grid.files.proof.form.ApprovedProofForm');
00134       $approvedProofForm = new ApprovedProofForm($this->monograph, $this->publicationFormat, $request->getUserVar('fileId'));
00135       $approvedProofForm->initData();
00136 
00137       $json = new JSONMessage(true, $approvedProofForm->fetch($request));
00138       return $json->getString();
00139    }
00140 
00141    function saveApprovedProof($args, &$request) {
00142       import('controllers.grid.files.proof.form.ApprovedProofForm');
00143       $approvedProofForm = new ApprovedProofForm($this->monograph, $this->publicationFormat, $request->getUserVar('fileId'));
00144       $approvedProofForm->readInputData();
00145 
00146       if ($approvedProofForm->validate()) {
00147          $fileIdAndRevision = $approvedProofForm->execute($request);
00148 
00149          // Let the calling grid reload itself
00150          return DAO::getDataChangedEvent($fileIdAndRevision);
00151       } else {
00152          $json = new JSONMessage(true, $approvedProofForm->fetch($request));
00153          return $json->getString();
00154       }
00155    }
00156 }
00157 
00158 ?>

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