Open Journal Systems  3.0.0
 All Data Structures Namespaces Functions Variables Groups Pages
IssueGalleyGridHandler.inc.php
1 <?php
2 
16 import('lib.pkp.classes.controllers.grid.GridHandler');
17 import('controllers.grid.issueGalleys.IssueGalleyGridRow');
18 
24  parent::GridHandler();
25  $this->addRoleAssignment(
26  array(ROLE_ID_MANAGER),
27  array(
28  'fetchGrid', 'fetchRow', 'saveSequence',
29  'add', 'edit', 'upload', 'download', 'update', 'delete'
30  )
31  );
32  }
33 
34 
35  //
36  // Implement template methods from PKPHandler
37  //
41  function authorize($request, &$args, $roleAssignments) {
42  import('lib.pkp.classes.security.authorization.ContextAccessPolicy');
43  $this->addPolicy(new ContextAccessPolicy($request, $roleAssignments));
44 
45  import('classes.security.authorization.OjsIssueRequiredPolicy');
46  $this->addPolicy(new OjsIssueRequiredPolicy($request, $args));
47 
48  // If a signoff ID was specified, authorize it.
49  if ($request->getUserVar('issueGalleyId')) {
50  import('classes.security.authorization.OjsIssueGalleyRequiredPolicy');
51  $this->addPolicy(new OjsIssueGalleyRequiredPolicy($request, $args));
52  }
53 
54  return parent::authorize($request, $args, $roleAssignments);
55  }
56 
60  function getDataElementSequence($issueGalley) {
61  return $issueGalley->getSequence();
62  }
63 
67  function setDataElementSequence($request, $rowId, &$issueGalley, $newSequence) {
68  $issueGalleyDao = DAORegistry::getDAO('IssueGalleyDAO'); /* @var $issueGalleyDao IssueGalleyDAO */
69  $issueGalley->setSequence($newSequence);
70  $issueGalleyDao->updateObject($issueGalley);
71  }
72 
76  function initFeatures($request, $args) {
77  import('lib.pkp.classes.controllers.grid.feature.OrderGridItemsFeature');
78  return array(new OrderGridItemsFeature());
79  }
80 
84  function getRequestArgs() {
85  $issue = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE);
86  $issueGalley = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE_GALLEY);
87  $requestArgs = (array) parent::getRequestArgs();
88  $requestArgs['issueId'] = $issue->getId();
89  if ($issueGalley) $requestArgs['issueGalleyId'] = $issueGalley->getId();
90  return $requestArgs;
91  }
92 
96  function initialize($request, $args) {
97  parent::initialize($request, $args);
98 
99  AppLocale::requireComponents(LOCALE_COMPONENT_APP_EDITOR, LOCALE_COMPONENT_PKP_SUBMISSION);
100 
101  // Add action
102  $router = $request->getRouter();
103  import('lib.pkp.classes.linkAction.request.AjaxModal');
104  $this->addAction(
105  new LinkAction(
106  'add',
107  new AjaxModal(
108  $router->url(
109  $request, null, null, 'add', null,
110  array_merge($this->getRequestArgs(), array('gridId' => $this->getId()))
111  ),
112  __('grid.action.addIssueGalley'),
113  'modal_add'
114  ),
115  __('grid.action.addIssueGalley'),
116  'add_category'
117  )
118  );
119 
120  // Grid columns.
121  import('controllers.grid.issueGalleys.IssueGalleyGridCellProvider');
122  $issueGalleyGridCellProvider = new IssueGalleyGridCellProvider();
123 
124  // Issue identification
125  $this->addColumn(
126  new GridColumn(
127  'label',
128  'submission.layout.galleyLabel',
129  null,
130  null,
131  $issueGalleyGridCellProvider
132  )
133  );
134 
135  // Language, if more than one is supported
136  $journal = $request->getJournal();
137  if (count($journal->getSupportedLocaleNames())>1) {
138  $this->addColumn(
139  new GridColumn(
140  'locale',
141  'common.language',
142  null,
143  null,
144  $issueGalleyGridCellProvider
145  )
146  );
147  }
148 
149  // Public ID, if enabled
150  if ($journal->getSetting('enablePublicGalleyId')) {
151  $this->addColumn(
152  new GridColumn(
153  'publicGalleyId',
154  'submission.layout.publicGalleyId',
155  null,
156  null,
157  $issueGalleyGridCellProvider
158  )
159  );
160  }
161  }
162 
167  protected function getRowInstance() {
168  $issue = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE);
169  return new IssueGalleyGridRow($issue->getId());
170  }
171 
172  //
173  // Public operations
174  //
180  function add($args, $request) {
181  // Calling editIssueData with an empty ID will add
182  // a new issue.
183  return $this->edit($args, $request);
184  }
185 
192  function edit($args, $request) {
193  $issue = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE);
194  $issueGalley = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE_GALLEY);
195 
196  import('controllers.grid.issues.form.IssueGalleyForm');
197  $issueGalleyForm = new IssueGalleyForm($request, $issue, $issueGalley);
198  $issueGalleyForm->initData();
199  return new JSONMessage(true, $issueGalleyForm->fetch($request));
200  }
201 
208  function upload($args, $request) {
209  $user = $request->getUser();
210 
211  import('lib.pkp.classes.file.TemporaryFileManager');
212  $temporaryFileManager = new TemporaryFileManager();
213  $temporaryFile = $temporaryFileManager->handleUpload('uploadedFile', $user->getId());
214  if ($temporaryFile) {
215  $json = new JSONMessage(true);
216  $json->setAdditionalAttributes(array(
217  'temporaryFileId' => $temporaryFile->getId()
218  ));
219  return $json;
220  } else {
221  return new JSONMessage(false, __('common.uploadFailed'));
222  }
223  }
224 
231  function download($args, $request) {
232  $issue = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE);
233  $issueGalley = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE_GALLEY);
234  import('classes.file.IssueFileManager');
235  $issueFileManager = new IssueFileManager($issue->getId());
236  return $issueFileManager->downloadFile($issueGalley->getFileId());
237  }
238 
245  function update($args, $request) {
246  $issue = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE);
247  $issueGalley = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE_GALLEY);
248 
249  import('controllers.grid.issues.form.IssueGalleyForm');
250  $issueGalleyForm = new IssueGalleyForm($request, $issue, $issueGalley);
251  $issueGalleyForm->readInputData();
252 
253  if ($issueGalleyForm->validate($request)) {
254  $issueId = $issueGalleyForm->execute($request);
255  return DAO::getDataChangedEvent($issueId);
256  } else {
257  return new JSONMessage(false);
258  }
259  }
260 
266  function delete($args, $request) {
267  $issueGalleyDao = DAORegistry::getDAO('IssueGalleyDAO');
268  $issueGalley = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE_GALLEY);
269  $issueGalley->getId();
270  $issueGalleyDao->deleteObject($issueGalley);
271  return DAO::getDataChangedEvent();
272  }
273 
277  protected function loadData($request, $filter) {
278  $issue = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE);
279  $issueGalleyDao = DAORegistry::getDAO('IssueGalleyDAO');
280  return $issueGalleyDao->getByIssueId($issue->getId());
281  }
282 }
283 
284 ?>
static & getDAO($name, $dbconn=null)
addPolicy($authorizationPolicy, $addToTop=false)
Policy that ensures that the request contains a valid issue.
downloadFile($fileId, $inline=false)
static requireComponents()
addAction($action, $position=GRID_ACTION_POSITION_ABOVE)
Grid cell provider for the issue galleys grid.
addColumn($column)
This class defines basic operations for handling HTML grids. Grids are used to implement a standardiz...
Class defining operations for issue file management.
addRoleAssignment($roleIds, $operations)
A modal that retrieves its content from via AJAX.
Class to represent a JSON (Javascript Object Notation) message.
Handle issue galley grid row requests.
authorize($request, &$args, $roleAssignments)
setDataElementSequence($request, $rowId, &$issueGalley, $newSequence)
Policy that ensures that the request contains a valid issue galley.
Class to control access to PKP applications&#39; setup components.
Issue galley editing form.
Implements grid ordering functionality.
Handle issues grid requests.
The GridColumn class represents a column within a grid. It is used to format the data presented in a ...
static getDataChangedEvent($elementId=null, $parentElementId=null, $content= '')
Definition: DAO.inc.php:633
& getAuthorizedContextObject($assocType)
Base class defining an action that can be performed by the user in the user interface.