Open Journal Systems  3.0.0
 All Data Structures Namespaces Functions Variables Groups Pages
SubmissionsListGridHandler.inc.php
1 <?php
2 
16 // Import grid base classes.
17 import('lib.pkp.classes.controllers.grid.GridHandler');
18 
19 // Import submissions list grid specific classes.
20 import('lib.pkp.controllers.grid.submissions.SubmissionsListGridCellProvider');
21 
22 // Access decision actions constants.
23 import('classes.workflow.EditorDecisionActionsManager');
24 
27  var $_isManager;
28 
32  function SubmissionsListGridHandler() {
33  parent::GridHandler();
34  }
35 
36 
37  //
38  // Implement template methods from PKPHandler
39  //
43  function authorize($request, &$args, $roleAssignments) {
44  import('lib.pkp.classes.security.authorization.ContextAccessPolicy');
45  $this->addPolicy(new ContextAccessPolicy($request, $roleAssignments));
46  return parent::authorize($request, $args, $roleAssignments);
47  }
48 
52  function initialize($request) {
53  parent::initialize($request);
54 
55  // Load submission-specific translations.
57  LOCALE_COMPONENT_APP_COMMON,
58  LOCALE_COMPONENT_APP_SUBMISSION,
59  LOCALE_COMPONENT_PKP_SUBMISSION
60  );
61 
62  // Fetch the authorized roles and determine if the user is a manager.
63  $authorizedRoles = $this->getAuthorizedContextObject(ASSOC_TYPE_USER_ROLES);
64  $this->_isManager = in_array(ROLE_ID_MANAGER, $authorizedRoles);
65 
66  // If there is more than one context in the system, add a context column
67  $cellProvider = new SubmissionsListGridCellProvider($request->getUser(), $authorizedRoles);
68  $this->addColumn(
69  new GridColumn(
70  'id',
71  null,
72  __('common.id'),
73  'controllers/grid/gridCell.tpl',
74  $cellProvider,
75  array('alignment' => COLUMN_ALIGNMENT_LEFT,
76  'width' => 10)
77  )
78  );
79  $this->addColumn(
80  new GridColumn(
81  'title',
82  'grid.submission.itemTitle',
83  null,
84  null,
85  $cellProvider,
86  array('html' => true,
87  'alignment' => COLUMN_ALIGNMENT_LEFT)
88  )
89  );
90  $this->addColumn(
91  new GridColumn(
92  'stage',
93  'workflow.stage',
94  null,
95  null,
96  $cellProvider,
97  array('alignment' => COLUMN_ALIGNMENT_LEFT,
98  'width' => 15)
99  )
100  );
101  }
102 
106  function getIsSubcomponent() {
107  return true;
108  }
113  protected function getFilterForm() {
114  return 'controllers/grid/submissions/submissionsGridFilter.tpl';
115  }
120  function renderFilter($request, $filterData = array()) {
122  $workflowStages[0] = 'workflow.stage.any';
123  ksort($workflowStages);
124  $filterColumns = $this->getFilterColumns();
125 
126  $filterData = array(
127  'columns' => $filterColumns,
128  'workflowStages' => $workflowStages,
129  'gridId' => $this->getId()
130  );
131 
132  return parent::renderFilter($request, $filterData);
133  }
134 
138  function getFilterSelectionData($request) {
139  $search = (string) $request->getUserVar('search');
140  $column = (string) $request->getUserVar('column');
141  $stageId = (int) $request->getUserVar('stageId');
142 
143  return array(
144  'search' => $search,
145  'column' => $column,
146  'stageId' => $stageId
147  );
148  }
149 
150 
151  //
152  // Public handler operations
153  //
160  function deleteSubmission($args, $request) {
161  $submissionDao = Application::getSubmissionDAO();
162  $submission = $submissionDao->getById(
163  (int) $request->getUserVar('submissionId')
164  );
165 
166  // If the submission is incomplete, or this is a manager, allow it to be deleted
167  if ($submission && ($this->_isManager || $submission->getSubmissionProgress() != 0)) {
168  $submissionDao->deleteById($submission->getId());
169 
170  $user = $request->getUser();
171  NotificationManager::createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SUCCESS, array('contents' => __('notification.removedSubmission')));
172  return DAO::getDataChangedEvent($submission->getId());
173  } else {
174  return new JSONMessage(false);
175  }
176  }
177 
178 
179  //
180  // Protected methods
181  //
185  protected function initFeatures($request, $args) {
186  import('lib.pkp.classes.controllers.grid.feature.InfiniteScrollingFeature');
187  import('lib.pkp.classes.controllers.grid.feature.CollapsibleGridFeature');
188  return array(new InfiniteScrollingFeature('infiniteScrolling', $this->getItemsNumber()), new CollapsibleGridFeature());
189  }
190 
195  protected function getRowInstance() {
196  return new SubmissionsListGridRow($this->_isManager);
197  }
203  protected function getFilterColumns() {
204  return array(
205  'title' => __('submission.title'),
206  'author' => __('submission.authors'));
207  }
208 
214  protected function getFilterValues($filter) {
215  if (isset($filter['search']) && $filter['search']) {
216  $search = $filter['search'];
217  } else {
218  $search = null;
219  }
220 
221  if (isset($filter['column']) && $filter['column']) {
222  $column = $filter['column'];
223  } else {
224  $column = null;
225  }
226 
227  if (isset($filter['stageId']) && $filter['stageId']) {
228  $stageId = $filter['stageId'];
229  } else {
230  $stageId = null;
231  }
232 
233  return array($search, $column, $stageId);
234  }
235 
240  protected function getItemsNumber() {
241  return 5;
242  }
243 }
244 
245 ?>
addPolicy($authorizationPolicy, $addToTop=false)
Handle submission list grid requests.
static requireComponents()
addColumn($column)
This class defines basic operations for handling HTML grids. Grids are used to implement a standardiz...
Class to represent a JSON (Javascript Object Notation) message.
static getSubmissionDAO()
Add collapse and expand functionality to grids.
Add infinite scrolling functionality to grids. It doesn&#39;t support category grids. ...
renderFilter($request, $filterData=array())
Class to control access to PKP applications&#39; setup components.
static getWorkflowStageTranslationKeys()
The GridColumn class represents a column within a grid. It is used to format the data presented in a ...
authorize($request, &$args, $roleAssignments)
static getDataChangedEvent($elementId=null, $parentElementId=null, $content= '')
Definition: DAO.inc.php:633
& getAuthorizedContextObject($assocType)