2017 © Pedro Peláez
 

silverstripe-vendormodule comment-notifications

Provides email notifications for visitor comments

image

silverstripe/comment-notifications

Provides email notifications for visitor comments

  • Monday, June 18, 2018
  • by tractorcow
  • Repository
  • 11 Watchers
  • 3 Stars
  • 18,360 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 6 Forks
  • 0 Open issues
  • 11 Versions
  • 18 % Grown

The README.md

Comment Notifications

Build Status Scrutinizer Code Quality codecov.io SilverStripe supported module, (*1)

Provides simple email notifications for when new visitor comments are posted., (*2)

Installation

Install using Composer:, (*3)

composer require silverstripe/comment-notifications ^2.0

Note: This branch is SilverStripe 4 compatible. For a SilverStripe 3 version please see the 1.x release line., (*4)

Configuration

To configure the default email address to receive notifications, place this in your mysite/_config.yml, (*5)

SilverStripe\Control\Email\Email:
  admin_email: 'will@fullscreen.io'

Check out the CommentNotifiable class for the list of options you can override in your project., (*6)

Configuring Recipients

To define who receives the comment notification define a updateNotificationRecipients method and modify the list of email addresses., (*7)

mysite/code/CommentNotificationExtension.php, (*8)

<?php

use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Comments\Model\Comment;
use SilverStripe\ORM\ArrayList;
use SilverStripe\ORM\DataExtension;
use SilverStripe\Security\Group;

class CommentNotificationExtension extends DataExtension
{
    /**
     * @param array $existing
     * @param Comment $comment
     */
    public function updateNotificationRecipients(&$existing, $comment)
    {
        // send notification of the comment to all administrators in the CMS
        $admin = Group::get()->filter('Code', 'admin');

        foreach ($admin as $group) {
            foreach ($group->Members() as $member) {
                $existing[] = $member->Email;
            }
        }

        // or, notify the user who originally created the page
        $page = $comment->Parent();
        if ($page instanceof SiteTree) {
            /** @var ArrayList $pageVersion */
            $pageVersion = $page->allVersions('', '', 1); // get the original version
            if ($pageVersion && $pageVersion->count()) {
                $existing[] = $pageVersion->first()->Author()->Email;
            }
        }
    }
}

Apply the CommentNotificationExtension to any classes which have commenting enabled (e.g SiteTree), (*9)

mysite/_config/extensions.yml, (*10)

SilverStripe\CMS\Model\SiteTree:
  extensions:
    - CommentNotificationExtension

The Versions

18/06 2018

dev-master

9999999-dev

Provides email notifications for visitor comments

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

11/06 2018

2.0.x-dev

2.0.9999999.9999999-dev

Provides email notifications for visitor comments

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

04/04 2018

2.0.1

2.0.1.0

Provides email notifications for visitor comments

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

26/03 2018

dev-raissanorth-patch-1

dev-raissanorth-patch-1

Provides email notifications for visitor comments

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

22/02 2018

2.0.0

2.0.0.0

Provides email notifications for visitor comments

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

14/12 2017

2.0.0-beta1

2.0.0.0-beta1

Provides email notifications for visitor comments

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

28/09 2017

dev-pulls/2.0/readme-badges

dev-pulls/2.0/readme-badges

Provides email notifications for visitor comments

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

28/08 2017

1.0.x-dev

1.0.9999999.9999999-dev

Provides email notifications for visitor comments

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

28/08 2017

1.0.2

1.0.2.0

Provides email notifications for visitor comments

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

03/02 2016

1.0.1

1.0.1.0

Provides email notifications for visitor comments

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

13/04 2015

1.0.0

1.0.0.0

Provides email notifications for visitor comments

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires