Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
ReviewerGridCellProvider.inc.php
1 <?php
2 
16 import('lib.pkp.classes.controllers.grid.DataObjectGridCellProvider');
17 
18 import('lib.pkp.classes.linkAction.request.AjaxModal');
19 import('lib.pkp.classes.linkAction.request.AjaxAction');
20 
26  parent::DataObjectGridCellProvider();
27  }
28 
29 
30  //
31  // Template methods from GridCellProvider
32  //
39  function getCellState($row, $column) {
40  $reviewAssignment = $row->getData();
41  $columnId = $column->getId();
42  assert(is_a($reviewAssignment, 'DataObject') && !empty($columnId));
43  switch ($columnId) {
44  case 'name':
45  if ($reviewAssignment->getDateCompleted())
46  return 'linkReview';
47  if ($reviewAssignment->getDateDue() < Core::getCurrentDate() || $reviewAssignment->getDateResponseDue() < Core::getCurrentDate())
48  return 'overdue';
49 
50  return '';
51  case 'considered':
52  // The review has not been completed.
53  if (!$reviewAssignment->getDateCompleted()) return 'unfinished';
54 
55  // The reviewer has been sent an acknowledgement.
56  // Completed states can be 'unconsidered' by an editor.
57  if ($reviewAssignment->getDateAcknowledged() && !$reviewAssignment->getUnconsidered()) {
58  return 'completed';
59  }
60 
61  if ($reviewAssignment->getUnconsidered() == REVIEW_ASSIGNMENT_UNCONSIDERED) {
62  return 'reviewReady';
63  }
64 
65  // Check if the somebody assigned to this stage has read the review.
66  $submissionDao = Application::getSubmissionDAO();
67  $userGroupDao = DAORegistry::getDAO('UserGroupDAO');
68  $userStageAssignmentDao = DAORegistry::getDAO('UserStageAssignmentDAO');
69  $viewsDao = DAORegistry::getDAO('ViewsDAO');
70 
71  $submission = $submissionDao->getById($reviewAssignment->getSubmissionId());
72 
73  // Get the user groups for this stage
74  $userGroups = $userGroupDao->getUserGroupsByStage(
75  $submission->getContextId(),
76  $reviewAssignment->getStageId(),
77  true,
78  true
79  );
80  while ($userGroup = $userGroups->next()) {
81  $roleId = $userGroup->getRoleId();
82  if ($roleId != ROLE_ID_MANAGER && $roleId != ROLE_ID_SUB_EDITOR) continue;
83 
84  // Get the users assigned to this stage and user group
85  $stageUsers = $userStageAssignmentDao->getUsersBySubmissionAndStageId(
86  $reviewAssignment->getSubmissionId(),
87  $reviewAssignment->getStageId(),
88  $userGroup->getId()
89  );
90 
91  // mark as completed (viewed) if any of the manager/editor users viewed it.
92  while ($user = $stageUsers->next()) {
93  if ($viewsDao->getLastViewDate(
94  ASSOC_TYPE_REVIEW_RESPONSE,
95  $reviewAssignment->getId(), $user->getId()
96  )) {
97  // Some user has read the review.
98  return 'read';
99  }
100  }
101  }
102 
103  // Nobody has read the review.
104  return 'reviewReady';
105  }
106  }
107 
115  function getTemplateVarsFromRowColumn($row, $column) {
116  $element = $row->getData();
117  $columnId = $column->getId();
118  assert(is_a($element, 'DataObject') && !empty($columnId));
119  switch ($columnId) {
120  case 'name':
121  return array('label' => $element->getReviewerFullName());
122 
123  case 'considered':
124  return array('status' => $this->getCellState($row, $column));
125  }
126 
127  return parent::getTemplateVarsFromRowColumn($row, $column);
128  }
129 
136  function getCellActions($request, $row, $column, $position = GRID_ACTION_POSITION_DEFAULT) {
137  $reviewAssignment = $row->getData();
138  $actionArgs = array(
139  'submissionId' => $reviewAssignment->getSubmissionId(),
140  'reviewAssignmentId' => $reviewAssignment->getId(),
141  'stageId' => $reviewAssignment->getStageId()
142  );
143 
144  $router = $request->getRouter();
145  $action = false;
146  $submissionDao = Application::getSubmissionDAO();
147  $submission = $submissionDao->getById($reviewAssignment->getSubmissionId());
148  switch($this->getCellState($row, $column)) {
149  case 'linkReview':
150  $user = $request->getUser();
151  import('lib.pkp.controllers.review.linkAction.ReviewNotesLinkAction');
152  return array(new ReviewNotesLinkAction($request, $reviewAssignment, $submission, $user));
153  case 'overdue':
154  import('lib.pkp.controllers.api.task.SendReminderLinkAction');
155  return array(new SendReminderLinkAction($request, 'editor.review.reminder', $actionArgs));
156  case 'read':
157  import('lib.pkp.controllers.api.task.SendThankYouLinkAction');
158  return array(new SendThankYouLinkAction($request, 'editor.review.thankReviewer', $actionArgs));
159  case 'completed':
160  import('lib.pkp.controllers.review.linkAction.UnconsiderReviewLinkAction');
161  return array(new UnconsiderReviewLinkAction($request, $reviewAssignment, $submission));
162  case 'reviewReady':
163  $user = $request->getUser();
164  import('lib.pkp.controllers.review.linkAction.ReviewNotesLinkAction');
165  return array(new ReviewNotesLinkAction($request, $reviewAssignment, $submission, $user, 'new'));
166  case '':
167  case 'declined':
168  case 'unfinished':
169  // No actions for these cases
170  return array();
171  }
172  // Inconsistent state
173  assert(false);
174  }
175 
181  function _getHoverTitleText($state) {
182  switch ($state) {
183  case 'completed':
184  return __('common.complete');
185  case 'overdue':
186  return __('common.overdue');
187  case 'accepted':
188  return __('common.accepted');
189  case 'declined':
190  return __('common.declined');
191  case 'reminder':
192  return __('common.reminder');
193  case 'new':
194  return __('common.unread');
195  default:
196  return '';
197  }
198  }
199 }
200 
201 ?>
static & getDAO($name, $dbconn=null)
getCellActions($request, $row, $column, $position=GRID_ACTION_POSITION_DEFAULT)
Base class for a cell provider that can retrieve labels for reviewer grid rows.
static getSubmissionDAO()
An action to open up a modal to send a thank you email to users assigned to a review task...
An action to allow editors to unconsider a review.
Base class for a cell provider that can retrieve simple labels from DataObjects. If you need more com...
An action to open up a modal to send a reminder to users assigned to a task.
static getCurrentDate($ts=null)
Definition: Core.inc.php:95