Skip to content

Commit

Permalink
Merge branch '2'
Browse files Browse the repository at this point in the history
  • Loading branch information
dhensby committed Jul 5, 2017
2 parents 6c1e6a9 + ca59af4 commit 84ac94f
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 3 deletions.
1 change: 1 addition & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
comment: false
15 changes: 15 additions & 0 deletions docs/en/configuring-notifications.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Configuring notifications

## Configuring whether notifications will send to authors of blogs if comments are spam

Default behaviour using the `silverstripe/comment-notifications` module is to send notification to authors of comments occuring regardless if they are spam or not.

In some cases you may wish to not send a notification email to an author if the comment is spam, this is a configurable option.

Add the following into your yaml config:

```
BlogPostNotifications:
notification_on_spam: false
```

4 changes: 2 additions & 2 deletions src/Model/BlogMemberExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ public function updateCMSFields(FieldList $fields)
Requirements::css(BLOGGER_DIR . '/css/cms.css');
Requirements::javascript(BLOGGER_DIR . '/js/cms.js');

$tab = Tab::create('BlogPosts', 'Blog Posts');
$tab = Tab::create('BlogPosts', _t('BlogMemberExtension.TABBLOGPOSTS', 'Blog Posts'));

$gridField = GridField::create(
'BlogPosts',
'Blog Posts',
_t('BlogMemberExtension.BLOGPOSTS', 'Blog Posts'),
$this->owner->BlogPosts(),
GridFieldConfig_BlogPost::create()
);
Expand Down
2 changes: 1 addition & 1 deletion src/Model/BlogPostFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function augmentSQL(SQLSelect $query, DataQuery $dataQuery = null)
{
$stage = Versioned::get_stage();

if (Controller::curr() instanceof LeftAndMain) {
if (Controller::has_curr() && Controller::curr() instanceof LeftAndMain) {
return;
}

Expand Down
12 changes: 12 additions & 0 deletions src/Model/BlogPostNotifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
*/
class BlogPostNotifications extends DataExtension
{
/**
* Configure whether to send notifications even for spam comments
* @config
*/
private static $notification_on_spam = true;

/**
* Notify all authors of notifications.
*
Expand All @@ -19,7 +25,13 @@ class BlogPostNotifications extends DataExtension
*/
public function updateNotificationRecipients(&$list, &$comment)
{
//default is notification is on regardless of spam status
$list = $this->owner->Authors();

// 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();
}
}

/**
Expand Down

0 comments on commit 84ac94f

Please sign in to comment.