Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
ENHANCEMENT emails are now sent when a content review date comes up
- Loading branch information
Showing
2 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
/** | ||
* Daily task to send emails to the owners of content items | ||
* when the review date rolls around | ||
* | ||
* @package cmsworkflow | ||
*/ | ||
class ContentReviewEmails extends DailyTask { | ||
function run($req) { $this->process(); } | ||
function process() { | ||
// Disable subsite filter (if installed) | ||
if (ClassInfo::exists('Subsite')) { | ||
$oldSubsiteState = Subsite::$disable_subsite_filter; | ||
Subsite::$disable_subsite_filter = true; | ||
} | ||
|
||
$pages = DataObject::get('Page', "NextReviewDate = '".date('Y-m-d')."' AND OwnerID != 0"); | ||
if ($pages && $pages->Count()) { | ||
foreach($pages as $page) { | ||
$owner = $page->Owner(); | ||
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/show/".$page->ID, | ||
"Recipient" => $recipient, | ||
"Sender" => $sender, | ||
"Page" => $page, | ||
"StageSiteLink" => $page->Link()."?stage=stage", | ||
"LiveSiteLink" => $page->Link()."?stage=live", | ||
)); | ||
|
||
return $email->send(); | ||
} | ||
} | ||
} | ||
|
||
// Revert subsite filter (if installed) | ||
if (ClassInfo::exists('Subsite')) { | ||
Subsite::$disable_subsite_filter = $oldSubsiteState; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | ||
<html> | ||
<head> | ||
</head> | ||
<body> | ||
<table id="Content" cellspacing="0" cellpadding="0"> | ||
<tbody> | ||
<tr> | ||
<td scope="row" colspan="2" class="typography"> | ||
<h2><% _t('ContentReviewEmails.EMAIL_HEADING','Page due for review') %></h2> | ||
|
||
<p>The page $Page.Title is due for review today by you</p> | ||
|
||
<h2>Actions</h2> | ||
<ul> | ||
<li><a href="$PageCMSLink"><% _t('ContentReviewEmails.REVIEWPAGELINK','Review the page in the CMS') %></a></li> | ||
<li><a href="$LiveSiteLink"><% _t('ContentReviewEmails.VIEWPUBLISHEDLINK','View this page on your website') %></a></li> | ||
</ul> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</body> | ||
</html> |