Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
AllRevisionsInNotificationManager.inc.php
1 <?php
2 
16 import('lib.pkp.classes.notification.managerDelegate.RevisionsNotificationManager');
17 
19 
24  function AllRevisionsInNotificationManager($notificationType) {
25  parent::RevisionsNotificationManager($notificationType);
26  }
27 
31  public function updateNotification($request, $userIds, $assocType, $assocId) {
32  $reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO');
33  $reviewRound = $reviewRoundDao->getById($assocId);
34  $submissionId = $reviewRound->getSubmissionId();
35 
36  $pendingRevisionDecision = $this->findValidPendingRevisionsDecision($submissionId, $reviewRound->getStageId());
37  $removeNotifications = false;
38 
39  if ($pendingRevisionDecision) {
40  if ($this->responseExists($pendingRevisionDecision, $submissionId)) {
41  // Some user already uploaded a revision.
42  $this->_addAllRevisionsIn($request, $reviewRound);
43  } else {
44  // No revision response, remove notification.
45  $removeNotifications = true;
46  }
47  } else {
48  $removeNotifications = true;
49  }
50 
51  if ($removeNotifications) {
52  $this->_removeAllRevisionsIn($request, $reviewRound);
53  }
54  }
55 
56 
57  //
58  // Private helper methods.
59  //
66  private function _addAllRevisionsIn($request, $reviewRound) {
67  $context = $request->getContext();
68  $contextId = $context->getId();
69 
70  $this->_removeAllRevisionsIn($request, $reviewRound);
71 
72  $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO');
73  $stageAssignments = $stageAssignmentDao->getEditorsAssignedToStage($reviewRound->getSubmissionId(), $reviewRound->getStageId());
74  foreach ($stageAssignments as $stageAssignment) {
75  $userId = $stageAssignment->getUserId();
76  $this->createNotification($request, $userId, NOTIFICATION_TYPE_ALL_REVISIONS_IN, $contextId,
77  ASSOC_TYPE_REVIEW_ROUND, $reviewRound->getId(), NOTIFICATION_LEVEL_TASK);
78  }
79  }
80 
87  private function _removeAllRevisionsIn($request, $reviewRound) {
88  $context = $request->getContext();
89  $contextId = $context->getId();
90  $notificationDao = DAORegistry::getDAO('NotificationDAO'); /* @var $notificationDao NotificationDAO */
91 
92  $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO');
93  $stageAssignments = $stageAssignmentDao->getEditorsAssignedToStage($reviewRound->getSubmissionId(), $reviewRound->getStageId());
94  foreach ($stageAssignments as $stageAssignment) {
95  $userId = $stageAssignment->getUserId();
96 
97  // Get any existing notification.
98  $notificationFactory = $notificationDao->getByAssoc(
99  ASSOC_TYPE_REVIEW_ROUND,
100  $reviewRound->getId(), $userId,
101  NOTIFICATION_TYPE_ALL_REVISIONS_IN,
102  $contextId
103  );
104 
105  if (!$notificationFactory->wasEmpty()) {
106  $notification = $notificationFactory->next();
107  $notificationDao->deleteObject($notification);
108  }
109  }
110  }
111 }
112 
113 ?>
static & getDAO($name, $dbconn=null)
All revisions in notification types manager delegate.
updateNotification($request, $userIds, $assocType, $assocId)
findValidPendingRevisionsDecision($submissionId, $expectedStageId)
Base class for revision notification types manager delegate.