Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
RevisionsNotificationManager.inc.php
1 <?php
2 
16 import('lib.pkp.classes.notification.NotificationManagerDelegate');
17 import('lib.pkp.classes.submission.SubmissionFile'); // Bring file stage constants.
18 import('classes.workflow.EditorDecisionActionsManager'); // Access decision actions constants.
19 
21 
26  function RevisionsNotificationManager($notificationType) {
27  parent::NotificationManagerDelegate($notificationType);
28  }
29 
33  public function getStyleClass($notification) {
34  return NOTIFICATION_STYLE_CLASS_WARNING;
35  }
36 
37 
38  //
39  // Protected helper methods.
40  //
49  protected function findValidPendingRevisionsDecision($submissionId, $expectedStageId) {
50  $editDecisionDao = DAORegistry::getDAO('EditDecisionDAO');
51  $editorDecisions = $editDecisionDao->getEditorDecisions($submissionId);
52  $workingDecisions = array_reverse($editorDecisions);
53  $postReviewDecisions = array(SUBMISSION_EDITOR_DECISION_SEND_TO_PRODUCTION);
54  $pendingRevisionDecision = null;
55 
56  foreach ($workingDecisions as $decision) {
57  if (in_array($decision['decision'], $postReviewDecisions)) {
58  // Decisions at later stages do not override the pending revisions one.
59  continue;
60  } elseif ($decision['decision'] == SUBMISSION_EDITOR_DECISION_PENDING_REVISIONS) {
61  if ($decision['stageId'] == $expectedStageId) {
62  $pendingRevisionDecision = $decision;
63  // Only the last pending revisions decision is relevant.
64  break;
65  } else {
66  // Both internal and external pending revisions decisions are
67  // valid at the same time. Continue to search.
68  continue;
69  }
70 
71  } else {
72  break;
73  }
74  }
75 
76  return $pendingRevisionDecision;
77  }
78 
86  protected function responseExists($decision, $submissionId) {
87  $stageId = $decision['stageId'];
88  $round = $decision['round'];
89  $sentRevisions = false;
90 
91  $reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO');
92  $reviewRound = $reviewRoundDao->getReviewRound($submissionId, $stageId, $round);
93 
94  $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO');
95  $submissionFiles = $submissionFileDao->getRevisionsByReviewRound($reviewRound, SUBMISSION_FILE_REVIEW_REVISION);
96 
97  if (is_array($submissionFiles)) {
98  foreach ($submissionFiles as $file) {
99  if ($file->getDateUploaded() > $decision['dateDecided']) {
100  $sentRevisions = true;
101  break;
102  }
103  }
104  }
105 
106  return $sentRevisions;
107  }
108 }
109 
110 ?>
static & getDAO($name, $dbconn=null)
findValidPendingRevisionsDecision($submissionId, $expectedStageId)
Base class for revision notification types manager delegate.
Abstract class to support notification manager delegates that provide default implementation to the i...