diff --git a/modules/notification/helpers/notification.php b/modules/notification/helpers/notification.php
index 00ea994d..9a942728 100644
--- a/modules/notification/helpers/notification.php
+++ b/modules/notification/helpers/notification.php
@@ -82,48 +82,60 @@ class notification {
return $subscribers;
}
- static function send_item_changed($old, $new=null) {
- $users = self::get_subscribers($item);
+ static function send_item_updated($old, $new) {
+ $body = new View("item_updated.html");
+ $body->subject = sprintf(t("Item %s updated"), $old->title);
+ $body->type = ucfirst($old->type);
+ $body->item_title = $old->title;
+ $body->description = $item->description;
+ $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);
}
static function send_item_add($item) {
- $users = self::get_subscribers($item);
- Sendmail::factory()
- ->to($users)
- ->from("from@gallery3.com")
- ->subject(t("Item added to Gallery3"))
- ->message($item->title)
- ->send();
+ $body = new View("item_added.html");
+ $body->subject = sprintf(t("Item added to %s"), $item->parent()->title);
+ $body->parent_title = $item->parent()->title;
+ $body->type = $item->type;
+ $body->item_title = $item->title;
+ $body->description = $item->description;
+ $body->url = url::site("{$item->type}s/$item->id", "http");
+
+ self::_send_message($item, $body);
}
static function send_item_delete($item) {
- $users = self::get_subscribers($item);
- Sendmail::factory()
- ->to($users)
- ->from("from@gallery3.com")
- ->subject("Item deleted: $item->title")
- ->message("It was deleted")
- ->send();
+ $body = new View("item_deleted.html");
+ $body->subject = sprintf(t("Item deleted from %s"), $item->parent()->title);
+
+ self::_send_message($item, $body);
}
static function send_comment_added($comment) {
- $users = self::get_subscribers($comment->item());
- Sendmail::factory()
- ->to($users)
- ->from("from@gallery3.com")
- ->subject("Comment added to $comment->$item->title")
- ->message($comment->text)
- ->send();
+ $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) {
- $users = self::get_subscribers($comment->item());
- Sendmail::factory()
- ->to($users)
- ->from("from@gallery3.com")
- ->subject("Comment updated on item: $comment->$item-title")
- ->message($new->text)
- ->send();
+ $body = new View("comment_changed.html");
+ $body->subject = sprintf(t("Comment changed on %s"), $old->item()->title);
+
+ self::_send_message($old->item(), $body);
}
+ private 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();
+ }
}
diff --git a/modules/notification/helpers/notification_event.php b/modules/notification/helpers/notification_event.php
index 415093a5..e7c7aac1 100644
--- a/modules/notification/helpers/notification_event.php
+++ b/modules/notification/helpers/notification_event.php
@@ -19,7 +19,7 @@
*/
class notification_event_Core {
static function item_updated($old, $new) {
- notification::send_item_changed($old, $new);
+ notification::send_item_updated($old, $new);
}
static function item_created($item) {
diff --git a/modules/notification/views/comment_added.html.php b/modules/notification/views/comment_added.html.php
new file mode 100644
index 00000000..e69de29b
diff --git a/modules/notification/views/comment_changed.html.php b/modules/notification/views/comment_changed.html.php
new file mode 100644
index 00000000..e69de29b
diff --git a/modules/notification/views/item_added.html.php b/modules/notification/views/item_added.html.php
new file mode 100644
index 00000000..1832fb39
--- /dev/null
+++ b/modules/notification/views/item_added.html.php
@@ -0,0 +1,25 @@
+
+
+
+ = $subject ?>
+
+
+ = sprintf(t("A new %s was added to %s"), $type, $parent_title); ?>
+
+
+ | = t("Title:") ?> |
+ = $item_title ?> |
+
+
+ | = t("Url:") ?> |
+ = $url ?> |
+
+ if (!empty($description)): ?>
+
+ | = t("Description:") ?> |
+ = $description ?> |
+
+ endif ?>
+
+
+
diff --git a/modules/notification/views/item_deleted.html.php b/modules/notification/views/item_deleted.html.php
new file mode 100644
index 00000000..e69de29b
diff --git a/modules/notification/views/item_updated.html.php b/modules/notification/views/item_updated.html.php
new file mode 100644
index 00000000..126bd5cc
--- /dev/null
+++ b/modules/notification/views/item_updated.html.php
@@ -0,0 +1,36 @@
+
+
+
+ = $subject ?>
+
+
+ = sprintf(t("%s %s was updated"), ucfirst($type), $item_title); ?>
+
+
+ if (!empty($new_title)): ?>
+ | = t("New Title:") ?> |
+ = $new_title ?> |
+ else: ?>
+ = t("Title:") ?> |
+ = $item_title ?> |
+ endif ?>
+
+
+ | = t("Url:") ?> |
+ = $url ?> |
+
+ if (!empty($new_description)): ?>
+
+ | = t("New Description:") ?> |
+ = $new_description ?> |
+
+ else: if (!empty($description)): ?>
+
+ | = t("Description:") ?> |
+ = $description ?> |
+
+ endif ?>
+ endif ?>
+
+
+