• Main Page
  • Modules
  • Classes
  • Files
  • File List

controllers/grid/notifications/NotificationsGridHandler.inc.php

00001 <?php
00002 
00015 // Import UI base classes.
00016 import('lib.pkp.classes.controllers.grid.GridHandler');
00017 
00018 // Grid-specific classes.
00019 import('controllers.grid.notifications.NotificationsGridCellProvider');
00020 
00021 class NotificationsGridHandler extends GridHandler {
00025    function NotificationsGridHandler() {
00026       parent::GridHandler();
00027 
00028       $this->addRoleAssignment(
00029          array(ROLE_ID_PRESS_MANAGER, ROLE_ID_SERIES_EDITOR, ROLE_ID_PRESS_ASSISTANT, ROLE_ID_AUTHOR, ROLE_ID_REVIEWER),
00030          array('fetchGrid')
00031       );
00032    }
00033 
00034 
00035    //
00036    // Getters and Setters
00037    //
00038 
00039    //
00040    // Implement template methods from PKPHandler
00041    //
00048    function authorize(&$request, $args, $roleAssignments) {
00049       import('lib.pkp.classes.security.authorization.PKPSiteAccessPolicy');
00050       $this->addPolicy(new PKPSiteAccessPolicy($request, null, $roleAssignments));
00051       return parent::authorize($request, $args, $roleAssignments);
00052    }
00053 
00057    function initialize(&$request) {
00058       parent::initialize($request);
00059 
00060       $cellProvider = new NotificationsGridCellProvider();
00061       $this->addColumn(
00062          new GridColumn(
00063             'task',
00064             'common.tasks',
00065             null,
00066             'controllers/grid/gridCell.tpl',
00067             $cellProvider,
00068             array('html' => true,
00069                   'alignment' => COLUMN_ALIGNMENT_LEFT)
00070          )
00071       );
00072       $this->addColumn(
00073          new GridColumn(
00074             'title',
00075             'monograph.title',
00076             null,
00077             'controllers/grid/gridCell.tpl',
00078             $cellProvider,
00079             array('alignment' => COLUMN_ALIGNMENT_LEFT)
00080          )
00081       );
00082 
00083       // Set the no items row text
00084       $this->setEmptyRowText('grid.noItems');
00085    }
00086 
00087 
00088    //
00089    // Overridden methods from GridHandler
00090    //
00096    function loadData(&$request) {
00097       $user =& $request->getUser();
00098 
00099       // Get all level task notifications.
00100       $notificationDao =& DAORegistry::getDAO('NotificationDAO'); /* @var $notificationDao NotificationDAO */
00101       $notifications =& $notificationDao->getByUserId($user->getId(), NOTIFICATION_LEVEL_TASK);
00102       $rowData = $notifications->toAssociativeArray();
00103 
00104       // Remove not listable task types.
00105       $notListableTaskTypes = $this->_getNotListableTaskTypes();
00106       foreach ($rowData as $key => $notification) {
00107          if (in_array($notification->getType(), $notListableTaskTypes)) {
00108             unset($rowData[$key]);
00109          }
00110       }
00111 
00112       return $rowData;
00113    }
00114 
00115 
00116    //
00117    // Private helper methods.
00118    //
00124    function _getNotListableTaskTypes() {
00125       return array(NOTIFICATION_TYPE_SIGNOFF_COPYEDIT, NOTIFICATION_TYPE_SIGNOFF_PROOF);
00126    }
00127 }
00128 
00129 ?>

Generated on Mon Sep 17 2012 13:58:56 for Open Monograph Press by  doxygen 1.7.1