Merge pull request #1 from silverstripe/master

Update Govt.nz contentreview fork
This commit is contained in:
Jules 2016-08-23 08:17:11 +12:00 committed by GitHub
commit dd32a6910d
6 changed files with 70 additions and 14 deletions

View File

@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## [3.0.2]
* fix(ContentReviewNotificationJob): Changed to use ->config() system so that the next_run_hour can be configured in YAML.
* BUG Prevent non-real draft changes forcing record to appear as changed when saved
## [3.0.1]
- Update documentation and configuration to supported module standard
- Fix documentation links
## [3.0.0]
- Replace review page form with inline form
@ -22,4 +32,4 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## [2.0.0]
Changelog added.
Changelog added.

View File

@ -120,24 +120,24 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
{
if ($this->canBeReviewedBy(Member::currentUser())) {
Requirements::css("contentreview/css/contentreview.css");
$reviewTitle = LiteralField::create(
"ReviewContentNotesLabel",
"<label class=\"left\" for=\"Form_EditForm_ReviewNotes\">" . _t("ContentReview.CONTENTREVIEW", "Content due for review") . "</label>"
);
$ReviewNotes = LiteralField::create("ReviewNotes", "<textarea class=\"no-change-track\" id=\"Form_EditForm_ReviewNotes\" name=\"ReviewNotes\" placeholder=\"" . _t("ContentReview.COMMENTS", "(optional) Add comments...") . "\" class=\"text\"></textarea>");
$quickReviewAction = FormAction::create("savereview", _t("ContentReview.MARKREVIEWED", "Mark as reviewed"))
->setAttribute("data-icon", "pencil")
->setAttribute("data-text-alternate", _t("ContentReview.MARKREVIEWED", "Mark as reviewed"));
$allFields = CompositeField::create($reviewTitle, $ReviewNotes, $quickReviewAction)
->addExtraClass('review-notes field');
$reviewTab = Tab::create('ReviewContent', $allFields);
$reviewTab->addExtraClass('contentreview-tab');
$actions->fieldByName('ActionMenus')->insertBefore($reviewTab, 'MoreOptions');
}
}
@ -257,7 +257,7 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
$member = Member::currentUser();
if ($member) {
return $member->FirstName . " " . $member->Surname;
return $member->getTitle();
}
return null;
@ -483,8 +483,12 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
*/
public function onBeforeWrite()
{
$this->owner->LastEditedByName = $this->owner->getEditorName();
$this->owner->OwnerNames = $this->owner->getOwnerNames();
// Only update if DB fields have been changed
$changedFields = $this->owner->getChangedFields(true, 2);
if($changedFields) {
$this->owner->LastEditedByName = $this->owner->getEditorName();
$this->owner->OwnerNames = $this->owner->getOwnerNames();
}
// If the user changed the type, we need to recalculate the review date.
if ($this->owner->isChanged("ContentReviewType", 2)) {
@ -509,7 +513,7 @@ class SiteTreeContentReview extends DataExtension implements PermissionProvider
return;
}
// parent page change it's review period
// parent page change its review period
// && !$this->owner->isChanged('ContentReviewType', 2)
if ($this->owner->isChanged("ReviewPeriodDays", 2)) {
$nextReviewUnixSec = strtotime(" + " . $this->owner->ReviewPeriodDays . " days", SS_Datetime::now()->format("U"));

View File

@ -90,11 +90,11 @@ class ContentReviewNotificationJob extends AbstractQueuedJob implements QueuedJo
$nextRun = new ContentReviewNotificationJob();
$nextRunTime = mktime(
self::$next_run_hour,
self::$next_run_minute,
Config::inst()->get(__CLASS__, 'next_run_hour'),
Config::inst()->get(__CLASS__, 'next_run_minute'),
0,
date("m"),
date("d") + self::$next_run_in_days,
date("d") + Config::inst()->get(__CLASS__, 'next_run_in_days'),
date("Y")
);

View File

@ -9,6 +9,9 @@ en:
CUSTOM: 'Custom settings'
DEFAULTSETTINGSHELP: 'These content review settings will apply to all pages that does not have specific Content Review schedule.'
DISABLE: 'Disable content review'
EMAILFROM: 'From email address'
EMAILSUBJECT: 'Subject line'
EMAILTEMPLATE: 'Email template'
INHERIT: 'Inherit from parent page'
MARKREVIEWED: 'Mark as reviewed'
NEXTREVIEWDATADESCRIPTION: 'Leave blank for no review'
@ -35,6 +38,12 @@ en:
PLURALNAME: 'Content Review Logs'
SINGULARNAME: 'Content Review Log'
PagesDueForReviewReport:
ONLYMYPAGES: 'Only Show pages assigned to me'
REVIEWDATEAFTER: 'Review date after or on'
REVIEWDATEBEFORE: 'Review date before or on'
SHOWVIRTUALPAGES: 'Show Virtual Pages'
TITLE: 'Pages due for review'
PagesWithoutReviewScheduleReport:
TITLE: 'Pages without a scheduled review.'
Review:
EMAILFROM_RIGHTTITLE: 'e.g: do-not-reply@site.com'

View File

@ -4,6 +4,7 @@
[![Code Quality](http://img.shields.io/scrutinizer/g/silverstripe/silverstripe-contentreview.svg?style=flat-square)](https://scrutinizer-ci.com/g/silverstripe/silverstripe-contentreview)
[![Version](http://img.shields.io/packagist/v/silverstripe/contentreview.svg?style=flat-square)](https://packagist.org/packages/silverstripe/contentreview)
[![License](http://img.shields.io/packagist/l/silverstripe/contentreview.svg?style=flat-square)](license.md)
![helpfulrobot](https://helpfulrobot.io/silverstripe/contentreview/badge)
This module helps keep your website content accurate and up-to-date, which keeps your users happy.

View File

@ -244,6 +244,38 @@ class SiteTreeContentReviewTest extends ContentReviewBaseTest
SS_Datetime::clear_mock_now();
}
public function testUnModifiedPagesDontChangeEditor() {
SS_Datetime::set_mock_now("2013-03-01 12:00:00");
/** @var Member $author */
$author = $this->objFromFixture("Member", "author");
$this->logInAs($author);
// Page which is un-modified doesn't advance version of have an editor assigned
$contactPage = $this->objFromFixture("Page", "contact");
$contactPageVersion = $contactPage->Version;
$contactPage->write();
$this->assertEmpty($contactPage->LastEditedByName);
$this->assertEquals(
$contactPageVersion,
Versioned::get_versionnumber_by_stage('SiteTree', 'Stage', $contactPage->ID, false)
);
// Page with modifications gets marked
$homePage = $this->objFromFixture("Page", "home");
$homePageVersion = $homePage->Version;
$homePage->Content = '<p>Welcome!</p>';
$homePage->write();
$this->assertNotEmpty($homePage->LastEditedByName);
$this->assertEquals($author->getTitle(), $homePage->LastEditedByName);
$this->assertGreaterThan(
$homePageVersion,
Versioned::get_versionnumber_by_stage('SiteTree', 'Stage', $homePage->ID, false)
);
SS_Datetime::clear_mock_now();
}
public function testReviewActionVisibleForAuthor()
{
SS_Datetime::set_mock_now("2020-03-01 12:00:00");