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

controllers/grid/notifications/NotificationsGridCellProvider.inc.php

00001 <?php
00002 
00016 import('lib.pkp.classes.controllers.grid.GridCellProvider');
00017 import('lib.pkp.classes.linkAction.request.RedirectAction');
00018 
00019 class NotificationsGridCellProvider extends GridCellProvider {
00023    function NotificationsGridCellProvider() {
00024       parent::GridCellProvider();
00025    }
00026 
00033    function getCellActions(&$request, &$row, &$column, $position = GRID_ACTION_POSITION_DEFAULT) {
00034       if ( $column->getId() == 'title' ) {
00035          return array();
00036       } elseif ($column->getId() == 'task') {
00037          $notification =& $row->getData();
00038 
00039          $notificationMgr = new NotificationManager();
00040          return array(new LinkAction(
00041             'details',
00042             new RedirectAction(
00043                $notificationMgr->getNotificationUrl($request, $notification)
00044             ),
00045             $notificationMgr->getNotificationMessage($request, $notification)
00046          ));
00047       }
00048       // This should be unreachable.
00049       assert(false);
00050    }
00051 
00052    //
00053    // Template methods from GridCellProvider
00054    //
00062    function getTemplateVarsFromRowColumn(&$row, $column) {
00063       $notification =& $row->getData();
00064 
00065       switch ($column->getId()) {
00066          case 'title':
00067             switch ($notification->getAssocType()) {
00068                case ASSOC_TYPE_MONOGRAPH:
00069                   $monographId = $notification->getAssocId();
00070                   break;
00071                case ASSOC_TYPE_MONOGRAPH_FILE:
00072                   $fileId = $notification->getAssocId();
00073                   break;
00074                case ASSOC_TYPE_SIGNOFF:
00075                   $signoffDao =& DAORegistry::getDAO('SignoffDAO'); /* @var $signoffDao SignoffDAO */
00076                   $signoff =& $signoffDao->getById($notification->getAssocId());
00077                   if ($signoff->getAssocType() == ASSOC_TYPE_MONOGRAPH) {
00078                      $monographId = $signoff->getAssocId();
00079                   } elseif ($signoff->getAssocType() == ASSOC_TYPE_MONOGRAPH_FILE) {
00080                      $fileId = $signoff->getAssocId();
00081                   } else {
00082                      // Don't know of SIGNOFFs with other ASSOC types for TASKS
00083                      assert(false);
00084                   }
00085                   break;
00086                case ASSOC_TYPE_REVIEW_ASSIGNMENT:
00087                   $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO'); /* @var $reviewAssignmentDao ReviewAssignmentDAO */
00088                   $reviewAssignment =& $reviewAssignmentDao->getById($notification->getAssocId());
00089                   assert(is_a($reviewAssignment, 'ReviewAssignment'));
00090                   $monographId = $reviewAssignment->getSubmissionId();
00091                   break;
00092                case ASSOC_TYPE_REVIEW_ROUND:
00093                   $reviewRoundDao =& DAORegistry::getDAO('ReviewRoundDAO');
00094                   $reviewRound =& $reviewRoundDao->getReviewRoundById($notification->getAssocId());
00095                   assert(is_a($reviewRound, 'ReviewRound'));
00096                   $monographId = $reviewRound->getSubmissionId();
00097                   break;
00098                default:
00099                   // Don't know of other ASSOC_TYPEs for TASK notifications
00100                   assert(false);
00101             }
00102 
00103             if (!isset($monographId) && isset($fileId)) {
00104                assert(is_numeric($fileId));
00105                $submissionFileDao =& DAORegistry::getDAO('SubmissionFileDAO'); /* @var $submissionFileDao SubmissionFileDAO */
00106                $monographFile =& $submissionFileDao->getLatestRevision($fileId);
00107                assert(is_a($monographFile, 'MonographFile'));
00108                $monographId = $monographFile->getMonographId();
00109             }
00110             assert(is_numeric($monographId));
00111             $monographDao =& DAORegistry::getDAO('MonographDAO'); /* @var $monographDao MonographDAO */
00112             $monograph =& $monographDao->getById($monographId);
00113             assert(is_a($monograph, 'Monograph'));
00114 
00115             $title = $monograph->getLocalizedTitle();
00116             if ( empty($title) ) $title = __('common.untitled');
00117             return array('label' => $title);
00118             break;
00119          case 'task':
00120             // The action has the label
00121             return array('label' => '');
00122             break;
00123       }
00124    }
00125 }
00126 
00127 ?>

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