Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
NotificationsGridCellProvider.inc.php
1 <?php
2 
17 import('lib.pkp.classes.controllers.grid.GridCellProvider');
18 import('lib.pkp.classes.linkAction.request.RedirectAction');
19 
25  parent::GridCellProvider();
26  }
27 
34  function getCellActions($request, $row, $column, $position = GRID_ACTION_POSITION_DEFAULT) {
35  if ( $column->getId() == 'title' ) {
36  return array();
37  } elseif ($column->getId() == 'task') {
38  $notification = $row->getData();
39 
40  $notificationMgr = new NotificationManager();
41  return array(new LinkAction(
42  'details',
43  new RedirectAction(
44  $notificationMgr->getNotificationUrl($request, $notification)
45  ),
46  $notificationMgr->getNotificationMessage($request, $notification)
47  ));
48  }
49  // This should be unreachable.
50  assert(false);
51  }
52 
53 
54  //
55  // Template methods from GridCellProvider
56  //
64  function getTemplateVarsFromRowColumn($row, $column) {
65  $notification = $row->getData();
66 
67  switch ($column->getId()) {
68  case 'title':
69  switch ($notification->getAssocType()) {
70  case ASSOC_TYPE_SUBMISSION:
71  $submissionId = $notification->getAssocId();
72  break;
73  case ASSOC_TYPE_SUBMISSION_FILE:
74  $fileId = $notification->getAssocId();
75  break;
76  case ASSOC_TYPE_SIGNOFF:
77  $signoffDao = DAORegistry::getDAO('SignoffDAO'); /* @var $signoffDao SignoffDAO */
78  $signoff = $signoffDao->getById($notification->getAssocId());
79  if ($signoff->getAssocType() == ASSOC_TYPE_SUBMISSION) {
80  $submissionId = $signoff->getAssocId();
81  } elseif ($signoff->getAssocType() == ASSOC_TYPE_SUBMISSION_FILE) {
82  $fileId = $signoff->getAssocId();
83  } else {
84  // Don't know of SIGNOFFs with other ASSOC types for TASKS
85  assert(false);
86  }
87  break;
88  case ASSOC_TYPE_REVIEW_ASSIGNMENT:
89  $reviewAssignmentDao = DAORegistry::getDAO('ReviewAssignmentDAO'); /* @var $reviewAssignmentDao ReviewAssignmentDAO */
90  $reviewAssignment = $reviewAssignmentDao->getById($notification->getAssocId());
91  assert(is_a($reviewAssignment, 'ReviewAssignment'));
92  $submissionId = $reviewAssignment->getSubmissionId();
93  break;
94  case ASSOC_TYPE_REVIEW_ROUND:
95  $reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO');
96  $reviewRound = $reviewRoundDao->getById($notification->getAssocId());
97  assert(is_a($reviewRound, 'ReviewRound'));
98  $submissionId = $reviewRound->getSubmissionId();
99  break;
100  default:
101  // Don't know of other ASSOC_TYPEs for TASK notifications
102  assert(false);
103  }
104 
105  if (!isset($submissionId) && isset($fileId)) {
106  assert(is_numeric($fileId));
107  $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO'); /* @var $submissionFileDao SubmissionFileDAO */
108  $submissionFile = $submissionFileDao->getLatestRevision($fileId);
109  assert(is_a($submissionFile, 'SubmissionFile'));
110  $submissionId = $submissionFile->getSubmissionId();
111  }
112  assert(is_numeric($submissionId));
113  $submissionDao = Application::getSubmissionDAO();
114  $submission = $submissionDao->getById($submissionId);
115  assert(is_a($submission, 'Submission'));
116 
117  $title = $submission->getLocalizedTitle();
118  if ( empty($title) ) $title = __('common.untitled');
119  return array('label' => $title);
120  break;
121  case 'task':
122  // The action has the label
123  return array('label' => '');
124  break;
125  }
126  }
127 }
128 
129 ?>
static & getDAO($name, $dbconn=null)
Base class for a grid column&#39;s cell provider.
This action request redirects to another page.
static getSubmissionDAO()
Class for a cell provider that can retrieve labels from notifications.
getCellActions($request, $row, $column, $position=GRID_ACTION_POSITION_DEFAULT)
Base class defining an action that can be performed by the user in the user interface.