17 import(
'lib.pkp.classes.notification.PKPNotificationOperationManager');
18 import(
'lib.pkp.classes.workflow.WorkflowStageDAO');
27 $url = parent::getNotificationUrl($request, $notification);
30 $context = $contextDao->getById($notification->getContextId());
32 switch ($notification->getType()) {
33 case NOTIFICATION_TYPE_EDITOR_ASSIGN:
34 assert($notification->getAssocType() == ASSOC_TYPE_SUBMISSION && is_numeric($notification->getAssocId()));
35 return $dispatcher->url($request, ROUTE_PAGE, $context->getPath(),
'workflow',
'access', $notification->getAssocId());
36 case NOTIFICATION_TYPE_COPYEDIT_ASSIGNMENT:
37 case NOTIFICATION_TYPE_LAYOUT_ASSIGNMENT:
38 case NOTIFICATION_TYPE_INDEX_ASSIGNMENT:
39 assert($notification->getAssocType() == ASSOC_TYPE_SUBMISSION && is_numeric($notification->getAssocId()));
40 return $dispatcher->url($request, ROUTE_PAGE, $context->getPath(),
'workflow',
'access', $notification->getAssocId());
41 case NOTIFICATION_TYPE_REVIEWER_COMMENT:
42 assert($notification->getAssocType() == ASSOC_TYPE_REVIEW_ASSIGNMENT && is_numeric($notification->getAssocId()));
44 $reviewAssignment = $reviewAssignmentDao->getById($notification->getAssocId());
46 $operation = $reviewAssignment->getStageId()==WORKFLOW_STAGE_ID_INTERNAL_REVIEW?WORKFLOW_STAGE_PATH_INTERNAL_REVIEW:WORKFLOW_STAGE_PATH_EXTERNAL_REVIEW;
47 return $dispatcher->url($request, ROUTE_PAGE, $context->getPath(),
'workflow', $operation, $reviewAssignment->getSubmissionId());
48 case NOTIFICATION_TYPE_REVIEW_ASSIGNMENT:
49 case NOTIFICATION_TYPE_REVIEW_ASSIGNMENT_UPDATED:
51 $reviewAssignment = $reviewAssignmentDao->getById($notification->getAssocId());
52 return $dispatcher->url($request, ROUTE_PAGE, $context->getPath(),
'reviewer',
'submission', $reviewAssignment->getSubmissionId());
53 case NOTIFICATION_TYPE_NEW_ANNOUNCEMENT:
54 assert($notification->getAssocType() == ASSOC_TYPE_ANNOUNCEMENT);
56 $announcement = $announcementDao->getById($notification->getAssocId());
57 $context = $contextDao->getById($announcement->getAssocId());
58 return $dispatcher->url($request, ROUTE_PAGE, $context->getPath(),
'announcement',
'view', array($notification->getAssocId()));
59 case NOTIFICATION_TYPE_CONFIGURE_PAYMENT_METHOD:
60 return __(
'notification.type.configurePaymentMethod');
61 case NOTIFICATION_TYPE_PAYMENT_REQUIRED:
62 $context = $contextDao->getById($notification->getContextId());
64 assert($notification->getAssocType() == ASSOC_TYPE_QUEUED_PAYMENT);
66 $queuedPayment = $queuedPaymentDao->getById($notification->getAssocId());
67 $context = $contextDao->getById($queuedPayment->getContextId());
68 return $dispatcher->url($request, ROUTE_PAGE, $context->getPath(),
'payment',
'pay', array($queuedPayment->getId()));
71 $notification->getType(),
72 $notification->getAssocType(),
73 $notification->getAssocId(),
75 array($request, $notification)
78 if ($delegateResult) $url = $delegateResult;
90 $message = parent::getNotificationMessage($request, $notification);
91 $type = $notification->getType();
96 case NOTIFICATION_TYPE_SUCCESS:
97 case NOTIFICATION_TYPE_ERROR:
98 case NOTIFICATION_TYPE_WARNING:
99 if (!is_null($this->getNotificationSettings($notification->getId()))) {
100 $notificationSettings = $this->getNotificationSettings($notification->getId());
101 return $notificationSettings[
'contents'];
103 return __(
'common.changesSaved');
105 case NOTIFICATION_TYPE_FORM_ERROR:
106 case NOTIFICATION_TYPE_ERROR:
107 $notificationSettings = $this->getNotificationSettings($notification->getId());
108 assert(!is_null($notificationSettings[
'contents']));
109 return $notificationSettings[
'contents'];
110 case NOTIFICATION_TYPE_PLUGIN_ENABLED:
111 return $this->_getTranslatedKeyWithParameters(
'common.pluginEnabled', $notification->getId());
112 case NOTIFICATION_TYPE_PLUGIN_DISABLED:
113 return $this->_getTranslatedKeyWithParameters(
'common.pluginDisabled', $notification->getId());
114 case NOTIFICATION_TYPE_REVIEWER_COMMENT:
115 assert($notification->getAssocType() == ASSOC_TYPE_REVIEW_ASSIGNMENT && is_numeric($notification->getAssocId()));
117 $reviewAssignment = $reviewAssignmentDao->getById($notification->getAssocId());
118 $submission = $submissionDao->getById($reviewAssignment->getSubmissionId());
119 return __(
'notification.type.reviewerComment', array(
'title' => $submission->getLocalizedTitle()));
120 case NOTIFICATION_TYPE_EDITOR_ASSIGN:
121 assert($notification->getAssocType() == ASSOC_TYPE_SUBMISSION && is_numeric($notification->getAssocId()));
122 $submission = $submissionDao->getById($notification->getAssocId());
123 return __(
'notification.type.editorAssign', array(
'title' => $submission->getLocalizedTitle()));
124 case NOTIFICATION_TYPE_COPYEDIT_ASSIGNMENT:
125 assert($notification->getAssocType() == ASSOC_TYPE_SUBMISSION && is_numeric($notification->getAssocId()));
126 $submission = $submissionDao->getById($notification->getAssocId());
127 return __(
'notification.type.copyeditorRequest', array(
'title' => $submission->getLocalizedTitle()));
128 case NOTIFICATION_TYPE_LAYOUT_ASSIGNMENT:
129 assert($notification->getAssocType() == ASSOC_TYPE_SUBMISSION && is_numeric($notification->getAssocId()));
130 $submission = $submissionDao->getById($notification->getAssocId());
131 return __(
'notification.type.layouteditorRequest', array(
'title' => $submission->getLocalizedTitle()));
132 case NOTIFICATION_TYPE_INDEX_ASSIGNMENT:
133 assert($notification->getAssocType() == ASSOC_TYPE_SUBMISSION && is_numeric($notification->getAssocId()));
134 $submission = $submissionDao->getById($notification->getAssocId());
135 return __(
'notification.type.indexRequest', array(
'title' => $submission->getLocalizedTitle()));
136 case NOTIFICATION_TYPE_REVIEW_ASSIGNMENT:
137 return __(
'notification.type.reviewAssignment');
138 case NOTIFICATION_TYPE_REVIEW_ASSIGNMENT_UPDATED:
139 return __(
'notification.type.reviewAssignmentUpdated');
140 case NOTIFICATION_TYPE_REVIEW_ROUND_STATUS:
141 assert($notification->getAssocType() == ASSOC_TYPE_REVIEW_ROUND && is_numeric($notification->getAssocId()));
143 $reviewRound = $reviewRoundDao->getById($notification->getAssocId());
147 $user = $request->getUser();
148 $stageAssignments = $stageAssignmentDao->getBySubmissionAndRoleId($reviewRound->getSubmissionId(), ROLE_ID_AUTHOR,
null, $user->getId());
149 $isAuthor = $stageAssignments->getCount()>0;
150 $stageAssignments->close();
151 return __($reviewRound->getStatusKey($isAuthor));
152 case NOTIFICATION_TYPE_PAYMENT_REQUIRED:
153 return __(
'payment.type.publication.required');
154 case NOTIFICATION_TYPE_EDITORIAL_REPORT:
155 $notificationSettings = $this->getNotificationSettings($notification->getId());
156 return $notificationSettings[
'contents'];
159 $notification->getType(),
160 $notification->getAssocType(),
161 $notification->getAssocId(),
163 array($request, $notification)
166 if ($delegateResult) $message = $delegateResult;
182 $content = parent::getNotificationContents($request, $notification);
183 $type = $notification->getType();
184 assert(isset($type));
187 case NOTIFICATION_TYPE_FORM_ERROR:
189 $templateMgr->assign(
'errors', $content);
190 return $templateMgr->fetch(
'controllers/notification/formErrorNotificationContent.tpl');
191 case NOTIFICATION_TYPE_ERROR:
192 if (is_array($content)) {
193 $templateMgr->assign(
'errors', $content);
194 return $templateMgr->fetch(
'controllers/notification/errorNotificationContent.tpl');
200 $notification->getType(),
201 $notification->getAssocType(),
202 $notification->getAssocId(),
204 array($request, $notification)
207 if ($delegateResult) $content = $delegateResult;
216 $title = parent::getNotificationTitle($notification);
217 $type = $notification->getType();
218 assert(isset($type));
221 case NOTIFICATION_TYPE_REVIEW_ROUND_STATUS:
223 $reviewRound = $reviewRoundDao->getById($notification->getAssocId());
224 return __(
'notification.type.roundStatusTitle', array(
'round' => $reviewRound->getRound()));
225 case NOTIFICATION_TYPE_FORM_ERROR:
226 return __(
'form.errorsOccurred');
229 $notification->getType(),
230 $notification->getAssocType(),
231 $notification->getAssocId(),
236 if ($delegateResult) $title = $delegateResult;
245 $styleClass = parent::getStyleClass($notification);
246 switch ($notification->getType()) {
247 case NOTIFICATION_TYPE_SUCCESS:
return NOTIFICATION_STYLE_CLASS_SUCCESS;
248 case NOTIFICATION_TYPE_WARNING:
return NOTIFICATION_STYLE_CLASS_WARNING;
249 case NOTIFICATION_TYPE_ERROR:
return NOTIFICATION_STYLE_CLASS_ERROR;
250 case NOTIFICATION_TYPE_INFORMATION:
return NOTIFICATION_STYLE_CLASS_INFORMATION;
251 case NOTIFICATION_TYPE_FORBIDDEN:
return NOTIFICATION_STYLE_CLASS_FORBIDDEN;
252 case NOTIFICATION_TYPE_HELP:
return NOTIFICATION_STYLE_CLASS_HELP;
253 case NOTIFICATION_TYPE_FORM_ERROR:
return NOTIFICATION_STYLE_CLASS_FORM_ERROR;
254 case NOTIFICATION_TYPE_REVIEW_ROUND_STATUS:
return NOTIFICATION_STYLE_CLASS_INFORMATION;
257 $notification->getType(),
258 $notification->getAssocType(),
259 $notification->getAssocId(),
263 if ($delegateResult) $styleClass = $delegateResult;
272 $iconClass = parent::getIconClass($notification);
273 switch ($notification->getType()) {
274 case NOTIFICATION_TYPE_SUCCESS:
return 'notifyIconSuccess';
275 case NOTIFICATION_TYPE_WARNING:
return 'notifyIconWarning';
276 case NOTIFICATION_TYPE_ERROR:
return 'notifyIconError';
277 case NOTIFICATION_TYPE_INFORMATION:
return 'notifyIconInfo';
278 case NOTIFICATION_TYPE_FORBIDDEN:
return 'notifyIconForbidden';
279 case NOTIFICATION_TYPE_HELP:
return 'notifyIconHelp';
282 $notification->getType(),
283 $notification->getAssocType(),
284 $notification->getAssocId(),
288 if ($delegateResult) $iconClass = $delegateResult;
297 $isVisible = parent::isVisibleToAllUsers($notificationType, $assocType, $assocId);
298 switch ($notificationType) {
299 case NOTIFICATION_TYPE_REVIEW_ROUND_STATUS:
300 case NOTIFICATION_TYPE_APPROVE_SUBMISSION:
301 case NOTIFICATION_TYPE_VISIT_CATALOG:
302 case NOTIFICATION_TYPE_CONFIGURE_PAYMENT_METHOD:
305 case NOTIFICATION_TYPE_PAYMENT_REQUIRED:
314 array($notificationType, $assocType, $assocId)
316 if (!is_null($delegateResult)) $isVisible = $delegateResult;
335 final public function updateNotification($request, $notificationTypes, $userIds, $assocType, $assocId) {
337 foreach ($notificationTypes as $type) {
338 $managerDelegate = $this->
getMgrDelegate($type, $assocType, $assocId);
339 if (!is_null($managerDelegate) && is_a($managerDelegate,
'NotificationManagerDelegate')) {
340 $returner = $managerDelegate->updateNotification($request, $userIds, $assocType, $assocId);
361 switch ($notificationType) {
362 case NOTIFICATION_TYPE_SUBMISSION_SUBMITTED:
363 case NOTIFICATION_TYPE_METADATA_MODIFIED:
364 case NOTIFICATION_TYPE_SUBMISSION_NEW_VERSION:
365 case NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_REQUIRED:
366 assert($assocType == ASSOC_TYPE_SUBMISSION && is_numeric($assocId));
367 import(
'lib.pkp.classes.notification.managerDelegate.SubmissionNotificationManager');
369 case NOTIFICATION_TYPE_NEW_QUERY:
370 case NOTIFICATION_TYPE_QUERY_ACTIVITY:
371 import(
'lib.pkp.classes.notification.managerDelegate.QueryNotificationManager');
373 case NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_SUBMISSION:
374 case NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_EXTERNAL_REVIEW:
375 case NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_EDITING:
376 case NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_PRODUCTION:
377 assert($assocType == ASSOC_TYPE_SUBMISSION && is_numeric($assocId));
378 import(
'lib.pkp.classes.notification.managerDelegate.EditorAssignmentNotificationManager');
380 case NOTIFICATION_TYPE_EDITOR_DECISION_ACCEPT:
381 case NOTIFICATION_TYPE_EDITOR_DECISION_EXTERNAL_REVIEW:
382 case NOTIFICATION_TYPE_EDITOR_DECISION_PENDING_REVISIONS:
383 case NOTIFICATION_TYPE_EDITOR_DECISION_RESUBMIT:
384 case NOTIFICATION_TYPE_EDITOR_DECISION_NEW_ROUND:
385 case NOTIFICATION_TYPE_EDITOR_DECISION_DECLINE:
386 case NOTIFICATION_TYPE_EDITOR_DECISION_SEND_TO_PRODUCTION:
387 assert($assocType == ASSOC_TYPE_SUBMISSION && is_numeric($assocId));
388 import(
'lib.pkp.classes.notification.managerDelegate.EditorDecisionNotificationManager');
390 case NOTIFICATION_TYPE_PENDING_INTERNAL_REVISIONS:
391 case NOTIFICATION_TYPE_PENDING_EXTERNAL_REVISIONS:
392 assert($assocType == ASSOC_TYPE_SUBMISSION && is_numeric($assocId));
393 import(
'lib.pkp.classes.notification.managerDelegate.PendingRevisionsNotificationManager');
395 case NOTIFICATION_TYPE_ASSIGN_COPYEDITOR:
396 case NOTIFICATION_TYPE_AWAITING_COPYEDITS:
397 case NOTIFICATION_TYPE_ASSIGN_PRODUCTIONUSER:
398 case NOTIFICATION_TYPE_AWAITING_REPRESENTATIONS:
399 assert($assocType == ASSOC_TYPE_SUBMISSION && is_numeric($assocId));
400 import(
'lib.pkp.classes.notification.managerDelegate.PKPEditingProductionStatusNotificationManager');
402 case NOTIFICATION_TYPE_EDITORIAL_REPORT:
403 import(
'lib.pkp.classes.notification.managerDelegate.EditorialReportNotificationManager');
416 protected function getByDelegate($notificationType, $assocType, $assocId, $operationName, $parameters) {
417 $delegate = $this->
getMgrDelegate($notificationType, $assocType, $assocId);
418 if (is_a($delegate,
'NotificationManagerDelegate')) {
419 return call_user_func_array(array($delegate, $operationName), $parameters);
434 private function getNotificationSettings($notificationId) {
436 $notificationSettings = $notificationSettingsDao->getNotificationSettings($notificationId);
437 if (empty($notificationSettings)) {
440 return $notificationSettings;
450 private function _getTranslatedKeyWithParameters($key, $notificationId) {
451 $params = $this->getNotificationSettings($notificationId);