2015-04-09 06:01:28 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2015-05-09 16:33:12 +02:00
|
|
|
* Customise blog post to support comment notifications.
|
|
|
|
*
|
|
|
|
* Extends {@see BlogPost} with extensions to {@see CommentNotifiable}.
|
2015-04-09 06:01:28 +02:00
|
|
|
*/
|
2015-11-21 07:17:29 +01:00
|
|
|
class BlogPostNotifications extends DataExtension
|
|
|
|
{
|
2017-07-03 03:56:26 +02:00
|
|
|
/**
|
|
|
|
* Configure whether to send notifications even for spam comments
|
|
|
|
* @config
|
|
|
|
*/
|
|
|
|
private static $notification_on_spam = true;
|
|
|
|
|
2015-11-21 07:17:29 +01:00
|
|
|
/**
|
|
|
|
* Notify all authors of notifications.
|
|
|
|
*
|
|
|
|
* @param SS_List $list
|
|
|
|
* @param mixed $comment
|
|
|
|
*/
|
|
|
|
public function updateNotificationRecipients(&$list, &$comment)
|
|
|
|
{
|
2017-07-03 03:56:26 +02:00
|
|
|
//default is notification is on regardless of spam status
|
2015-11-21 07:17:29 +01:00
|
|
|
$list = $this->owner->Authors();
|
2017-07-03 03:56:26 +02:00
|
|
|
|
|
|
|
// If comment is spam and notification are set to not send on spam clear the recipient list
|
|
|
|
if (Config::inst()->get(__CLASS__, 'notification_on_spam') == false && $comment->IsSpam) {
|
|
|
|
$list = array();
|
|
|
|
}
|
2015-11-21 07:17:29 +01:00
|
|
|
}
|
2015-04-09 06:01:28 +02:00
|
|
|
|
2015-11-21 07:17:29 +01:00
|
|
|
/**
|
|
|
|
* Update comment to include the page title.
|
|
|
|
*
|
|
|
|
* @param string $subject
|
|
|
|
* @param Comment $comment
|
|
|
|
* @param Member|string $recipient
|
|
|
|
*/
|
|
|
|
public function updateNotificationSubject(&$subject, &$comment, &$recipient)
|
|
|
|
{
|
2016-01-25 12:23:27 +01:00
|
|
|
$subject = sprintf('A new comment has been posted on %s', $this->owner->Title);
|
2015-11-21 07:17:29 +01:00
|
|
|
}
|
2015-04-09 06:01:28 +02:00
|
|
|
}
|