Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
AllReviewsInNotificationManager.inc.php
1 <?php
2 
16 import('lib.pkp.classes.notification.NotificationManagerDelegate');
17 
19 
24  function AllReviewsInNotificationManager($notificationType) {
25  parent::NotificationManagerDelegate($notificationType);
26  }
27 
32  public function getStyleClass($notification) {
33  return NOTIFICATION_STYLE_CLASS_WARNING;
34  }
35 
43  public function updateNotification($request, $userIds, $assocType, $assocId) {
44  $reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO');
45  $reviewRound = $reviewRoundDao->getById($assocId);
46 
47  $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO');
48  $stageAssignments = $stageAssignmentDao->getEditorsAssignedToStage($reviewRound->getSubmissionId(), $reviewRound->getStageId());
49 
50  $notificationDao = DAORegistry::getDAO('NotificationDAO'); /* @var $notificationDao NotificationDAO */
51  $context = $request->getContext();
52  $contextId = $context->getId();
53 
54  foreach ($stageAssignments as $stageAssignment) {
55  $userId = $stageAssignment->getUserId();
56 
57  // Get any existing notification.
58  $notificationFactory = $notificationDao->getByAssoc(
59  ASSOC_TYPE_REVIEW_ROUND,
60  $reviewRound->getId(), $userId,
61  NOTIFICATION_TYPE_ALL_REVIEWS_IN,
62  $contextId
63  );
64 
65  $currentStatus = $reviewRound->getStatus();
66  if (in_array($currentStatus, $reviewRoundDao->getEditorDecisionRoundStatus()) ||
67  in_array($currentStatus, array(REVIEW_ROUND_STATUS_PENDING_REVIEWERS, REVIEW_ROUND_STATUS_PENDING_REVIEWS))) {
68  // Editor has taken a decision in round or there are pending
69  // reviews or no reviews. Delete any existing notification.
70  if (!$notificationFactory->wasEmpty()) {
71  $notification = $notificationFactory->next();
72  $notificationDao->deleteObject($notification);
73  }
74  } else {
75  // There is no currently decision in round. Also there is reviews,
76  // but no pending reviews. Insert notification, if not already present.
77  if ($notificationFactory->wasEmpty()) {
78  $this->createNotification($request, $userId, NOTIFICATION_TYPE_ALL_REVIEWS_IN, $contextId,
79  ASSOC_TYPE_REVIEW_ROUND, $reviewRound->getId(), NOTIFICATION_LEVEL_TASK);
80  }
81  }
82  }
83  }
84 }
85 
86 ?>
static & getDAO($name, $dbconn=null)
updateNotification($request, $userIds, $assocType, $assocId)
All reviews in notification types manager delegate.
Abstract class to support notification manager delegates that provide default implementation to the i...