Skip to content

Commit

Permalink
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
rixth committed Nov 2, 2009
1 parent ca5f921 commit 9b2df02
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
52 changes: 52 additions & 0 deletions code/ContentReviewEmails.php
@@ -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;
}
}
}
24 changes: 24 additions & 0 deletions templates/ContentReviewEmails.ss
@@ -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>

0 comments on commit 9b2df02

Please sign in to comment.