From a11bf295078656612603c1c561e9261555d0c40c Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 9 Jan 2010 23:57:16 -0800 Subject: Fix for ticket #972 and more. In Kohana 2.4, ORM::delete_all ignores any where clauses and deletes all the entries in the table unless an array of id's are passed as the parameter. This fix used the Database_builder to specify any where conditions. Thanks psvo for find the first one. :-) --- modules/notification/helpers/notification_event.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'modules/notification/helpers') diff --git a/modules/notification/helpers/notification_event.php b/modules/notification/helpers/notification_event.php index 2c7ede27..bc1303f5 100644 --- a/modules/notification/helpers/notification_event.php +++ b/modules/notification/helpers/notification_event.php @@ -89,9 +89,10 @@ class notification_event_Core { static function user_before_delete($user) { try { - ORM::factory("subscription") + db::build() + ->delete("subscriptions") ->where("user_id", "=", $user->id) - ->delete_all(); + ->execute(); } catch (Exception $e) { Kohana_Log::add("error", "@todo notification_event::user_before_delete() failed"); Kohana_Log::add("error", $e->getMessage() . "\n" . $e->getTraceAsString()); -- cgit v1.2.3 From 639f1e741a5c9c96db1ab894cea7aa90cad82dbc Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 12 Jan 2010 11:42:31 -0800 Subject: Put quotes around the item titles in all the messages and more importantly actually display the original's title properly. Fixes ticket #966, but does now show us ticket #978 --- modules/notification/helpers/notification.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'modules/notification/helpers') diff --git a/modules/notification/helpers/notification.php b/modules/notification/helpers/notification.php index e9fc3f33..a2271b59 100644 --- a/modules/notification/helpers/notification.php +++ b/modules/notification/helpers/notification.php @@ -101,10 +101,10 @@ class notification { $v = new View("item_updated.html"); $v->item = $item; $v->subject = $item->is_album() ? - t("Album %title updated", array("title" => $item->original("title"))) : + t("Album \"%title\" updated", array("title" => $item->original()->title)) : ($item->is_photo() ? - t("Photo %title updated", array("title" => $item->original("title"))) - : t("Movie %title updated", array("title" => $item->original("title")))); + t("Photo \"%title\" updated", array("title" => $item->original()->title)) + : t("Movie \"%title\" updated", array("title" => $item->original()->title))); self::_notify($subscribers, $item, $v->render(), $v->subject); } @@ -119,12 +119,12 @@ class notification { $v = new View("item_added.html"); $v->item = $item; $v->subject = $item->is_album() ? - t("Album %title added to %parent_title", + t("Album \"%title\" added to \"%parent_title\"", array("title" => $item->title, "parent_title" => $parent->title)) : ($item->is_photo() ? - t("Photo %title added to %parent_title", + t("Photo \"%title\" added to \"%parent_title\"", array("title" => $item->title, "parent_title" => $parent->title)) : - t("Movie %title added to %parent_title", + t("Movie \"%title\" added to \"%parent_title\"", array("title" => $item->title, "parent_title" => $parent->title))); self::_notify($subscribers, $item, $v->render(), $v->subject); @@ -140,12 +140,12 @@ class notification { $v = new View("item_deleted.html"); $v->item = $item; $v->subject = $item->is_album() ? - t("Album %title removed from %parent_title", + t("Album \"%title\" removed from \"%parent_title\"", array("title" => $item->title, "parent_title" => $parent->title)) : ($item->is_photo() ? - t("Photo %title removed from %parent_title", + t("Photo \"%title\" removed from \"%parent_title\"", array("title" => $item->title, "parent_title" => $parent->title)) - : t("Movie %title removed from %parent_title", + : t("Movie \"%title\" removed from \"%parent_title\"", array("title" => $item->title, "parent_title" => $parent->title))); self::_notify($subscribers, $item, $v->render(), $v->subject); @@ -161,10 +161,10 @@ class notification { $v = new View("comment_published.html"); $v->comment = $comment; $v->subject = $item->is_album() ? - t("A new comment was published for album %title", array("title" => $item->title)) : + t("A new comment was published for album \"%title\"", array("title" => $item->title)) : ($item->is_photo() ? - t("A new comment was published for photo %title", array("title" => $item->title)) - : t("A new comment was published for movie %title", array("title" => $item->title))); + t("A new comment was published for photo \"%title\"", array("title" => $item->title)) + : t("A new comment was published for movie \"%title\"", array("title" => $item->title))); self::_notify($subscribers, $item, $v->render(), $v->subject); } -- cgit v1.2.3 From 9f03d36d6ee5358b3081f64fc7ef0b0ae42d97db Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 16 Jan 2010 00:10:55 -0800 Subject: Don't use MY_ORM::original() here since the values may not have changed since the last save. Instead, use the original ORM passed in. --- modules/notification/helpers/notification.php | 11 +++++++---- modules/notification/helpers/notification_event.php | 3 ++- modules/notification/views/item_updated.html.php | 4 ++-- 3 files changed, 11 insertions(+), 7 deletions(-) (limited to 'modules/notification/helpers') diff --git a/modules/notification/helpers/notification.php b/modules/notification/helpers/notification.php index a2271b59..dfeab9fc 100644 --- a/modules/notification/helpers/notification.php +++ b/modules/notification/helpers/notification.php @@ -92,19 +92,22 @@ class notification { return array_keys($subscribers); } - static function send_item_updated($item) { + static function send_item_updated($original, $item) { $subscribers = self::get_subscribers($item); if (!$subscribers) { return; } $v = new View("item_updated.html"); + $v->original = $original; $v->item = $item; $v->subject = $item->is_album() ? - t("Album \"%title\" updated", array("title" => $item->original()->title)) : + t("Album \"%title\" updated", array("title" => $original->title)) : ($item->is_photo() ? - t("Photo \"%title\" updated", array("title" => $item->original()->title)) - : t("Movie \"%title\" updated", array("title" => $item->original()->title))); + t("Photo \"%title\" updated", array("title" => $original->title)) + : t("Movie \"%title\" updated", array("title" => $original->title))); + + Kohana_Log::add("error",print_r($v->render(),1)); self::_notify($subscribers, $item, $v->render(), $v->subject); } diff --git a/modules/notification/helpers/notification_event.php b/modules/notification/helpers/notification_event.php index bc1303f5..76afac9c 100644 --- a/modules/notification/helpers/notification_event.php +++ b/modules/notification/helpers/notification_event.php @@ -22,8 +22,9 @@ class notification_event_Core { // don't want to screw up the processing that was generating the notification // so we don't pass the exception up the call stack static function item_updated($original, $new) { + Kohana_Log::add("error",print_r("item_updated({$original->title}, {$new->title})",1)); try { - notification::send_item_updated($new); + notification::send_item_updated($original, $new); } catch (Exception $e) { Kohana_Log::add("error", "@todo notification_event::item_updated() failed"); Kohana_Log::add("error", $e->getMessage() . "\n" . $e->getTraceAsString()); diff --git a/modules/notification/views/item_updated.html.php b/modules/notification/views/item_updated.html.php index 47856cab..7020fd53 100644 --- a/modules/notification/views/item_updated.html.php +++ b/modules/notification/views/item_updated.html.php @@ -7,7 +7,7 @@

- original("title") != $item->title): ?> + title != $item->title): ?> @@ -19,7 +19,7 @@ - original("description") != $item->description): ?> + description != $item->description): ?> -- cgit v1.2.3 From 2c2c77ea391a59f89449d07aff604bf11042515c Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 16 Jan 2010 00:19:35 -0800 Subject: Remove debug code. --- modules/notification/helpers/notification_event.php | 1 - 1 file changed, 1 deletion(-) (limited to 'modules/notification/helpers') diff --git a/modules/notification/helpers/notification_event.php b/modules/notification/helpers/notification_event.php index 76afac9c..edbf6e39 100644 --- a/modules/notification/helpers/notification_event.php +++ b/modules/notification/helpers/notification_event.php @@ -22,7 +22,6 @@ class notification_event_Core { // don't want to screw up the processing that was generating the notification // so we don't pass the exception up the call stack static function item_updated($original, $new) { - Kohana_Log::add("error",print_r("item_updated({$original->title}, {$new->title})",1)); try { notification::send_item_updated($original, $new); } catch (Exception $e) { -- cgit v1.2.3
title) ?> abs_url() ?>
description) ?>