Source of file CommentingControllerNotificationsExtension.php
Size: 1,314 Bytes - Last Modified: 2021-12-23T10:53:28+00:00
/var/www/docs.ssmods.com/process/src/code/extensions/CommentingControllerNotificationsExtension.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 | <?php /** * @author Damian Mooyman * @see CommentingController */ class CommentingControllerNotificationsExtension extends Extension { /** * Notify admin of new comment * * @param Comment $comment */ public function onAfterPostComment(Comment $comment) { // Determine recipient $recipient = CommentsNotifications::get_recipient($comment->getParent()); if(empty($recipient)) return; // Check moderation status if(Config::inst()->get('CommentsNotifications', 'only_unmoderated') && $comment->Moderated) return; // Generate email $email = new Email(); $email->setSubject(Config::inst()->get('CommentsNotifications', 'email_subject')); $email->setTo($recipient); $email->setTemplate(Config::inst()->get('CommentsNotifications', 'email_template')); $email->populateTemplate($comment); // Corretly set sender and from as per email convention $sender = Config::inst()->get('CommentsNotifications', 'email_sender'); if(!empty($comment->Email)) { $email->setFrom($comment->Email); $email->addCustomHeader ('Reply-To', $comment->Email); } else { $email->setFrom($sender); } $email->addCustomHeader('X-Sender', $sender); $email->addCustomHeader('Sender', $sender); $this->owner->extend('updateEmail', $email); // Send $email->send(); } } |