938 Posts in 271 Topics by 291 members
Forum Module
SilverStripe Forums » Forum Module » Notifications of New Postings by Email - Module
Discuss the Forum Module.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 1505 Views |
-
Notifications of New Postings by Email - Module

3 March 2010 at 6:48pm
hi
I've created a silverstripe module, my first, that enables email notification to one email address each time a posting is made anywhere in the forums. The use case here is for a group of forum administrators for a company to be notified under a group alias, e.g. forumadmin@yourcompany.com and then moderate with immediate effect instead of having to hunt through postings.
The code can be found at
http://github.com/gordonbanderson/SilverstripeForumModerationEmails
It decorates the relevant Forum class in order to avoid having to make changes directly to the Forum module in a 'hacky' way
Feedback welcome - as I said it is my first module
Cheers
Gordon
-
Re: Notifications of New Postings by Email - Module

4 March 2010 at 9:47am
Nice addition. I know a couple people have been looking for this.
One of the features I have to implement in the module is a more robust moderation system so going to probably add forum email notifications, pending rss feeds etc but this module will help solve the issue in the short term!
-
Re: Notifications of New Postings by Email - Module

5 March 2010 at 1:36pm
thanks. elg. Thats really good work.
Email noticaiton was quite useful in this stage. will download and have a run your module 4 sure. keeping updating it
-
Re: Notifications of New Postings by Email - Module

5 March 2010 at 5:53pm
hi Willr
Thanks for the comments. Email notification seemed the simplest option, and I based the module on the Embargo / Expiry one once I saw how the decorator pattern was used in that module.
I guess the only problem with email notification regarding possible spam content is if the email itself is placed into a spam folder and ignored
Regards
Gordon
-
Re: Notifications of New Postings by Email - Module

8 November 2012 at 5:15pm
Hi team,
Would love to know if there has been further progress on providing email notifications to Moderators of forums whenever a new post is made?
Client is crying out for this but it's beyond my current coding abilities to deliver on it easily.
Thanks,
Dave
-
Re: Notifications of New Postings by Email - Module

3 January 2013 at 3:45pm
Hi again,
Good news, have made some progress, building on Gordon's great little module.
This version sends an email to all Forum Members with a ForumRank of either Moderator or Administrator:
class ForumEmailPostDecoratorV2 extends DataObjectDecorator {
//Email all Forum Administrators and Moderators when a post is made to any forum
function onAfterWrite() {
$moderators = DataObject::get("Member","ForumRank = 'Administrator' OR ForumRank = 'Moderator'", "", "");
if($moderators) {
foreach($moderators as $member) {
error_log("LOG MESSAGE FROM FORUM EMAIL POST DECORATOR LINK IS ".$this->owner->AbsoluteLink());
$email = new Email();
$email->setFrom(Email::getAdminEmail());
$email->setTo($member->Email);
$email->setSubject('New Forum Posting - ' . $this->owner->Title);
$email->setTemplate('Forum_ModeratorNotificationV2'); //duplicate the original template, rename and modify it as desired, including adding the Recipient's name, see below.
$email->populateTemplate(array(
'Recipient' => $member->FirstName, //personalise the email with the recipients first name.
'AbsoluteLink' => $this->owner->AbsoluteLink(),
'Title' => $this->owner->Title,
'Content' => $this->owner->Content
));
$email->send();
}
parent::onAfterWrite();
}
}
}Note - don't forget to modify the module's config file to extend Post:
DataObject::add_extension('Post', 'ForumEmailPostDecoratorV2');
Next step is to refine this so emails are only sent to the designated moderator(s) of specific forums. Any help on that from the experts would be much appreciated.
Cheers,
Dave
-
Re: Notifications of New Postings by Email - Module

24 April 2013 at 9:27am Last edited: 24 April 2013 9:30am
Hey beautiful people,
Thought you might be interested in my latest developments to elgordo's Forum Notifications module. This version sends a notification email only to the designated Moderators of each forum, plus all Administrators. I've also made minor cosmetic improvements to the generated email to include the recipient Member's first name and the title of the forum that has been posted to (see populateTemplate array).
function onAfterWrite() {
// GET ALL MEMBERS WITH THE FORUMRANK OF "MODERATOR"
$moderators = DataObject::get("Member","ForumRank = 'Moderator'", "", "");
// GET ALL MEMBERS WITH THE FORUMRANK OF "ADMINISTRATOR"
$administrators = DataObject::get("Member","ForumRank = 'Administrator'", "", "");
// EMAIL THE MODERATORS
if($moderators) {
foreach($moderators as $member) {
// ONLY EMAIL THE MODERATORS OF THIS PARTICULAR FORUM
if($member->isModeratingForum($this->owner->Forum())) {
$this->createEmail($member);
}
}
parent::onAfterWrite();
}
// EMAIL THE ADMINISTRATORS
if($administrators) {
foreach($administrators as $member) {
$this->createEmail($member);
}
parent::onAfterWrite();
}
}
//CREATE THE FORUM NOTIFICATION EMAIL
function createEmail($member)
{
error_log("LOG MESSAGE FROM FORUM EMAIL POST DECORATOR LINK IS ".$this->owner->AbsoluteLink());
$email = new Email();
$email->setFrom(Email::getAdminEmail()); //can also just hard code an email address in here.
$email->setTo($member->Email);
$email->setSubject('New Forum Posting - ' . $this->owner->Title);
$email->setTemplate('Forum_ModeratorNotificationV2');
$email->populateTemplate(array(
'Recipient' => $member->FirstName,
'AbsoluteLink' => $this->owner->AbsoluteLink(),
'Title' => $this->owner->Title,
'Content' => $this->owner->Content,
'Forum' => $this->owner->Forum()->Title
));
$email->send();
}
}Next stage:
- filter out Administrators from the Moderators group so people who are both an Administrator and Moderating a particular forum don't get two emails.
- allow the email sender address to be defined via the CMS, plus other text in the email.
- further extend the the Forum module so individual Members can opt in and out of receiving emails for particular forums. (At this stage planning to achieve this by duplicating and tweaking the code that assigns Moderators to particular forums, and allowing people to opt in and out via their Profile page.)Cheers,
Dave
| 1505 Views | ||
|
Page:
1
|
Go to Top |



