From 81a6dc26cb9bcbb3a494c2df5ea279788559bd7f Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 4 Mar 2009 03:31:01 +0000 Subject: Send 1 items added notification per batch of items --- .../notification/helpers/notification_event.php | 24 +++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'modules/notification/helpers/notification_event.php') 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); + } + } + } + } -- cgit v1.2.3