summaryrefslogtreecommitdiff
path: root/modules/notification
diff options
context:
space:
mode:
Diffstat (limited to 'modules/notification')
-rw-r--r--modules/notification/helpers/notification.php19
-rw-r--r--modules/notification/helpers/notification_event.php24
-rw-r--r--modules/notification/helpers/notification_installer.php1
-rw-r--r--modules/notification/views/batch_add.html.php11
4 files changed, 52 insertions, 3 deletions
diff --git a/modules/notification/helpers/notification.php b/modules/notification/helpers/notification.php
index 1048d094..4a644812 100644
--- a/modules/notification/helpers/notification.php
+++ b/modules/notification/helpers/notification.php
@@ -71,7 +71,7 @@ class notification {
->join("subscriptions", "users.id", "subscriptions.user_id")
->join("items", "subscriptions.item_id", "items.id")
->where("email IS NOT", null)
- ->where("items.left <", $item->left)
+ ->where("items.left <=", $item->left)
->where("items.right >", $item->right)
->find_all();
@@ -113,6 +113,19 @@ class notification {
self::_send_message($item, $body);
}
+ static function send_batch_add($parent_id) {
+ $parent = ORM::factory("item", $parent_id);
+ if ($parent->loaded) {
+ $body = new View("batch_add.html");
+ $body->subject = t("%parent_title Updated",
+ array("parent_title" => $parent->title));
+ $body->parent_title = $parent->title;
+ $body->url = url::site("{$parent->type}s/$parent->id", "http");
+
+ self::_send_message($parent, $body);
+ }
+ }
+
static function send_item_deleted($item) {
$parent = $item->parent();
$body = new View("item_deleted.html");
@@ -148,6 +161,10 @@ class notification {
self::_send_message($item, $body);
}
+ static function process_notifications() {
+ Kohana::log("error", "processing notifications in shutdown");
+ }
+
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 3fccdfbe..df06a2f1 100644
--- a/modules/notification/helpers/notification_event.php
+++ b/modules/notification/helpers/notification_event.php
@@ -23,7 +23,9 @@ class notification_event_Core {
}
static function item_created($item) {
- notification::send_item_add($item);
+ if (!batch::in_progress("add")) {
+ notification::send_item_add($item);
+ }
}
static function item_before_delete($item) {
@@ -51,4 +53,24 @@ class notification_event_Core {
->where("user_id", $user->id)
->delete_all();
}
+
+ static function operation($name, $item) {
+ if ($name == "add") {
+ $id = Session::instance()->get("notification_batch_item_id");
+ if ($id && $item->id != $id) {
+ notification::send_batch_add($id);
+ }
+ Session::instance()->set("notification_batch_item_id", $item->id);
+ }
+ }
+
+ static function end_operation($name) {
+ if ($name == "add") {
+ $id = Session::instance()->get_once("notification_batch_item_id");
+ if ($id) {
+ notification::send_batch_add($id);
+ }
+ }
+ }
+
}
diff --git a/modules/notification/helpers/notification_installer.php b/modules/notification/helpers/notification_installer.php
index dc70d93c..473ae169 100644
--- a/modules/notification/helpers/notification_installer.php
+++ b/modules/notification/helpers/notification_installer.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/batch_add.html.php b/modules/notification/views/batch_add.html.php
new file mode 100644
index 00000000..b13fcf01
--- /dev/null
+++ b/modules/notification/views/batch_add.html.php
@@ -0,0 +1,11 @@
+<?php defined("SYSPATH") or die("No direct script access.") ?>
+<html>
+<head>
+ <title><?= $subject ?> </title>
+</head>
+<body>
+ <h2><?= sprintf(t("New Photos, Movies or Albums have been added to %s."), $parent_title); ?></h2>
+ <p><?= sprintf(t("Click on the link below to view the additions"), $parent_title); ?></p>
+ <p><a href="<?= $url ?>"><?= t(here) ?></a><p>
+</body>
+</html>