Open Journal Systems  3.0.0
 All Classes 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.PKPSiteAccessPolicy');
45  $this->addPolicy(new PKPSiteAccessPolicy($request, null, $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  // Load submissions.
63  $user = $request->getUser();
64  $this->setGridDataElements($this->getSubmissions($request, $user->getId()));
65 
66  // Fetch the authorized roles and determine if the user is a manager.
67  $authorizedRoles = $this->getAuthorizedContextObject(ASSOC_TYPE_USER_ROLES);
68  $this->_isManager = in_array(ROLE_ID_MANAGER, $authorizedRoles);
69 
70  // If there is more than one context in the system, add a context column
71  $contextDao = Application::getContextDAO();
72  $contexts = $contextDao->getAll();
73  $cellProvider = new SubmissionsListGridCellProvider($authorizedRoles);
74  if($contexts->getCount() > 1) {
75 
76  $hasRoleCount = 0;
77  $userGroupDao = DAORegistry::getDAO('UserGroupDAO');
78 
79  while ($context = $contexts->next()) {
80  $userGroups = $userGroupDao->getByUserId($user->getId(), $context->getId());
81  if ($userGroups->getCount() > 0) $hasRoleCount ++;
82  }
83 
84  if ($hasRoleCount > 1 || $request->getContext() == null) {
85  $this->addColumn(
86  new GridColumn(
87  'context',
88  'context.context',
89  null,
90  'controllers/grid/gridCell.tpl',
91  $cellProvider
92  )
93  );
94  }
95  }
96 
97  $this->addColumn(
98  new GridColumn(
99  'author',
100  'submission.authors',
101  null,
102  'controllers/grid/gridCell.tpl',
103  $cellProvider
104  )
105  );
106  $this->addColumn(
107  new GridColumn(
108  'title',
109  'submission.title',
110  null,
111  'controllers/grid/gridCell.tpl',
112  $cellProvider,
113  array('html' => true,
114  'alignment' => COLUMN_ALIGNMENT_LEFT)
115  )
116  );
117 
118  $this->addColumn(
119  new GridColumn(
120  'status',
121  'common.status',
122  null,
123  'controllers/grid/gridCell.tpl',
124  $cellProvider
125  )
126  );
127  }
128 
129 
130  //
131  // Public handler operations
132  //
139  function deleteSubmission($args, $request) {
140  $submissionDao = Application::getSubmissionDAO();
141  $submission = $submissionDao->getById(
142  (int) $request->getUserVar('submissionId')
143  );
144 
145  // If the submission is incomplete, or this is a manager, allow it to be deleted
146  if ($submission && ($this->_isManager || $submission->getSubmissionProgress() != 0)) {
147  $submissionDao->deleteById($submission->getId());
148 
149  $user = $request->getUser();
150  NotificationManager::createTrivialNotification($user->getId(), NOTIFICATION_TYPE_SUCCESS, array('contents' => __('notification.removedSubmission')));
151  return DAO::getDataChangedEvent($submission->getId());
152  } else {
153  $json = new JSONMessage(false);
154  return $json->getString();
155  }
156  }
157 
158 
159  //
160  // Protected methods
161  //
165  function initFeatures($request, $args) {
166  import('lib.pkp.classes.controllers.grid.feature.PagingFeature');
167  return array(new PagingFeature());
168  }
169 
177  function getSubmissions($request, $userId) {
178  // Must be implemented by sub-classes.
179  assert(false);
180  }
181 
186  function getRowInstance() {
187  return new SubmissionsListGridRow($this->_isManager);
188  }
189 }
190 
191 ?>
static & getDAO($name, $dbconn=null)
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...
setGridDataElements($data)
Class to represent a JSON (Javascript Object Notation) message.
Class for a cell provider that can retrieve labels from submissions.
static getSubmissionDAO()
Class to that makes sure that a user is logged in.
Add paging functionality to grids.
static getContextDAO()
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:632
& getAuthorizedContextObject($assocType)