mirror of
https://github.com/silverstripe/silverstripe-contentreview
synced 2024-10-22 17:05:47 +02:00
Merge pull request #36 from open-sausages/pulls/fix-inherited-date
BUG Show inherited date even when inheriting settings
This commit is contained in:
commit
6138d0b927
@ -352,6 +352,7 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
|
|||||||
|
|
||||||
$userField = ListboxField::create("OwnerUsers", _t("ContentReview.PAGEOWNERUSERS", "Users"), $usersMap)
|
$userField = ListboxField::create("OwnerUsers", _t("ContentReview.PAGEOWNERUSERS", "Users"), $usersMap)
|
||||||
->setMultiple(true)
|
->setMultiple(true)
|
||||||
|
->addExtraClass('custom-setting')
|
||||||
->setAttribute("data-placeholder", _t("ContentReview.ADDUSERS", "Add users"))
|
->setAttribute("data-placeholder", _t("ContentReview.ADDUSERS", "Add users"))
|
||||||
->setDescription(_t('ContentReview.OWNERUSERSDESCRIPTION', 'Page owners that are responsible for reviews'));
|
->setDescription(_t('ContentReview.OWNERUSERSDESCRIPTION', 'Page owners that are responsible for reviews'));
|
||||||
|
|
||||||
@ -364,6 +365,7 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
|
|||||||
|
|
||||||
$groupField = ListboxField::create("OwnerGroups", _t("ContentReview.PAGEOWNERGROUPS", "Groups"), $groupsMap)
|
$groupField = ListboxField::create("OwnerGroups", _t("ContentReview.PAGEOWNERGROUPS", "Groups"), $groupsMap)
|
||||||
->setMultiple(true)
|
->setMultiple(true)
|
||||||
|
->addExtraClass('custom-setting')
|
||||||
->setAttribute("data-placeholder", _t("ContentReview.ADDGROUP", "Add groups"))
|
->setAttribute("data-placeholder", _t("ContentReview.ADDGROUP", "Add groups"))
|
||||||
->setDescription(_t("ContentReview.OWNERGROUPSDESCRIPTION", "Page owners that are responsible for reviews"));
|
->setDescription(_t("ContentReview.OWNERGROUPSDESCRIPTION", "Page owners that are responsible for reviews"));
|
||||||
|
|
||||||
@ -373,7 +375,12 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
|
|||||||
->setConfig("datavalueformat", "yyyy-MM-dd")
|
->setConfig("datavalueformat", "yyyy-MM-dd")
|
||||||
->setDescription(_t("ContentReview.NEXTREVIEWDATADESCRIPTION", "Leave blank for no review"));
|
->setDescription(_t("ContentReview.NEXTREVIEWDATADESCRIPTION", "Leave blank for no review"));
|
||||||
|
|
||||||
$reviewFrequency = DropdownField::create("ReviewPeriodDays", _t("ContentReview.REVIEWFREQUENCY", "Review frequency"), self::get_schedule())
|
$reviewFrequency = DropdownField::create(
|
||||||
|
"ReviewPeriodDays",
|
||||||
|
_t("ContentReview.REVIEWFREQUENCY", "Review frequency"),
|
||||||
|
self::get_schedule()
|
||||||
|
)
|
||||||
|
->addExtraClass('custom-setting')
|
||||||
->setDescription(_t("ContentReview.REVIEWFREQUENCYDESCRIPTION", "The review date will be set to this far in the future whenever the page is published"));
|
->setDescription(_t("ContentReview.REVIEWFREQUENCYDESCRIPTION", "The review date will be set to this far in the future whenever the page is published"));
|
||||||
|
|
||||||
$notesField = GridField::create("ReviewNotes", "Review Notes", $this->owner->ReviewLogs(), GridFieldConfig_RecordEditor::create());
|
$notesField = GridField::create("ReviewNotes", "Review Notes", $this->owner->ReviewLogs(), GridFieldConfig_RecordEditor::create());
|
||||||
@ -386,9 +393,8 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
|
|||||||
$groupField,
|
$groupField,
|
||||||
$reviewDate,
|
$reviewDate,
|
||||||
$reviewFrequency
|
$reviewFrequency
|
||||||
)->addExtraClass("custom-settings"),
|
)->addExtraClass("review-settings"),
|
||||||
ReadonlyField::create("ROContentOwners", _t("ContentReview.CONTENTOWNERS", "Content Owners"), $this->getOwnerNames()),
|
ReadonlyField::create("ROContentOwners", _t("ContentReview.CONTENTOWNERS", "Content Owners"), $this->getOwnerNames()),
|
||||||
ReadonlyField::create("RONextReviewDate", _t("ContentReview.NEXTREVIEWDATE", "Next review date"), $this->owner->NextReviewDate),
|
|
||||||
$notesField,
|
$notesField,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -504,19 +510,6 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
|
|||||||
$nextReviewUnixSec = strtotime(" + " . $this->owner->ReviewPeriodDays . " days", SS_Datetime::now()->format("U"));
|
$nextReviewUnixSec = strtotime(" + " . $this->owner->ReviewPeriodDays . " days", SS_Datetime::now()->format("U"));
|
||||||
$this->owner->NextReviewDate = date("Y-m-d", $nextReviewUnixSec);
|
$this->owner->NextReviewDate = date("Y-m-d", $nextReviewUnixSec);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
if ($this->owner->isChanged("NextReviewDate", 2)) {
|
|
||||||
$children = $this->owner->stageChildren(true)->filter("ContentReviewType", "Inherit");
|
|
||||||
$compatibility = ContentReviewCompatability::start();
|
|
||||||
|
|
||||||
foreach ($children as $child) {
|
|
||||||
$child->NextReviewDate = $this->owner->NextReviewDate;
|
|
||||||
$child->write();
|
|
||||||
}
|
|
||||||
|
|
||||||
ContentReviewCompatability::done($compatibility);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function setDefaultReviewDateForDisabled()
|
private function setDefaultReviewDateForDisabled()
|
||||||
@ -526,6 +519,7 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
|
|||||||
|
|
||||||
protected function setDefaultReviewDateForCustom()
|
protected function setDefaultReviewDateForCustom()
|
||||||
{
|
{
|
||||||
|
// Don't overwrite existing value
|
||||||
if ($this->owner->NextReviewDate) {
|
if ($this->owner->NextReviewDate) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -542,11 +536,16 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
|
|||||||
|
|
||||||
protected function setDefaultReviewDateForInherited()
|
protected function setDefaultReviewDateForInherited()
|
||||||
{
|
{
|
||||||
|
// Don't overwrite existing value
|
||||||
|
if($this->owner->NextReviewDate) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$options = $this->getOptions();
|
$options = $this->getOptions();
|
||||||
$nextDate = null;
|
$nextDate = null;
|
||||||
|
|
||||||
if ($options && $this->owner->parent()->exists()) {
|
if ($options instanceof SiteTree) {
|
||||||
$nextDate = $this->getReviewDate($this->owner->parent());
|
$nextDate = $this->getReviewDate($options);
|
||||||
} elseif ($options instanceof SiteConfig) {
|
} elseif ($options instanceof SiteConfig) {
|
||||||
$nextDate = $this->getReviewDate();
|
$nextDate = $this->getReviewDate();
|
||||||
}
|
}
|
||||||
|
@ -40,16 +40,15 @@ jQuery(function($) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_custom: function() {
|
_custom: function() {
|
||||||
$('.custom-settings').show();
|
$('.review-settings').show();
|
||||||
$('.inherited-settings').hide();
|
$('.field.custom-setting').show();
|
||||||
},
|
},
|
||||||
_inherited: function() {
|
_inherited: function() {
|
||||||
$('.inherited-settings').show();
|
$('.review-settings').show();
|
||||||
$('.custom-settings').hide();
|
$('.field.custom-setting').hide();
|
||||||
},
|
},
|
||||||
_disabled: function() {
|
_disabled: function() {
|
||||||
$('.inherited-settings').hide();
|
$('.review-settings').hide();
|
||||||
$('.custom-settings').hide();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -68,17 +68,19 @@ class ContentReviewSettingsTest extends SapphireTest
|
|||||||
|
|
||||||
public function testAdvanceReviewFromInheritedSettings()
|
public function testAdvanceReviewFromInheritedSettings()
|
||||||
{
|
{
|
||||||
/** @var Page|SiteTreeContentReview $page */
|
// When a parent page is advanced, the next review date of the child is not automatically advanced
|
||||||
$page = $this->objFromFixture("Page", "page-1-1");
|
|
||||||
|
|
||||||
/** @var Page|SiteTreeContentReview $parentPage */
|
|
||||||
$parentPage = $this->objFromFixture("Page", "page-1");
|
$parentPage = $this->objFromFixture("Page", "page-1");
|
||||||
|
$this->assertTrue($parentPage->advanceReviewDate());
|
||||||
|
$parentPage->write();
|
||||||
|
|
||||||
|
$page = $this->objFromFixture("Page", "page-1-1");
|
||||||
|
$this->assertEquals(date("Y-m-d", strtotime("now + 5 days")), $parentPage->NextReviewDate);
|
||||||
|
$this->assertEquals('2011-04-12', $page->NextReviewDate);
|
||||||
|
|
||||||
|
// When a sub page is advanced, the next review date is advanced by the number of days in the parent
|
||||||
$this->assertTrue($page->advanceReviewDate());
|
$this->assertTrue($page->advanceReviewDate());
|
||||||
|
|
||||||
$page->write();
|
$page->write();
|
||||||
|
$this->assertEquals(date("Y-m-d", strtotime("now + 5 days")), $page->NextReviewDate);
|
||||||
$this->assertEquals(date("Y-m-d", strtotime("now + " . $parentPage->ReviewPeriodDays . " days")), $page->NextReviewDate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAdvanceReviewFromInheritedSiteConfigSettings()
|
public function testAdvanceReviewFromInheritedSiteConfigSettings()
|
||||||
@ -183,19 +185,11 @@ class ContentReviewSettingsTest extends SapphireTest
|
|||||||
|
|
||||||
public function testGetNextReviewDateFromPageInheritedSetting()
|
public function testGetNextReviewDateFromPageInheritedSetting()
|
||||||
{
|
{
|
||||||
/** @var Page|SiteTreeContentReview $page */
|
// Although page-1-1 inherits from page-1, it has an independent review date
|
||||||
$page = $this->objFromFixture("Page", "page-1-1");
|
$page = $this->objFromFixture("Page", "page-1-1");
|
||||||
|
|
||||||
$nextReviewDate = $page->getReviewDate();
|
$nextReviewDate = $page->getReviewDate();
|
||||||
|
|
||||||
$this->assertInstanceOf("Date", $nextReviewDate);
|
$this->assertInstanceOf("Date", $nextReviewDate);
|
||||||
|
$this->assertEquals('2011-04-12', $nextReviewDate->format("Y-m-d"));
|
||||||
/** @var Page|SiteTreeContentReview $nextPage */
|
|
||||||
$nextPage = $this->objFromFixture("Page", "page-1");
|
|
||||||
|
|
||||||
$expected = $nextPage->NextReviewDate;
|
|
||||||
|
|
||||||
$this->assertEquals($expected, $nextReviewDate->format("Y-m-d"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUpdateNextReviewDateFromCustomToDisabled()
|
public function testUpdateNextReviewDateFromCustomToDisabled()
|
||||||
@ -248,13 +242,10 @@ class ContentReviewSettingsTest extends SapphireTest
|
|||||||
/** @var Page|SiteTreeContentReview $childPage */
|
/** @var Page|SiteTreeContentReview $childPage */
|
||||||
$childPage = $this->objFromFixture("Page", "page-1-1");
|
$childPage = $this->objFromFixture("Page", "page-1-1");
|
||||||
|
|
||||||
// BEFORE: parent page have a period of five days, so childPage should have a
|
// Parent and child pages have different review dates
|
||||||
// review date LastEdited + 5 days
|
$this->assertNotEquals($parentPage->NextReviewDate, $childPage->NextReviewDate);
|
||||||
$this->assertEquals($parentPage->NextReviewDate, $childPage->NextReviewDate);
|
|
||||||
|
|
||||||
$oldChildDate = $childPage->NextReviewDate;
|
// But if we change the parent page ReviewPeriodDays to 10, the childs stays the same
|
||||||
// But if we change the parent page ReviewPeriodDays to 10, the childs should
|
|
||||||
// change as well
|
|
||||||
$parentPage->ReviewPeriodDays = 10;
|
$parentPage->ReviewPeriodDays = 10;
|
||||||
$parentPage->write();
|
$parentPage->write();
|
||||||
|
|
||||||
@ -267,11 +258,14 @@ class ContentReviewSettingsTest extends SapphireTest
|
|||||||
/** @var Page|SiteTreeContentReview $page */
|
/** @var Page|SiteTreeContentReview $page */
|
||||||
$childPage = $this->objFromFixture("Page", "page-1-1");
|
$childPage = $this->objFromFixture("Page", "page-1-1");
|
||||||
|
|
||||||
// AFTER: parent page have a period of 10 days, so childPage should have
|
// The parent page's date advances, but not the child's
|
||||||
// a review date now + 10 days.
|
$this->assertEquals('2011-04-12', $childPage->NextReviewDate);
|
||||||
$this->assertNotEquals($oldChildDate, $childPage->NextReviewDate);
|
$this->assertEquals($this->addDaysToDate(date("Y-m-d"), 10), $parentPage->NextReviewDate);
|
||||||
|
|
||||||
|
// Reviewing the child page should, however, advance its review by 10 days
|
||||||
|
$childPage->advanceReviewDate();
|
||||||
|
$childPage->write();
|
||||||
$this->assertEquals($this->addDaysToDate(date("Y-m-d"), 10), $childPage->NextReviewDate);
|
$this->assertEquals($this->addDaysToDate(date("Y-m-d"), 10), $childPage->NextReviewDate);
|
||||||
$this->assertEquals($parentPage->NextReviewDate, $childPage->NextReviewDate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,94 +1,96 @@
|
|||||||
Permission:
|
Permission:
|
||||||
cmsmain1:
|
cmsmain1:
|
||||||
Code: CMS_ACCESS_CMSMain
|
Code: CMS_ACCESS_CMSMain
|
||||||
cmsmain2:
|
cmsmain2:
|
||||||
Code: CMS_ACCESS_CMSMain
|
Code: CMS_ACCESS_CMSMain
|
||||||
setreviewdates:
|
setreviewdates:
|
||||||
Code: EDIT_CONTENT_REVIEW_FIELDS
|
Code: EDIT_CONTENT_REVIEW_FIELDS
|
||||||
workflowadmin1:
|
workflowadmin1:
|
||||||
Code: IS_WORKFLOW_ADMIN
|
Code: IS_WORKFLOW_ADMIN
|
||||||
workflowadmin2:
|
workflowadmin2:
|
||||||
Code: IS_WORKFLOW_ADMIN
|
Code: IS_WORKFLOW_ADMIN
|
||||||
|
|
||||||
Group:
|
Group:
|
||||||
webmastergroup:
|
webmastergroup:
|
||||||
Title: Edit existing pages
|
Title: Edit existing pages
|
||||||
Code: editorgroup
|
Code: editorgroup
|
||||||
Permissions: =>Permission.cmsmain1,=>Permission.workflowadmin1,=>Permission.setreviewdates
|
Permissions: =>Permission.cmsmain1,=>Permission.workflowadmin1,=>Permission.setreviewdates
|
||||||
editorgroup:
|
editorgroup:
|
||||||
Title: Edit existing pages
|
Title: Edit existing pages
|
||||||
Code: editorgroup
|
Code: editorgroup
|
||||||
Permissions: =>Permission.cmsmain1,=>Permission.workflowadmin1,=>Permission.setreviewdates
|
Permissions: =>Permission.cmsmain1,=>Permission.workflowadmin1,=>Permission.setreviewdates
|
||||||
authorgroup:
|
authorgroup:
|
||||||
Title: Author existing pages
|
Title: Author existing pages
|
||||||
Code: authorgroup
|
Code: authorgroup
|
||||||
Permissions: =>Permission.cmsmain2,=>Permission.workflowadmin2
|
Permissions: =>Permission.cmsmain2,=>Permission.workflowadmin2
|
||||||
|
|
||||||
Member:
|
Member:
|
||||||
webmaster:
|
webmaster:
|
||||||
FirstName: Web
|
FirstName: Web
|
||||||
Surname: Master
|
Surname: Master
|
||||||
Email: webmaster@example.com
|
Email: webmaster@example.com
|
||||||
Groups: =>Group.webmastergroup
|
Groups: =>Group.webmastergroup
|
||||||
author:
|
author:
|
||||||
FirstName: Test
|
FirstName: Test
|
||||||
Surname: Author
|
Surname: Author
|
||||||
Email: author@example.com
|
Email: author@example.com
|
||||||
Groups: =>Group.authorgroup
|
Groups: =>Group.authorgroup
|
||||||
editor:
|
editor:
|
||||||
FirstName: Test
|
FirstName: Test
|
||||||
Surname: Editor
|
Surname: Editor
|
||||||
Groups: =>Group.editorgroup
|
Groups: =>Group.editorgroup
|
||||||
SiteConfig:
|
SiteConfig:
|
||||||
default:
|
default:
|
||||||
ContentReviewUsers: =>Member.webmaster
|
ContentReviewUsers: =>Member.webmaster
|
||||||
ContentReviewGroups: =>Group.webmastergroup
|
ContentReviewGroups: =>Group.webmastergroup
|
||||||
ReviewPeriodDays: 30
|
ReviewPeriodDays: 30
|
||||||
Page:
|
Page:
|
||||||
custom:
|
custom:
|
||||||
Title: custom
|
Title: custom
|
||||||
ContentReviewType: Custom
|
ContentReviewType: Custom
|
||||||
NextReviewDate: 2010-02-01
|
NextReviewDate: 2010-02-01
|
||||||
ContentReviewUsers: =>Member.editor
|
ContentReviewUsers: =>Member.editor
|
||||||
ReviewPeriodDays: 10
|
ReviewPeriodDays: 10
|
||||||
disabled:
|
disabled:
|
||||||
Title: disabled
|
Title: disabled
|
||||||
ContentReviewType: Disabled
|
ContentReviewType: Disabled
|
||||||
inherit:
|
inherit:
|
||||||
Title: inherit
|
Title: inherit
|
||||||
ContentReviewType: Inherit
|
ContentReviewType: Inherit
|
||||||
page-1:
|
page-1:
|
||||||
Title: page 1
|
Title: page 1
|
||||||
ContentReviewType: Custom
|
ContentReviewType: Custom
|
||||||
ReviewPeriodDays: 5
|
ReviewPeriodDays: 5
|
||||||
NextReviewDate: 2010-02-01
|
NextReviewDate: 2010-02-01
|
||||||
page-1-1:
|
page-1-1:
|
||||||
Title: page 1 1
|
Title: page 1 1
|
||||||
ContentReviewType: Inherit
|
ContentReviewType: Inherit
|
||||||
ParentID: =>Page.page-1
|
ReviewPeriodDays: 1
|
||||||
page-2:
|
NextReviewDate: 2011-04-12
|
||||||
Title: page 2
|
ParentID: =>Page.page-1
|
||||||
ContentReviewType: Inherit
|
page-2:
|
||||||
page-2-1:
|
Title: page 2
|
||||||
Title: page 2 1
|
ContentReviewType: Inherit
|
||||||
ContentReviewType: Disabled
|
page-2-1:
|
||||||
ParentID: =>Page.page-2
|
Title: page 2 1
|
||||||
page-2-1-1:
|
ContentReviewType: Disabled
|
||||||
Title: page 2 1 1
|
ParentID: =>Page.page-2
|
||||||
ContentReviewType: Inherit
|
page-2-1-1:
|
||||||
ParentID: =>Page.page-2-1
|
Title: page 2 1 1
|
||||||
page-3:
|
ContentReviewType: Inherit
|
||||||
Title: page 3
|
ParentID: =>Page.page-2-1
|
||||||
ContentReviewType: Inherit
|
page-3:
|
||||||
page-3-1:
|
Title: page 3
|
||||||
Title: page 3 1
|
ContentReviewType: Inherit
|
||||||
ContentReviewType: Inherit
|
page-3-1:
|
||||||
ParentID: =>Page.page-3
|
Title: page 3 1
|
||||||
page-3-1-1:
|
ContentReviewType: Inherit
|
||||||
Title: page 3 1 1
|
ParentID: =>Page.page-3
|
||||||
ContentReviewType: Inherit
|
page-3-1-1:
|
||||||
ParentID: =>Page.page-3-1
|
Title: page 3 1 1
|
||||||
page-3-1-1-1:
|
ContentReviewType: Inherit
|
||||||
Title: page 3 1 1 1
|
ParentID: =>Page.page-3-1
|
||||||
ContentReviewType: Inherit
|
page-3-1-1-1:
|
||||||
ParentID: =>Page.page-3-1-1
|
Title: page 3 1 1 1
|
||||||
|
ContentReviewType: Inherit
|
||||||
|
ParentID: =>Page.page-3-1-1
|
||||||
|
Loading…
Reference in New Issue
Block a user