Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
EditorDecisionNotificationManager.inc.php
1 <?php
2 
16 import('lib.pkp.classes.notification.NotificationManagerDelegate');
17 
19 
24  function EditorDecisionNotificationManager($notificationType) {
25  parent::NotificationManagerDelegate($notificationType);
26  }
27 
31  function getNotificationMessage($request, $notification) {
32  switch ($notification->getType()) {
33  case NOTIFICATION_TYPE_EDITOR_DECISION_INTERNAL_REVIEW:
34  return __('notification.type.editorDecisionInternalReview');
35  case NOTIFICATION_TYPE_EDITOR_DECISION_ACCEPT:
36  return __('notification.type.editorDecisionAccept');
37  case NOTIFICATION_TYPE_EDITOR_DECISION_EXTERNAL_REVIEW:
38  return __('notification.type.editorDecisionExternalReview');
39  case NOTIFICATION_TYPE_EDITOR_DECISION_PENDING_REVISIONS:
40  return __('notification.type.editorDecisionPendingRevisions');
41  case NOTIFICATION_TYPE_EDITOR_DECISION_RESUBMIT:
42  return __('notification.type.editorDecisionResubmit');
43  case NOTIFICATION_TYPE_EDITOR_DECISION_DECLINE:
44  return __('notification.type.editorDecisionDecline');
45  case NOTIFICATION_TYPE_EDITOR_DECISION_SEND_TO_PRODUCTION:
46  return __('notification.type.editorDecisionSendToProduction');
47  default:
48  return null;
49  }
50  }
51 
55  function getStyleClass($notification) {
56  return NOTIFICATION_STYLE_CLASS_INFORMATION;
57  }
58 
62  function getNotificationTitle($notification) {
63  return __('notification.type.editorDecisionTitle');
64  }
65 
69  public function updateNotification($request, $userIds, $assocType, $assocId) {
70  $context = $request->getContext();
71 
72  // Get the submitter id.
73  $userId = current($userIds);
74 
75  // Remove any existing editor decision notifications.
76  $notificationDao = DAORegistry::getDAO('NotificationDAO');
77  $notificationFactory = $notificationDao->getByAssoc(
78  ASSOC_TYPE_SUBMISSION,
79  $assocId,
80  $userId,
81  null,
82  $context->getId()
83  );
84 
85  $editorDecisionNotificationTypes = $this->_getAllEditorDecisionNotificationTypes();
86  while(!$notificationFactory->eof()) {
87  $notification = $notificationFactory->next();
88  if (in_array($notification->getType(), $editorDecisionNotificationTypes)) {
89  $notificationDao->deleteObject($notification);
90  }
91  }
92 
93  // Create the notification.
94  $this->createNotification(
95  $request,
96  $userId,
97  $this->getNotificationType(),
98  $context->getId(),
99  ASSOC_TYPE_SUBMISSION,
100  $assocId,
102  );
103  }
104 
108  public function getNotificationUrl($request, $notification) {
109  switch ($notification->getType()) {
110  case NOTIFICATION_TYPE_EDITOR_DECISION_PENDING_REVISIONS:
111  $submissionDao = Application::getSubmissionDAO();
112  $submission = $submissionDao->getById($notification->getAssocId());
113  import('lib.pkp.controllers.grid.submissions.SubmissionsListGridCellProvider');
114  list($page, $operation) = SubmissionsListGridCellProvider::getPageAndOperationByUserRoles($request, $submission);
115  $router = $request->getRouter();
116  $dispatcher = $router->getDispatcher();
117  $contextDao = Application::getContextDAO();
118  $context = $contextDao->getById($submission->getContextId());
119  // this will probably be authorDashboard/submission, but the possibility exists that an editor is
120  // revising a submission without being an author in the stage assignments.
121  return $dispatcher->url($request, ROUTE_PAGE, $context->getPath(), $page, $operation, $submission->getId());
122 
123  default:
124  return '';
125  }
126  }
127 
128  //
129  // Private helper methods
130  //
136  return array(
137  NOTIFICATION_TYPE_EDITOR_DECISION_INTERNAL_REVIEW,
138  NOTIFICATION_TYPE_EDITOR_DECISION_ACCEPT,
139  NOTIFICATION_TYPE_EDITOR_DECISION_EXTERNAL_REVIEW,
140  NOTIFICATION_TYPE_EDITOR_DECISION_PENDING_REVISIONS,
141  NOTIFICATION_TYPE_EDITOR_DECISION_RESUBMIT,
142  NOTIFICATION_TYPE_EDITOR_DECISION_DECLINE,
143  NOTIFICATION_TYPE_EDITOR_DECISION_SEND_TO_PRODUCTION
144  );
145  }
146 
152  function _getNotificationTaskLevel($type) {
153  switch ($type) {
154  case NOTIFICATION_TYPE_EDITOR_DECISION_PENDING_REVISIONS:
155  return NOTIFICATION_LEVEL_TASK;
156  default:
157  return NOTIFICATION_LEVEL_NORMAL;
158  }
159  }
160 }
161 
162 ?>
static & getDAO($name, $dbconn=null)
updateNotification($request, $userIds, $assocType, $assocId)
Editor decision notification types manager delegate.
static getSubmissionDAO()
static getPageAndOperationByUserRoles($request, $submission, $userId=null)
Abstract class to support notification manager delegates that provide default implementation to the i...
static getContextDAO()