@@ -11,112 +11,112 @@ |
||
11 | 11 | class CommentNotifiable extends DataExtension |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
15 | - * Default subject line if the owner doesn't override it |
|
16 | - * |
|
17 | - * @config |
|
18 | - * @var string |
|
19 | - */ |
|
20 | - private static $default_notification_subject = 'A new comment has been posted'; |
|
21 | - |
|
22 | - /** |
|
23 | - * Default sender |
|
24 | - * |
|
25 | - * @config |
|
26 | - * @var string |
|
27 | - */ |
|
28 | - private static $default_notification_sender = 'noreply@{host}'; |
|
29 | - |
|
30 | - /** |
|
31 | - * Default template to use for comment notifications |
|
32 | - * |
|
33 | - * @config |
|
34 | - * @var string |
|
35 | - */ |
|
36 | - private static $default_notification_template = 'SilverStripe\\CommentNotifications\\CommentEmail'; |
|
37 | - |
|
38 | - /** |
|
39 | - * Return the list of members or emails to send comment notifications to |
|
40 | - * |
|
41 | - * @param Comment $comment |
|
42 | - * @return array|Traversable |
|
43 | - */ |
|
44 | - public function notificationRecipients($comment) |
|
45 | - { |
|
46 | - $list = []; |
|
47 | - |
|
48 | - if ($adminEmail = Email::config()->admin_email) { |
|
49 | - $list[] = $adminEmail; |
|
50 | - } |
|
51 | - |
|
52 | - $this->owner->invokeWithExtensions('updateNotificationRecipients', $list, $comment); |
|
53 | - |
|
54 | - return $list; |
|
55 | - } |
|
56 | - |
|
57 | - /** |
|
58 | - * Gets the email subject line for comment notifications |
|
59 | - * |
|
60 | - * @param Comment $comment Comment |
|
61 | - * @param Member|string $recipient |
|
62 | - * @return string |
|
63 | - */ |
|
64 | - public function notificationSubject($comment, $recipient) |
|
65 | - { |
|
66 | - $subject = $this->owner->config()->default_notification_subject; |
|
67 | - |
|
68 | - $this->owner->invokeWithExtensions('updateNotificationSubject', $subject, $comment, $recipient); |
|
69 | - |
|
70 | - return $subject; |
|
71 | - } |
|
72 | - |
|
73 | - /** |
|
74 | - * Get the sender email address to use for email notifications |
|
75 | - * |
|
76 | - * @param Comment $comment |
|
77 | - * @param Member|string $recipient |
|
78 | - * @return string |
|
79 | - */ |
|
80 | - public function notificationSender($comment, $recipient) |
|
81 | - { |
|
82 | - $sender = $this->owner->config()->default_notification_sender; |
|
83 | - |
|
84 | - // Do hostname substitution |
|
85 | - $host = isset($_SERVER['HTTP_HOST']) |
|
86 | - ? preg_replace('/^www\./i', '', $_SERVER['HTTP_HOST']) |
|
87 | - : 'localhost'; |
|
88 | - $sender = preg_replace('/{host}/', $host, $sender); |
|
89 | - |
|
90 | - $this->owner->invokeWithExtensions('updateNotificationSender', $sender, $comment, $recipient); |
|
91 | - |
|
92 | - return $sender; |
|
93 | - } |
|
94 | - |
|
95 | - /** |
|
96 | - * Determine the template to use for this email |
|
97 | - * |
|
98 | - * @param Comment $comment |
|
99 | - * @param Member|string $recipient |
|
100 | - * @return string Template name (excluding .ss extension) |
|
101 | - */ |
|
102 | - public function notificationTemplate($comment, $recipient) |
|
103 | - { |
|
104 | - $template = $this->owner->config()->default_notification_template; |
|
105 | - |
|
106 | - $this->owner->invokeWithExtensions('updateNotificationTemplate', $template, $comment, $recipient); |
|
107 | - |
|
108 | - return $template; |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * Update the notification email |
|
113 | - * |
|
114 | - * @param Email $email |
|
115 | - * @param Comment $comment |
|
116 | - * @param Member|string $recipient |
|
117 | - */ |
|
118 | - public function updateCommentNotification($email, $comment, $recipient) |
|
119 | - { |
|
120 | - // |
|
121 | - } |
|
14 | + /** |
|
15 | + * Default subject line if the owner doesn't override it |
|
16 | + * |
|
17 | + * @config |
|
18 | + * @var string |
|
19 | + */ |
|
20 | + private static $default_notification_subject = 'A new comment has been posted'; |
|
21 | + |
|
22 | + /** |
|
23 | + * Default sender |
|
24 | + * |
|
25 | + * @config |
|
26 | + * @var string |
|
27 | + */ |
|
28 | + private static $default_notification_sender = 'noreply@{host}'; |
|
29 | + |
|
30 | + /** |
|
31 | + * Default template to use for comment notifications |
|
32 | + * |
|
33 | + * @config |
|
34 | + * @var string |
|
35 | + */ |
|
36 | + private static $default_notification_template = 'SilverStripe\\CommentNotifications\\CommentEmail'; |
|
37 | + |
|
38 | + /** |
|
39 | + * Return the list of members or emails to send comment notifications to |
|
40 | + * |
|
41 | + * @param Comment $comment |
|
42 | + * @return array|Traversable |
|
43 | + */ |
|
44 | + public function notificationRecipients($comment) |
|
45 | + { |
|
46 | + $list = []; |
|
47 | + |
|
48 | + if ($adminEmail = Email::config()->admin_email) { |
|
49 | + $list[] = $adminEmail; |
|
50 | + } |
|
51 | + |
|
52 | + $this->owner->invokeWithExtensions('updateNotificationRecipients', $list, $comment); |
|
53 | + |
|
54 | + return $list; |
|
55 | + } |
|
56 | + |
|
57 | + /** |
|
58 | + * Gets the email subject line for comment notifications |
|
59 | + * |
|
60 | + * @param Comment $comment Comment |
|
61 | + * @param Member|string $recipient |
|
62 | + * @return string |
|
63 | + */ |
|
64 | + public function notificationSubject($comment, $recipient) |
|
65 | + { |
|
66 | + $subject = $this->owner->config()->default_notification_subject; |
|
67 | + |
|
68 | + $this->owner->invokeWithExtensions('updateNotificationSubject', $subject, $comment, $recipient); |
|
69 | + |
|
70 | + return $subject; |
|
71 | + } |
|
72 | + |
|
73 | + /** |
|
74 | + * Get the sender email address to use for email notifications |
|
75 | + * |
|
76 | + * @param Comment $comment |
|
77 | + * @param Member|string $recipient |
|
78 | + * @return string |
|
79 | + */ |
|
80 | + public function notificationSender($comment, $recipient) |
|
81 | + { |
|
82 | + $sender = $this->owner->config()->default_notification_sender; |
|
83 | + |
|
84 | + // Do hostname substitution |
|
85 | + $host = isset($_SERVER['HTTP_HOST']) |
|
86 | + ? preg_replace('/^www\./i', '', $_SERVER['HTTP_HOST']) |
|
87 | + : 'localhost'; |
|
88 | + $sender = preg_replace('/{host}/', $host, $sender); |
|
89 | + |
|
90 | + $this->owner->invokeWithExtensions('updateNotificationSender', $sender, $comment, $recipient); |
|
91 | + |
|
92 | + return $sender; |
|
93 | + } |
|
94 | + |
|
95 | + /** |
|
96 | + * Determine the template to use for this email |
|
97 | + * |
|
98 | + * @param Comment $comment |
|
99 | + * @param Member|string $recipient |
|
100 | + * @return string Template name (excluding .ss extension) |
|
101 | + */ |
|
102 | + public function notificationTemplate($comment, $recipient) |
|
103 | + { |
|
104 | + $template = $this->owner->config()->default_notification_template; |
|
105 | + |
|
106 | + $this->owner->invokeWithExtensions('updateNotificationTemplate', $template, $comment, $recipient); |
|
107 | + |
|
108 | + return $template; |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * Update the notification email |
|
113 | + * |
|
114 | + * @param Email $email |
|
115 | + * @param Comment $comment |
|
116 | + * @param Member|string $recipient |
|
117 | + */ |
|
118 | + public function updateCommentNotification($email, $comment, $recipient) |
|
119 | + { |
|
120 | + // |
|
121 | + } |
|
122 | 122 | } |