AdvanceReviewDate now can use inherited settings #3

This commit is contained in:
Stig Lindqvist 2014-02-25 00:46:50 +13:00
parent bfbc53c080
commit de4fac0541
3 changed files with 8 additions and 11 deletions

View File

@ -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;
}
/**

View File

@ -20,7 +20,6 @@ Group:
Code: authorgroup
Permissions: =>Permission.cmsmain2,=>Permission.workflowadmin2
Member:
author:
FirstName: Test

View File

@ -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();