Open Journal Systems  3.3.0
EditorAssignmentNotificationManager.inc.php
1 <?php
2 
16 import('lib.pkp.classes.notification.NotificationManagerDelegate');
17 
19 
24  function __construct($notificationType) {
25  parent::__construct($notificationType);
26  }
27 
31  public function getNotificationMessage($request, $notification) {
32  switch ($notification->getType()) {
33  case NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_SUBMISSION:
34  case NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_INTERNAL_REVIEW:
35  case NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_EXTERNAL_REVIEW:
36  return __('notification.type.editorAssignment');
37  case NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_EDITING:
38  return __('notification.type.editorAssignmentEditing');
39  case NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_PRODUCTION:
40  return __('notification.type.editorAssignmentProduction');
41  }
42  }
43 
47  public function getStyleClass($notification) {
48  return NOTIFICATION_STYLE_CLASS_WARNING;
49  }
50 
54  public function isVisibleToAllUsers($notificationType, $assocType, $assocId) {
55  return true;
56  }
57 
67  public function updateNotification($request, $userIds, $assocType, $assocId) {
68  $context = $request->getContext();
69  $notificationType = $this->getNotificationType();
70  $submissionId = $assocId;
71 
72  // Check for an existing NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_...
73  $notificationDao = DAORegistry::getDAO('NotificationDAO'); /* @var $notificationDao NotificationDAO */
74  $notificationFactory = $notificationDao->getByAssoc(
75  ASSOC_TYPE_SUBMISSION,
76  $submissionId,
77  null,
78  $notificationType,
79  $context->getId()
80  );
81 
82  // Check for editor stage assignment.
83  $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO'); /* @var $stageAssignmentDao StageAssignmentDAO */
84  $editorAssigned = $stageAssignmentDao->editorAssignedToStage($submissionId, $this->_getStageIdByNotificationType());
85 
86  // Decide if we have to create or delete a notification.
87  if ($editorAssigned && !$notificationFactory->wasEmpty()) {
88  // Delete the notification.
89  $notification = $notificationFactory->next();
90  $notificationDao->deleteObject($notification);
91  } else if (!$editorAssigned && $notificationFactory->wasEmpty()) {
92  // Create a notification.
93  $this->createNotification(
94  $request, null, $notificationType, $context->getId(), ASSOC_TYPE_SUBMISSION,
95  $submissionId, NOTIFICATION_LEVEL_TASK);
96  }
97  }
98 
99 
100  //
101  // Helper methods.
102  //
108  switch ($this->getNotificationType()) {
109  case NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_SUBMISSION:
110  return WORKFLOW_STAGE_ID_SUBMISSION;
111  case NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_INTERNAL_REVIEW:
112  return WORKFLOW_STAGE_ID_INTERNAL_REVIEW;
113  case NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_EXTERNAL_REVIEW:
114  return WORKFLOW_STAGE_ID_EXTERNAL_REVIEW;
115  case NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_EDITING:
116  return WORKFLOW_STAGE_ID_EDITING;
117  case NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_PRODUCTION:
118  return WORKFLOW_STAGE_ID_PRODUCTION;
119  default:
120  return null;
121  }
122  }
123 }
124 
125 
DAORegistry\getDAO
static & getDAO($name, $dbconn=null)
Definition: DAORegistry.inc.php:57
NotificationManagerDelegate
Abstract class to support notification manager delegates that provide default implementation to the i...
Definition: NotificationManagerDelegate.inc.php:21
NotificationManagerDelegate\getNotificationType
getNotificationType()
Definition: NotificationManagerDelegate.inc.php:41
EditorAssignmentNotificationManager\getStyleClass
getStyleClass($notification)
Definition: EditorAssignmentNotificationManager.inc.php:47
EditorAssignmentNotificationManager\updateNotification
updateNotification($request, $userIds, $assocType, $assocId)
Definition: EditorAssignmentNotificationManager.inc.php:67
EditorAssignmentNotificationManager
Editor assignment notification types manager delegate.
Definition: EditorAssignmentNotificationManager.inc.php:18
EditorAssignmentNotificationManager\_getStageIdByNotificationType
_getStageIdByNotificationType()
Definition: EditorAssignmentNotificationManager.inc.php:107
NotificationManagerDelegate\createNotification
createNotification($request, $userId=null, $notificationType, $contextId=null, $assocType=null, $assocId=null, $level=NOTIFICATION_LEVEL_NORMAL, $params=null, $suppressEmail=false, callable $mailConfigurator=null)
Definition: NotificationManagerDelegate.inc.php:62
EditorAssignmentNotificationManager\getNotificationMessage
getNotificationMessage($request, $notification)
Definition: EditorAssignmentNotificationManager.inc.php:31
EditorAssignmentNotificationManager\__construct
__construct($notificationType)
Definition: EditorAssignmentNotificationManager.inc.php:24
EditorAssignmentNotificationManager\isVisibleToAllUsers
isVisibleToAllUsers($notificationType, $assocType, $assocId)
Definition: EditorAssignmentNotificationManager.inc.php:54