Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
AuditorRequestNotificationManager.inc.php
1 <?php
2 
16 import('lib.pkp.classes.notification.NotificationManagerDelegate');
17 
19 
24  function AuditorRequestNotificationManagerDelegate($notificationType) {
25  parent::NotificationManagerDelegate($notificationType);
26  }
27 
31  function getNotificationMessage($request, $notification) {
32  $signoffDao = DAORegistry::getDAO('SignoffDAO'); /* @var $signoffDao SignoffDAO */
33  $signoff = $signoffDao->getById($notification->getAssocId());
34  assert($signoff->getAssocType() == ASSOC_TYPE_SUBMISSION_FILE);
35 
36  $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO');
37  $submissionFile = $submissionFileDao->getLatestRevision($signoff->getAssocId());
38  return __('notification.type.auditorRequest', array('file' => $submissionFile->getLocalizedName()));
39  }
40 
44  function getStyleClass($notification) {
45  return NOTIFICATION_STYLE_CLASS_WARNING;
46  }
47 
51  public function updateNotification($request, $userIds, $assocType, $assocId) {
52  $userId = !is_null($userIds) ? current($userIds) : null;
53 
54  // Check for an existing notification.
55  $notificationDao = DAORegistry::getDAO('NotificationDAO');
56  $notificationFactory = $notificationDao->getByAssoc(
57  ASSOC_TYPE_SIGNOFF,
58  $assocId,
59  $userId,
60  NOTIFICATION_TYPE_AUDITOR_REQUEST
61  );
62 
63  // Check for the complete state of the signoff.
64  $signoffDao = DAORegistry::getDAO('SignoffDAO'); /* @var $signoffDao SignoffDAO */
65  $signoff = $signoffDao->getById($assocId);
66 
67  $signoffCompleted = false;
68  $removed = false;
69  if (!$signoff) {
70  $removed = true;
71  } else {
72  if (!is_null($signoff->getDateCompleted())) {
73  $signoffCompleted = true;
74  }
75  }
76 
77  // Decide if we have to create or delete a notification.
78  if (($signoffCompleted || $removed) && !$notificationFactory->wasEmpty()) {
79  $notification = $notificationFactory->next();
80  $notificationDao->deleteObject($notification);
81  } else if (!$signoffCompleted && $notificationFactory->wasEmpty()) {
82  $context = $request->getContext();
83  $this->createNotification(
84  $request,
85  $userId,
86  NOTIFICATION_TYPE_AUDITOR_REQUEST,
87  $context->getId(),
88  ASSOC_TYPE_SIGNOFF,
89  $assocId,
90  NOTIFICATION_LEVEL_TASK
91  );
92  }
93  }
94 }
95 
96 ?>
static & getDAO($name, $dbconn=null)
updateNotification($request, $userIds, $assocType, $assocId)
Abstract class to support notification manager delegates that provide default implementation to the i...
Auditor request notification types manager delegate.