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
|
* @param SiteTree $page
|
||||||
* @return Date | false - returns false if the content review have disabled
|
* @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'
|
* @return bool - returns true if date was set and false is content review is 'off'
|
||||||
*/
|
*/
|
||||||
public function advanceReviewDate() {
|
public function advanceReviewDate() {
|
||||||
$hasNextReview = true;
|
$options = $this->getOptions();
|
||||||
if($this->owner->ReviewPeriodDays) {
|
$nextDate = false;
|
||||||
$this->owner->NextReviewDate = date('Y-m-d', strtotime('+' . $this->owner->ReviewPeriodDays . ' days'));
|
if($options && $options->ReviewPeriodDays) {
|
||||||
} else {
|
$nextDate = date('Y-m-d', strtotime('+ '.$options->ReviewPeriodDays.' days', SS_Datetime::now()->format('U')));
|
||||||
|
|
||||||
$hasNextReview = false;
|
|
||||||
$this->owner->NextReviewDate = null;
|
|
||||||
}
|
}
|
||||||
|
$this->owner->NextReviewDate = $nextDate;
|
||||||
$this->owner->write();
|
$this->owner->write();
|
||||||
return $hasNextReview;
|
return (bool)$nextDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,7 +20,6 @@ Group:
|
|||||||
Code: authorgroup
|
Code: authorgroup
|
||||||
Permissions: =>Permission.cmsmain2,=>Permission.workflowadmin2
|
Permissions: =>Permission.cmsmain2,=>Permission.workflowadmin2
|
||||||
|
|
||||||
|
|
||||||
Member:
|
Member:
|
||||||
author:
|
author:
|
||||||
FirstName: Test
|
FirstName: Test
|
||||||
|
@ -38,6 +38,7 @@ class SiteTreeContentReviewTest extends FunctionalTest {
|
|||||||
|
|
||||||
public function testAdvanceReviewDate10Days() {
|
public function testAdvanceReviewDate10Days() {
|
||||||
$page = new Page();
|
$page = new Page();
|
||||||
|
$page->ContentReviewType = 'Custom';
|
||||||
$page->ReviewPeriodDays = 10;
|
$page->ReviewPeriodDays = 10;
|
||||||
$this->assertTrue($page->advanceReviewDate());
|
$this->assertTrue($page->advanceReviewDate());
|
||||||
$page->write();
|
$page->write();
|
||||||
@ -46,6 +47,7 @@ class SiteTreeContentReviewTest extends FunctionalTest {
|
|||||||
|
|
||||||
public function testAdvanceReviewDateNull() {
|
public function testAdvanceReviewDateNull() {
|
||||||
$page = new Page();
|
$page = new Page();
|
||||||
|
$page->ContentReviewType = 'Custom';
|
||||||
$page->ReviewPeriodDays = 0;
|
$page->ReviewPeriodDays = 0;
|
||||||
$this->assertFalse($page->advanceReviewDate());
|
$this->assertFalse($page->advanceReviewDate());
|
||||||
$page->write();
|
$page->write();
|
||||||
|
Loading…
Reference in New Issue
Block a user