Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
ApproveSubmissionNotificationManager.inc.php
1 <?php
2 
16 import('lib.pkp.classes.notification.NotificationManagerDelegate');
17 
19 
24  function ApproveSubmissionNotificationManager($notificationType) {
25  parent::NotificationManagerDelegate($notificationType);
26  }
27 
31  public function getStyleClass($notification) {
32  return NOTIFICATION_STYLE_CLASS_WARNING;
33  }
34 
38  public function updateNotification($request, $userIds, $assocType, $assocId) {
39  $submissionId = $assocId;
40  $submissionDao = Application::getSubmissionDAO();
41  $submission = $submissionDao->getById($submissionId);
42 
43  $context = $request->getContext();
44  $contextId = $context->getId();
45  $notificationDao = DAORegistry::getDAO('NotificationDAO');
46 
47  $notificationTypes = array(
48  NOTIFICATION_TYPE_APPROVE_SUBMISSION => false,
49  NOTIFICATION_TYPE_FORMAT_NEEDS_APPROVED_SUBMISSION => false,
50  NOTIFICATION_TYPE_VISIT_CATALOG => true,
51  );
52 
53  $isPublished = (boolean) $submission->getDatePublished();
54 
55  foreach ($notificationTypes as $type => $forPublicationState) {
56  $notificationFactory = $notificationDao->getByAssoc(
57  ASSOC_TYPE_SUBMISSION,
58  $submissionId,
59  null,
60  $type,
61  $contextId
62  );
63  $notification = $notificationFactory->next();
64 
65  if (!$notification && $isPublished == $forPublicationState) {
66  // Create notification.
67  $this->createNotification(
68  $request,
69  null,
70  $type,
71  $contextId,
72  ASSOC_TYPE_SUBMISSION,
73  $submissionId,
74  NOTIFICATION_LEVEL_NORMAL
75  );
76  } elseif ($notification && $isPublished != $forPublicationState) {
77  // Delete existing notification.
78  $notificationDao->deleteObject($notification);
79  }
80  }
81  }
82 }
83 
84 ?>
static & getDAO($name, $dbconn=null)
static getSubmissionDAO()
Abstract class to support notification manager delegates that provide default implementation to the i...
Approve submission notification type manager delegate.
updateNotification($request, $userIds, $assocType, $assocId)