File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -526,7 +526,7 @@ public function advanceReviewDate()
526526 }
527527
528528 /**
529- * Check if a review is due by a member for this owner.
529+ * A function to check whether the content review bell can be displayed
530530 *
531531 * @param Member $member
532532 *
@@ -576,6 +576,61 @@ public function canBeReviewedBy(Member $member = null)
576576 return false ;
577577 }
578578
579+ /**
580+ * Check if a review is overdue and an email can be sent
581+ *
582+ * @param Member $member
583+ *
584+ * @return bool
585+ */
586+ public function canSendEmail (Member $ member = null )
587+ {
588+ if (!$ this ->owner ->obj ("NextReviewDate " )->exists ()) {
589+ return false ;
590+ }
591+
592+ if ($ this ->owner ->obj ("NextReviewDate " )->InFuture ()) {
593+ return false ;
594+ }
595+
596+ $ options = $ this ->getOptions ();
597+
598+ if (!$ options ) {
599+ return false ;
600+ }
601+
602+ if (!$ options
603+ // Options can be a SiteConfig with different extension applied
604+ || (!$ options ->hasExtension (__CLASS__ )
605+ && !$ options ->hasExtension (ContentReviewDefaultSettings::class))
606+ ) {
607+ return false ;
608+ }
609+
610+ if ($ options ->OwnerGroups ()->count () == 0 && $ options ->OwnerUsers ()->count () == 0 ) {
611+ return false ;
612+ }
613+
614+ if (!$ member ) {
615+ return true ;
616+ }
617+
618+ // Whether or not a user is allowed to review the content of the page.
619+ if ($ this ->owner ->hasMethod ("canReviewContent " ) && !$ this ->owner ->canReviewContent ($ member )) {
620+ return false ;
621+ }
622+
623+ if ($ member ->inGroups ($ options ->OwnerGroups ())) {
624+ return true ;
625+ }
626+
627+ if ($ options ->OwnerUsers ()->find ("ID " , $ member ->ID )) {
628+ return true ;
629+ }
630+
631+ return false ;
632+ }
633+
579634 /**
580635 * Set the review data from the review period, if set.
581636 */
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ protected function getOverduePagesForOwners(SS_List $pages)
5454 $ overduePages = [];
5555
5656 foreach ($ pages as $ page ) {
57- if (!$ page ->canBeReviewedBy ()) {
57+ if (!$ page ->canSendEmail ()) {
5858 continue ;
5959 }
6060
You can’t perform that action at this time.
0 commit comments