mirror of
https://github.com/silverstripe/silverstripe-contentreview
synced 2024-10-22 17:05:47 +02:00
56 lines
1.7 KiB
PHP
56 lines
1.7 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Daily task to send emails to the owners of content items
|
|
* when the review date rolls around
|
|
*
|
|
* @package contentreview
|
|
*/
|
|
class ContentReviewEmails extends BuildTask {
|
|
|
|
/**
|
|
*
|
|
* @param SS_HTTPRequest $request
|
|
*/
|
|
public function run($request) {
|
|
// Disable subsite filter (if installed)
|
|
if (ClassInfo::exists('Subsite')) {
|
|
$oldSubsiteState = Subsite::$disable_subsite_filter;
|
|
Subsite::$disable_subsite_filter = true;
|
|
}
|
|
|
|
$pages = DataObject::get('Page', "\"SiteTree\".\"NextReviewDate\" = '".(class_exists('SS_Datetime') ? SS_Datetime::now()->URLDate() : SSDatetime::now()->URLDate())."' AND \"SiteTree\".\"ContentReviewOwnerID\" != 0");
|
|
if ($pages && $pages->Count()) {
|
|
foreach($pages as $page) {
|
|
$owner = $page->ContentReviewOwner();
|
|
if ($owner) {
|
|
$sender = Security::findAnAdministrator();
|
|
$recipient = $owner;
|
|
|
|
$subject = sprintf(_t('ContentReviewEmails.SUBJECT', 'Page %s due for content review'), $page->Title);
|
|
|
|
$email = new Email();
|
|
$email->setTo($recipient->Email);
|
|
$email->setFrom(($sender->Email) ? $sender->Email : Email::getAdminEmail());
|
|
$email->setTemplate('ContentReviewEmails');
|
|
$email->setSubject($subject);
|
|
$email->populateTemplate(array(
|
|
"PageCMSLink" => "admin/pages/edit/show/".$page->ID,
|
|
"Recipient" => $recipient,
|
|
"Sender" => $sender,
|
|
"Page" => $page,
|
|
"StageSiteLink" => Controller::join_links($page->Link(), "?stage=Stage"),
|
|
"LiveSiteLink" => Controller::join_links($page->Link(), "?stage=Live"),
|
|
));
|
|
$email->send();
|
|
}
|
|
}
|
|
}
|
|
|
|
// Revert subsite filter (if installed)
|
|
if (ClassInfo::exists('Subsite')) {
|
|
Subsite::$disable_subsite_filter = $oldSubsiteState;
|
|
}
|
|
}
|
|
}
|