mirror of
https://github.com/silverstripe/silverstripe-contentreview
synced 2024-10-22 17:05:47 +02:00
AdvanceReviewDate now can use inherited settings #3
This commit is contained in:
parent
bfbc53c080
commit
de4fac0541
@ -62,7 +62,6 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
|
||||
|
||||
/**
|
||||
*
|
||||
* @param DataObject $options
|
||||
* @param SiteTree $page
|
||||
* @return Date | false - returns false if the content review have disabled
|
||||
*/
|
||||
@ -311,17 +310,14 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
|
||||
* @return bool - returns true if date was set and false is content review is 'off'
|
||||
*/
|
||||
public function advanceReviewDate() {
|
||||
$hasNextReview = true;
|
||||
if($this->owner->ReviewPeriodDays) {
|
||||
$this->owner->NextReviewDate = date('Y-m-d', strtotime('+' . $this->owner->ReviewPeriodDays . ' days'));
|
||||
} else {
|
||||
|
||||
$hasNextReview = false;
|
||||
$this->owner->NextReviewDate = null;
|
||||
$options = $this->getOptions();
|
||||
$nextDate = false;
|
||||
if($options && $options->ReviewPeriodDays) {
|
||||
$nextDate = date('Y-m-d', strtotime('+ '.$options->ReviewPeriodDays.' days', SS_Datetime::now()->format('U')));
|
||||
}
|
||||
|
||||
$this->owner->NextReviewDate = $nextDate;
|
||||
$this->owner->write();
|
||||
return $hasNextReview;
|
||||
return (bool)$nextDate;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -20,7 +20,6 @@ Group:
|
||||
Code: authorgroup
|
||||
Permissions: =>Permission.cmsmain2,=>Permission.workflowadmin2
|
||||
|
||||
|
||||
Member:
|
||||
author:
|
||||
FirstName: Test
|
||||
|
@ -38,6 +38,7 @@ class SiteTreeContentReviewTest extends FunctionalTest {
|
||||
|
||||
public function testAdvanceReviewDate10Days() {
|
||||
$page = new Page();
|
||||
$page->ContentReviewType = 'Custom';
|
||||
$page->ReviewPeriodDays = 10;
|
||||
$this->assertTrue($page->advanceReviewDate());
|
||||
$page->write();
|
||||
@ -46,6 +47,7 @@ class SiteTreeContentReviewTest extends FunctionalTest {
|
||||
|
||||
public function testAdvanceReviewDateNull() {
|
||||
$page = new Page();
|
||||
$page->ContentReviewType = 'Custom';
|
||||
$page->ReviewPeriodDays = 0;
|
||||
$this->assertFalse($page->advanceReviewDate());
|
||||
$page->write();
|
||||
|
Loading…
Reference in New Issue
Block a user