Open Journal Systems  3.3.0
PKPApproveSubmissionNotificationManager.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  function getNotificationUrl($request, $notification) {
32  $dispatcher = Application::get()->getDispatcher();
33  $context = $request->getContext();
34  return $dispatcher->url($request, ROUTE_PAGE, $context->getPath(), 'workflow', 'access', $notification->getAssocId());
35  }
36 
40  function getStyleClass($notification) {
41  return NOTIFICATION_STYLE_CLASS_INFORMATION;
42  }
43 
47  function isVisibleToAllUsers($notificationType, $assocType, $assocId) {
48  return true;
49  }
50 
54  function updateNotification($request, $userIds, $assocType, $assocId) {
55  $submissionId = $assocId;
56  $submissionDao = DAORegistry::getDAO('SubmissionDAO'); /* @var $submissionDao SubmissionDAO */
57  $submission = $submissionDao->getById($submissionId);
58 
59  $notificationDao = DAORegistry::getDAO('NotificationDAO'); /* @var $notificationDao NotificationDAO */
60 
61  $notificationTypes = array(
62  NOTIFICATION_TYPE_APPROVE_SUBMISSION => false,
63  NOTIFICATION_TYPE_FORMAT_NEEDS_APPROVED_SUBMISSION => false,
64  NOTIFICATION_TYPE_VISIT_CATALOG => true,
65  );
66 
67  $isPublished = (boolean) $submission->getDatePublished();
68 
69  foreach ($notificationTypes as $type => $forPublicationState) {
70  $notificationFactory = $notificationDao->getByAssoc(
71  ASSOC_TYPE_SUBMISSION,
72  $submissionId,
73  null,
74  $type,
75  $submission->getData('contextId')
76  );
77  $notification = $notificationFactory->next();
78 
79  if (!$notification && $isPublished == $forPublicationState) {
80  // Create notification.
81  $this->createNotification(
82  $request,
83  null,
84  $type,
85  $submission->getData('contextId'),
86  ASSOC_TYPE_SUBMISSION,
87  $submissionId,
88  NOTIFICATION_LEVEL_NORMAL
89  );
90  } elseif ($notification && $isPublished != $forPublicationState) {
91  // Delete existing notification.
92  $notificationDao->deleteObject($notification);
93  }
94  }
95  }
96 
100  protected function multipleTypesUpdate() {
101  return true;
102  }
103 }
104 
105 
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
PKPApproveSubmissionNotificationManager
Approve submission notification type manager delegate.
Definition: PKPApproveSubmissionNotificationManager.inc.php:18
PKPApproveSubmissionNotificationManager\multipleTypesUpdate
multipleTypesUpdate()
Definition: PKPApproveSubmissionNotificationManager.inc.php:100
PKPApproveSubmissionNotificationManager\isVisibleToAllUsers
isVisibleToAllUsers($notificationType, $assocType, $assocId)
Definition: PKPApproveSubmissionNotificationManager.inc.php:47
PKPApproveSubmissionNotificationManager\getNotificationUrl
getNotificationUrl($request, $notification)
Definition: PKPApproveSubmissionNotificationManager.inc.php:31
PKPApproveSubmissionNotificationManager\__construct
__construct($notificationType)
Definition: PKPApproveSubmissionNotificationManager.inc.php:24
PKPApproveSubmissionNotificationManager\updateNotification
updateNotification($request, $userIds, $assocType, $assocId)
Definition: PKPApproveSubmissionNotificationManager.inc.php:54
PKPApproveSubmissionNotificationManager\getStyleClass
getStyleClass($notification)
Definition: PKPApproveSubmissionNotificationManager.inc.php:40
PKPApplication\get
static get()
Definition: PKPApplication.inc.php:235
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