diff options
author | Andy Staudacher <andy.st@gmail.com> | 2009-02-02 07:32:45 +0000 |
---|---|---|
committer | Andy Staudacher <andy.st@gmail.com> | 2009-02-02 07:32:45 +0000 |
commit | 60d3d6e704176a54fe9870021a3ecabf8bd52037 (patch) | |
tree | d9847d4aa4e2ea77476db58128bcdf349c3976e1 /modules | |
parent | 5d0b710d54c84e281cd88efda5bacf9e2916a5a3 (diff) |
code audit fixes + bug fix: don't call sendmail with an empty To list (in notifications module)
Diffstat (limited to 'modules')
4 files changed, 16 insertions, 13 deletions
diff --git a/modules/notification/helpers/notification.php b/modules/notification/helpers/notification.php index c25da16d..5f46a58d 100644 --- a/modules/notification/helpers/notification.php +++ b/modules/notification/helpers/notification.php @@ -81,7 +81,7 @@ class notification { } return $subscribers; } - + static function send_item_updated($old, $new) { $body = new View("item_updated.html"); $body->subject = sprintf(t("Item %s updated"), $old->title); @@ -91,7 +91,7 @@ class notification { $body->new_title = $old->title != $new->title ? $new->title : null; $body->new_description = $old->title != $new->description ? $new->description : null; $body->url = url::site("{$old->type}s/$old->id", "http"); - + self::_send_message($old, $body); } @@ -115,14 +115,14 @@ class notification { $body->type = $item->type; $body->item_title = $item->title; $body->url = url::site("albums/$parent->id", "http"); - + 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); } @@ -133,14 +133,16 @@ class notification { self::_send_message($old->item(), $body); } - private function _send_message($item, $body) { + private static function _send_message($item, $body) { $users = self::get_subscribers($item); - Sendmail::factory() - ->to($users) - ->subject($body->subject) - ->header("Mime-Version", "1.0") - ->header("Content-type", "text/html; charset=iso-8859-1") - ->message($body->render()) - ->send(); + if (!empty($users)) { + Sendmail::factory() + ->to($users) + ->subject($body->subject) + ->header("Mime-Version", "1.0") + ->header("Content-type", "text/html; charset=iso-8859-1") + ->message($body->render()) + ->send(); + } } } diff --git a/modules/notification/helpers/notification_menu.php b/modules/notification/helpers/notification_menu.php index d04aa8ba..f12d2832 100644 --- a/modules/notification/helpers/notification_menu.php +++ b/modules/notification/helpers/notification_menu.php @@ -1,4 +1,3 @@ - <?php defined("SYSPATH") or die("No direct script access."); /** * Gallery - a web based photo album viewer and editor diff --git a/modules/notification/views/comment_added.html.php b/modules/notification/views/comment_added.html.php index e69de29b..115bfc86 100644 --- a/modules/notification/views/comment_added.html.php +++ b/modules/notification/views/comment_added.html.php @@ -0,0 +1 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> diff --git a/modules/notification/views/comment_changed.html.php b/modules/notification/views/comment_changed.html.php index e69de29b..115bfc86 100644 --- a/modules/notification/views/comment_changed.html.php +++ b/modules/notification/views/comment_changed.html.php @@ -0,0 +1 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> |