diff options
Diffstat (limited to 'modules/notification/helpers')
-rw-r--r-- | modules/notification/helpers/notification.php | 26 | ||||
-rw-r--r-- | modules/notification/helpers/notification_event.php | 8 |
2 files changed, 20 insertions, 14 deletions
diff --git a/modules/notification/helpers/notification.php b/modules/notification/helpers/notification.php index 5f46a58d..1b5b1b8f 100644 --- a/modules/notification/helpers/notification.php +++ b/modules/notification/helpers/notification.php @@ -119,20 +119,22 @@ class notification { self::_send_message($item, $body); } - static function send_comment_added($comment) { - $body = new View("comment_added.html"); - $body->subject = sprintf(t("Comment added to %s"), $comment->item()->title); - - self::_send_message($comment->item(), $body); - } - - static function send_comment_changed($old, $new) { - $body = new View("comment_changed.html"); - $body->subject = sprintf(t("Comment changed on %s"), $old->item()->title); + static function send_comment_published($comment) { + $item = $comment->item(); + $body = new View("comment_published.html"); + $body->subject = sprintf(t("A new comment for %s was published"), $item->title); + $body->text = $comment->text; + if (!empty($comment->author_id)) { + $author = ORM::factory("user", $comment->author_id); + $body->author = empty($author->full_name) ? $author->name : $author->full_name; + } else { + $body->author = $comment->guest_name; + } + $body->url = url::site("albums/$item->id#comments", "http"); - self::_send_message($old->item(), $body); + self::_send_message($item, $body); } - + private static function _send_message($item, $body) { $users = self::get_subscribers($item); if (!empty($users)) { diff --git a/modules/notification/helpers/notification_event.php b/modules/notification/helpers/notification_event.php index e7c7aac1..6336733a 100644 --- a/modules/notification/helpers/notification_event.php +++ b/modules/notification/helpers/notification_event.php @@ -35,10 +35,14 @@ class notification_event_Core { } static function comment_created($comment) { - notification::send_comment_added($comment); + if ($comment->state == "published") { + notification::send_comment_published($comment); + } } static function comment_updated($old, $new) { - notification::send_comment_changed($old, $new); + if ($new->state == "published" && $old->state != "published") { + notification::send_comment_published($new); + } } } |