Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
ApprovedProofFilesGridHandler.inc.php
1 <?php
2 
16 // import grid signoff files grid base classes
17 import('lib.pkp.classes.controllers.grid.GridHandler');
18 
19 // Import monograph file class which contains the SUBMISSION_FILE_* constants.
20 import('classes.monograph.MonographFile');
21 
22 // Import the various classes for this grid
23 import('controllers.grid.files.proof.ApprovedProofFilesGridDataProvider');
24 import('controllers.grid.files.proof.ApprovedProofFilesGridRow');
25 
26 
29  var $monograph;
30 
33 
38  parent::GridHandler(new ApprovedProofFilesGridDataProvider());
39 
40  $this->addRoleAssignment(
41  array(ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR),
42  array(
43  'fetchGrid', 'fetchRow',
44  'editApprovedProof', 'saveApprovedProof',
45  )
46  );
47  }
48 
49  //
50  // Implement template methods from PKPHandler
51  //
56  function initialize($request) {
57  // Basic grid configuration
58  $this->setId('proofFiles-' . $this->publicationFormat->getId());
59  AppLocale::requireComponents(LOCALE_COMPONENT_APP_EDITOR);
60  $this->setTitle('payment.directSales');
61 
62  parent::initialize($request);
63 
64  // Columns
65  $press = $request->getPress();
66  import('controllers.grid.files.proof.ApprovedProofFilesGridCellProvider');
67  $cellProvider = new ApprovedProofFilesGridCellProvider($press->getSetting('currency'));
68  $this->addColumn(new GridColumn(
69  'name',
70  'common.name',
71  null,
72  'controllers/grid/gridCell.tpl',
73  $cellProvider,
74  array('width' => 60, 'alignment' => COLUMN_ALIGNMENT_LEFT)
75  ));
76  $this->addColumn(new GridColumn(
77  'approved',
78  'payment.directSales.approved',
79  null,
80  'controllers/grid/common/cell/statusCell.tpl',
81  $cellProvider
82  ));
83  $this->addColumn(new GridColumn(
84  'price',
85  'payment.directSales.availability',
86  null,
87  'controllers/grid/gridCell.tpl',
88  $cellProvider
89  ));
90  }
91 
95  function authorize($request, &$args, $roleAssignments) {
96  import('classes.security.authorization.WorkflowStageAccessPolicy');
97  $this->addPolicy(new WorkflowStageAccessPolicy($request, $args, $roleAssignments, 'submissionId', WORKFLOW_STAGE_ID_PRODUCTION));
98 
99  if (parent::authorize($request, $args, $roleAssignments)) {
100  $publicationFormatId = (int) $request->getUserVar('publicationFormatId');
101  $publicationFormatDao = DAORegistry::getDAO('PublicationFormatDAO');
102  $this->monograph = $this->getAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH);
103  $this->publicationFormat = $publicationFormatDao->getById($publicationFormatId, $this->monograph->getId());
104 
105  return true;
106  }
107  return false;
108  }
109 
114  function getRowInstance() {
115  return new ApprovedProofFilesGridRow();
116  }
120  function getRequestArgs() {
121  return array_merge(
122  parent::getRequestArgs(),
123  array('publicationFormatId' => $this->publicationFormat->getId())
124  );
125  }
127  //
128  // Public handler methods
129  //
130  function editApprovedProof($args, $request) {
131  $this->initialize($request);
132 
133  import('controllers.grid.files.proof.form.ApprovedProofForm');
134  $approvedProofForm = new ApprovedProofForm($this->monograph, $this->publicationFormat, $request->getUserVar('fileId'));
135  $approvedProofForm->initData();
136 
137  $json = new JSONMessage(true, $approvedProofForm->fetch($request));
138  return $json->getString();
139  }
140 
141  function saveApprovedProof($args, $request) {
142  import('controllers.grid.files.proof.form.ApprovedProofForm');
143  $approvedProofForm = new ApprovedProofForm($this->monograph, $this->publicationFormat, $request->getUserVar('fileId'));
144  $approvedProofForm->readInputData();
145 
146  if ($approvedProofForm->validate()) {
147  $fileIdAndRevision = $approvedProofForm->execute($request);
148 
149  // Let the calling grid reload itself
150  return DAO::getDataChangedEvent($fileIdAndRevision);
151  } else {
152  $json = new JSONMessage(true, $approvedProofForm->fetch($request));
153  return $json->getString();
154  }
155  }
156 }
157 
158 ?>
Handle approved proof grid row requests.
static & getDAO($name, $dbconn=null)
addPolicy($authorizationPolicy, $addToTop=false)
static requireComponents()
addColumn($column)
Class defining basic operations for handling HTML grids.
Class to control access to OMP&#39;s submission workflow stage components.
addRoleAssignment($roleIds, $operations)
authorize($request, &$args, $roleAssignments)
Class to represent a JSON (Javascript Object Notation) message.
static getDataChangedEvent($elementId=null, $parentElementId=null)
Definition: DAO.inc.php:606
Approved proof files grid data provider.
Subclass of file grid for approved proof files.
Form for editing approved proofs (available for direct sales).
Represents a column within a grid. It is used to configure the way cells within a column are displaye...
Cell provider to retrieve the approved proof files grid data.
& getAuthorizedContextObject($assocType)