File tree Expand file tree Collapse file tree 2 files changed +18
-40
lines changed
Expand file tree Collapse file tree 2 files changed +18
-40
lines changed Original file line number Diff line number Diff line change @@ -585,50 +585,13 @@ public function canBeReviewedBy(Member $member = null)
585585 */
586586 public function canSendEmail (Member $ member = null )
587587 {
588- if (!$ this ->owner ->obj ("NextReviewDate " )->exists ()) {
589- return false ;
590- }
588+ $ canSendEmail = $ this ->canBeReviewedBy ($ member );
591589
592590 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 ;
591+ $ canSendEmail = false ;
625592 }
626593
627- if ($ options ->OwnerUsers ()->find ("ID " , $ member ->ID )) {
628- return true ;
629- }
630-
631- return false ;
594+ return $ canSendEmail ;
632595 }
633596
634597 /**
Original file line number Diff line number Diff line change @@ -195,6 +195,21 @@ public function testCanBeReviewedInFuture()
195195 DBDatetime::clear_mock_now ();
196196 }
197197
198+ public function testCanNotSendReviewEmail ()
199+ {
200+ DBDatetime::set_mock_now ("2010-01-01 12:00:00 " );
201+
202+ /** @var Member $author */
203+ $ author = $ this ->objFromFixture (Member::class, "author " );
204+
205+ /** @var Page|SiteTreeContentReview $page */
206+ $ page = $ this ->objFromFixture (Page::class, "staff " );
207+
208+ $ this ->assertFalse ($ page ->canSendEmail ($ author ));
209+
210+ DBDatetime::clear_mock_now ();
211+ }
212+
198213 public function testCanNotBeReviewedByUser ()
199214 {
200215 DBDatetime::set_mock_now ("2010-03-01 12:00:00 " );
You can’t perform that action at this time.
0 commit comments