finalise email behaviour

This commit is contained in:
Julian 2016-08-31 08:28:09 +12:00
parent 556f3c3126
commit 6e0240deb3
4 changed files with 57 additions and 55 deletions

View File

@ -34,8 +34,8 @@ class ContentReviewDefaultSettings extends DataExtension
private static $defaults = array(
'ReviewSubjectReminder' => 'Page(s) are approaching content review date',
'ReviewSubject' => 'Page(s) are due for content review',
'ReviewBodyFirstReminder' => '<h2>Page(s) 1 month from review</h2><p>There are $PagesCount pages that are due for review by you 1 month from today.</p>',
'ReviewBodySecondReminder' => '<h2>Page(s) 1 week from from review</h2><p>There are $PagesCount pages that are due for review by you 1 week from today.</p>',
'ReviewBodyFirstReminder' => '<h2>Page(s) 1 month from review</h2><p>There are $FirstReminderPagesCount pages that are due for review by you 1 month from today.</p>',
'ReviewBodySecondReminder' => '<h2>Page(s) 1 week from from review</h2><p>There are $SecondReminderPagesCount pages that are due for review by you 1 week from today.</p>',
'ReviewBody' => '<h2>Page(s) due for review</h2><p>There are $PagesCount pages that are due for review today by you.</p>',
'ReviewReminderEmail' => 'govt.nz@dia.govt.nz',
'FirstReviewDaysBefore' => '30',
@ -125,19 +125,6 @@ class ContentReviewDefaultSettings extends DataExtension
$fields->addFieldToTab('Root.ContentReview', $reviewFrequency);
$FirstReviewDaysBefore = NumericField::create(
'FirstReviewDaysBefore',
_t('ContentReview.FIRSTREVIEWDAYSBEFORE', 'First review reminder # days before final review')
);
$fields->addFieldToTab('Root.ContentReview', $FirstReviewDaysBefore);
$SecondReviewDaysBefore = NumericField::create(
'SecondReviewDaysBefore',
_t('ContentReview.SECONDREVIEWDAYSBEFORE', 'Second review reminder # days before final review')
);
$fields->addFieldToTab('Root.ContentReview', $SecondReviewDaysBefore);
$users = Permission::get_members_by_permission(array(
'CMS_ACCESS_CMSMain',
@ -170,12 +157,24 @@ class ContentReviewDefaultSettings extends DataExtension
$fields->addFieldToTab('Root.ContentReview', $groupField);
$FirstReviewDaysBefore = NumericField::create(
'FirstReviewDaysBefore',
_t('ContentReview.FIRSTREVIEWDAYSBEFORE', 'First review reminder # days before final review')
);
$SecondReviewDaysBefore = NumericField::create(
'SecondReviewDaysBefore',
_t('ContentReview.SECONDREVIEWDAYSBEFORE', 'Second review reminder # days before final review')
);
// Email content
$fields->addFieldsToTab(
'Root.ContentReview',
array(
TextField::create('ReviewFrom', _t('ContentReview.EMAILFROM', 'From email address'))
->setRightTitle(_t('Review.EMAILFROM_RIGHTTITLE', 'e.g: do-not-reply@site.com')),
$FirstReviewDaysBefore,
$SecondReviewDaysBefore,
TextField::create('ReviewReminderEmail','Review reminder email address')
->setRightTitle('e.g: review.reminders@site.com'),
TextField::create('ReviewSubjectReminder', _t('ContentReview.EMAILSUBJECTREMINDER', 'Subject line - reminder')),

View File

@ -46,26 +46,6 @@ class ContentReviewEmails extends BuildTask
}
}
Debug::show('====================================================================FIRST REMINDER');
foreach ($firstReminderPages as $p) {
Debug::show($p->Title);
}
Debug::show('====================================================================SECOND REMINDER');
foreach ($secondReminderPages as $p) {
Debug::show($p->Title);
}
Debug::show('====================================================================DUE/OVERDUE');
foreach ($pages as $p) {
Debug::show($p->Title);
}
//die();
$overduePages = $this->getNotifiablePagesForOwners($pages);
// Send one email to one owner with all the pages in there instead of no of pages of emails.
@ -109,6 +89,12 @@ Debug::show('===================================================================
return $overduePages;
}
/**
* Send an email to the configured team indicating which notices are at 'first reminder' or 'second reminder' status
* The 'days before due' value for each of these is configurable in settings.
* ie. a value of 30 for the 'first reminder' setting means a page with a review date exactly 30 days from due, will
* be present in the email sent to the configured address.
*/
protected function notifyTeam($firstReminderPages, $secondReminderPages) {
// Prepare variables
$siteConfig = SiteConfig::current_site_config();
@ -117,15 +103,12 @@ Debug::show('===================================================================
// Build email
$email = new Email();
$email->setTo($siteConfig->Email);
$email->setTo($siteConfig->ReviewReminderEmail);
$email->setFrom($siteConfig->ReviewFrom);
$subject = $siteConfig->ReviewSubject;
$subject = $siteConfig->ReviewSubjectReminder;
$email->setSubject($subject);
// Get user-editable body
$bodyFirstReminder = $this->getEmailBody($siteConfig, $templateVariables1, 'reminder1');
$bodySecondReminder = $this->getEmailBody($siteConfig, $templateVariables2, 'reminder2');
@ -136,16 +119,11 @@ Debug::show('===================================================================
$email->populateTemplate(array(
'EmailBodyFirstReminder' => $bodyFirstReminder,
'EmailBodySecondReminder' => $bodySecondReminder,
'Recipient' => $siteConfig->ReviewReminderEmail,
'FirstReminderPages' => $firstReminderPages,
'SecondReminderPages' => $secondReminderPages,
));
Debug::show($email);
//$email->send();
$email->send();
}
/**
@ -180,8 +158,7 @@ Debug::show('===================================================================
'Pages' => $pages,
));
Debug::show($email);
//$email->send();
$email->send();
}
/**

View File

@ -6,6 +6,20 @@
[![License](http://img.shields.io/packagist/l/silverstripe/contentreview.svg?style=flat-square)](license.md)
![helpfulrobot](https://helpfulrobot.io/silverstripe/contentreview/badge)
**Note:** _Govt.nz customisations to this module are as follows_
Prior to the due date, the content review task will send an email to the address configured in the settings.
This email contains two lists:
- a list of pages whose review date is exactly 1 month in the future.
- another list of pages whose review date is exactly 1 week in the future.
Both these times (1 month and 1 week) are defaults only, and can be configured in the settings area.
The email body for these reminder emails is also configurable in the settings.
---
This module helps keep your website content accurate and up-to-date, which keeps your users happy.
It does so by sending reviewers reminder emails to go in and check the content. For a reviewer this

View File

@ -1,10 +1,22 @@
<p>This is a list of dynamic variables that you can use in the email templates.</p>
<p>This is a list of dynamic variables that you can use in the <strong>First</strong> and <strong>Second</strong> reminder email templates.</p>
<ul>
<li>&#36;Subject - Email subject line</li>
<li>&#36;PagesCount - Number of pages pending review</li>
<li>&#36;FromEmail - Sender email address</li>
<li>&#36;ToFirstName - The email receivers first name</li>
<li>&#36;ToSurname - The email receivers surname</li>
<li>&#36;ToEmail - The email receivers email</li>
<li>&#36;Subject - Email subject line</li>
<li>&#36;FirstReminderPagesCount - Number of pages approaching review date (first reminder)</li>
<li>&#36;SecondReminderPagesCount - Number of pages approaching review date (second reminder)</li>
<li>&#36;FromEmail - Sender email address</li>
<li>&#36;ToEmail - The email receivers email</li>
</ul>
<br>
<p>This is a list of dynamic variables that you can use in the <strong>Due</strong> email template.</p>
<ul>
<li>&#36;Subject - Email subject line</li>
<li>&#36;PagesCount - Number of pages pending review</li>
<li>&#36;FromEmail - Sender email address</li>
<li>&#36;ToFirstName - The email receivers first name</li>
<li>&#36;ToSurname - The email receivers surname</li>
<li>&#36;ToEmail - The email receivers email</li>
</ul>