Open Journal Systems  3.0.0
 All Classes Namespaces Functions Variables Groups Pages
NotificationsGridHandler.inc.php
1 <?php
2 
16 // Import UI base classes.
17 import('lib.pkp.classes.controllers.grid.GridHandler');
18 
19 // Other classes associated with this grid
20 import('lib.pkp.controllers.grid.notifications.NotificationsGridRow');
21 import('lib.pkp.controllers.grid.notifications.NotificationsGridCellProvider');
22 
28  parent::GridHandler();
29 
30  $this->addRoleAssignment(
31  array(ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR, ROLE_ID_ASSISTANT, ROLE_ID_AUTHOR, ROLE_ID_REVIEWER),
32  array('fetchGrid', 'deleteNotification')
33  );
34  }
35 
36 
37  //
38  // Getters and Setters
39  //
40 
41  //
42  // Implement template methods from PKPHandler
43  //
47  function authorize($request, &$args, $roleAssignments) {
48  import('lib.pkp.classes.security.authorization.PKPSiteAccessPolicy');
49  $this->addPolicy(new PKPSiteAccessPolicy($request, null, $roleAssignments));
50  return parent::authorize($request, $args, $roleAssignments);
51  }
52 
56  function initialize($request, $args = null) {
57  parent::initialize($request);
58  AppLocale::requireComponents(LOCALE_COMPONENT_APP_SUBMISSION, LOCALE_COMPONENT_PKP_SUBMISSION);
59 
60  $cellProvider = new NotificationsGridCellProvider();
61  $this->addColumn(
62  new GridColumn(
63  'task',
64  'common.tasks',
65  null,
66  'controllers/grid/gridCell.tpl',
67  $cellProvider,
68  array('html' => true,
69  'alignment' => COLUMN_ALIGNMENT_LEFT)
70  )
71  );
72  $this->addColumn(
73  new GridColumn(
74  'title',
75  'submission.title',
76  null,
77  'controllers/grid/gridCell.tpl',
78  $cellProvider,
79  array('html' => true,
80  'alignment' => COLUMN_ALIGNMENT_LEFT)
81  )
82  );
83 
84  // Set the no items row text
85  $this->setEmptyRowText('grid.noItems');
86  }
87 
88 
89  //
90  // Overridden methods from GridHandler
91  //
96  protected function loadData($request, $filter) {
97  $user = $request->getUser();
98 
99  // Get all level task notifications.
100  $notificationDao = DAORegistry::getDAO('NotificationDAO'); /* @var $notificationDao NotificationDAO */
101  $notifications = $notificationDao->getByUserId($user->getId(), NOTIFICATION_LEVEL_TASK);
102  $rowData = $notifications->toAssociativeArray();
103 
104  // Remove not listable task types.
105  $notListableTaskTypes = $this->_getNotListableTaskTypes();
106  foreach ($rowData as $key => $notification) {
107  if (in_array($notification->getType(), $notListableTaskTypes)) {
108  unset($rowData[$key]);
109  }
110  }
111 
112  return $rowData;
113  }
114 
115 
116  //
117  // Public methods
118  //
124  function deleteNotification($args, $request) {
125  $notificationDao = DAORegistry::getDAO('NotificationDAO');
126  $user = $request->getUser();
127  $notification = $notificationDao->getById(
128  $request->getUserVar('notificationId'),
129  $user->getId()
130  );
131  $notificationDao->deleteObject($notification);
132  return DAO::getDataChangedEvent();
133  }
134 
135 
136  //
137  // Private helper methods.
138  //
145  return array(NOTIFICATION_TYPE_SIGNOFF_COPYEDIT, NOTIFICATION_TYPE_SIGNOFF_PROOF);
146  }
147 
151  protected function getRowInstance() {
152  return new NotificationsGridRow();
153  }
154 }
155 
156 ?>
static & getDAO($name, $dbconn=null)
addPolicy($authorizationPolicy, $addToTop=false)
static requireComponents()
setEmptyRowText($emptyRowText)
addColumn($column)
Class defining basic operations for handling HTML grids.
addRoleAssignment($roleIds, $operations)
static getDataChangedEvent($elementId=null, $parentElementId=null)
Definition: DAO.inc.php:606
Class to that makes sure that a user is logged in.
A row containing a notification.
Handle the display of notifications for a given user.
Class for a cell provider that can retrieve labels from notifications.
Represents a column within a grid. It is used to configure the way cells within a column are displaye...
authorize($request, &$args, $roleAssignments)