From 3e6ba7acc3291f2268cbe9c9bef0a492b557babb Mon Sep 17 00:00:00 2001 From: Chad Kieffer Date: Sun, 4 Oct 2009 00:27:22 -0600 Subject: Renamed most, if not all css selectors from gName to g-name. Moved a few shared images from wind to lib. Deleted unused images in the admin_wind. This will likely break a few ajax features. --- modules/comment/helpers/comment_event.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/comment/helpers/comment_event.php') diff --git a/modules/comment/helpers/comment_event.php b/modules/comment/helpers/comment_event.php index 0234aea9..2199eb7f 100644 --- a/modules/comment/helpers/comment_event.php +++ b/modules/comment/helpers/comment_event.php @@ -36,7 +36,7 @@ class comment_event_Core { ->id("comments") ->label(t("View comments on this item")) ->url("#comments") - ->css_id("gCommentsLink")); + ->css_id("g-comments-link")); } static function item_index_data($item, $data) { -- cgit v1.2.3 From 90465012d18b9d795d315e2fdf0461b39716b0a5 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 30 Oct 2009 14:23:57 -0700 Subject: Patch to clean up loose ends when a user is deleted. * For items and tasks the owner id is set to admin * For notification subscriptions, the subscription is deleted * For comments, I've extracted the user name, email and url and set the guest_name, guest_email and guest_url columns while setting the author_id to identity::guest()->id Fix for ticket #777. --- modules/comment/helpers/comment_event.php | 11 +++++++++++ modules/gallery/helpers/gallery_event.php | 7 +++++++ modules/notification/helpers/notification_event.php | 4 ++++ 3 files changed, 22 insertions(+) (limited to 'modules/comment/helpers/comment_event.php') diff --git a/modules/comment/helpers/comment_event.php b/modules/comment/helpers/comment_event.php index 2199eb7f..f20e1a51 100644 --- a/modules/comment/helpers/comment_event.php +++ b/modules/comment/helpers/comment_event.php @@ -22,6 +22,17 @@ class comment_event_Core { Database::instance()->delete("comments", array("item_id" => $item->id)); } + static function user_deleted($user) { + $guest = identity::guest(); + Database::instance() + ->query("UPDATE {comments} + SET author_id = {$guest->id}, + guest_email = '{$user->email}', + guest_name = '{$user->name}', + guest_url = '{$user->url}' + WHERE author_id = {$user->id}"); + } + static function admin_menu($menu, $theme) { $menu->get("content_menu") ->append(Menu::factory("link") diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 87dee356..7e0382ec 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -28,6 +28,13 @@ class gallery_event_Core { locales::set_request_locale(); } + static function user_deleted($user) { + $admin = identity::admin_user(); + $db = Database::instance(); + $db->query("UPDATE {tasks} SET owner_id = {$admin->id} where owner_id = {$user->id}"); + $db->query("UPDATE {items} SET owner_id = {$admin->id} where owner_id = {$user->id}"); + } + static function group_created($group) { access::add_group($group); } diff --git a/modules/notification/helpers/notification_event.php b/modules/notification/helpers/notification_event.php index 3a369155..e6791071 100644 --- a/modules/notification/helpers/notification_event.php +++ b/modules/notification/helpers/notification_event.php @@ -52,6 +52,10 @@ class notification_event_Core { } } + static function user_deleted($user) { + Database::instance()->query("DELETE FROM {subscriptions} where user_id = {$user->id}"); + } + static function comment_created($comment) { try { if ($comment->state == "published") { -- cgit v1.2.3 From 903b5f6f67faaf8d8b25d8efd279f0ebe669f4d2 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 31 Oct 2009 14:23:05 -0700 Subject: Add identity_change handlers to resolve the ownership issues of comments, subscription, items and tasks. --- modules/comment/helpers/comment_event.php | 16 +++++++++++++--- modules/gallery/helpers/gallery_event.php | 7 +++++++ modules/notification/helpers/notification_event.php | 4 ++++ 3 files changed, 24 insertions(+), 3 deletions(-) (limited to 'modules/comment/helpers/comment_event.php') diff --git a/modules/comment/helpers/comment_event.php b/modules/comment/helpers/comment_event.php index f20e1a51..ddf72e3c 100644 --- a/modules/comment/helpers/comment_event.php +++ b/modules/comment/helpers/comment_event.php @@ -27,12 +27,22 @@ class comment_event_Core { Database::instance() ->query("UPDATE {comments} SET author_id = {$guest->id}, - guest_email = '{$user->email}', - guest_name = '{$user->name}', - guest_url = '{$user->url}' + guest_email = NULL, + guest_name = 'guest', + guest_url = NULL WHERE author_id = {$user->id}"); } + static function identity_provider_changed($old_provider, $new_provider) { + $guest = identity::guest(); + Database::instance() + ->query("UPDATE {comments} + SET author_id = {$guest->id}, + guest_email = NULL, + guest_name = 'guest', + guest_url = null"); + } + static function admin_menu($menu, $theme) { $menu->get("content_menu") ->append(Menu::factory("link") diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 7e0382ec..f3ad1630 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -35,6 +35,13 @@ class gallery_event_Core { $db->query("UPDATE {items} SET owner_id = {$admin->id} where owner_id = {$user->id}"); } + static function identity_provider_changed($old_provider, $new_provider) { + $admin = identity::admin_user(); + $db = Database::instance(); + $db->query("UPDATE {tasks} SET owner_id = {$admin->id}"); + $db->query("UPDATE {items} SET owner_id = {$admin->id}"); + } + static function group_created($group) { access::add_group($group); } diff --git a/modules/notification/helpers/notification_event.php b/modules/notification/helpers/notification_event.php index e6791071..b82e4f0f 100644 --- a/modules/notification/helpers/notification_event.php +++ b/modules/notification/helpers/notification_event.php @@ -56,6 +56,10 @@ class notification_event_Core { Database::instance()->query("DELETE FROM {subscriptions} where user_id = {$user->id}"); } + static function identity_provider_changed($old_provider, $new_provider) { + Database::instance()->query("DELETE FROM {subscriptions}"); + } + static function comment_created($comment) { try { if ($comment->state == "published") { -- cgit v1.2.3 From 376eb5673fd9cbc06abf308a04f83231de1a1d11 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sun, 1 Nov 2009 10:22:56 -0800 Subject: Convert the event handlers for the "identity provider changed" and "user_deleted" events to use ORM or the Kohana query builder to build the database update calls instead of coding the sql directly. --- modules/comment/helpers/comment_event.php | 27 +++++++++++---------- modules/gallery/helpers/gallery_event.php | 28 ++++++++++++++++++---- .../notification/helpers/notification_event.php | 7 ++++-- 3 files changed, 43 insertions(+), 19 deletions(-) (limited to 'modules/comment/helpers/comment_event.php') diff --git a/modules/comment/helpers/comment_event.php b/modules/comment/helpers/comment_event.php index ddf72e3c..a72102b9 100644 --- a/modules/comment/helpers/comment_event.php +++ b/modules/comment/helpers/comment_event.php @@ -24,23 +24,24 @@ class comment_event_Core { static function user_deleted($user) { $guest = identity::guest(); - Database::instance() - ->query("UPDATE {comments} - SET author_id = {$guest->id}, - guest_email = NULL, - guest_name = 'guest', - guest_url = NULL - WHERE author_id = {$user->id}"); + Database::instance()->from("comments") + ->set(array("author_id" => $guest->id, + "guest_email" => null, + "guest_name" => "guest", + "guest_url" => null)) + ->where(array("author_id" => $user->id)) + ->update(); } static function identity_provider_changed($old_provider, $new_provider) { $guest = identity::guest(); - Database::instance() - ->query("UPDATE {comments} - SET author_id = {$guest->id}, - guest_email = NULL, - guest_name = 'guest', - guest_url = null"); + Database::instance()->from("comments") + ->set(array("author_id" => $guest->id, + "guest_email" => null, + "guest_name" => "guest", + "guest_url" => null)) + ->where("1 = 1") + ->update(); } static function admin_menu($menu, $theme) { diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 582e3267..67a6f41f 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -31,15 +31,35 @@ class gallery_event_Core { static function user_deleted($user) { $admin = identity::admin_user(); $db = Database::instance(); - $db->query("UPDATE {tasks} SET owner_id = {$admin->id} where owner_id = {$user->id}"); - $db->query("UPDATE {items} SET owner_id = {$admin->id} where owner_id = {$user->id}"); + $db->from("tasks") + ->set(array("owner_id" => $admin->id)) + ->where(array("owner_id" => $user->id)) + ->update(); + $db->from("items") + ->set(array("owner_id" => $admin->id)) + ->where(array("owner_id" => $user->id)) + ->update(); + $db->from("logs") + ->set(array("user_id" => $admin->id)) + ->where(array("user_id" => $user->id)) + ->update(); } static function identity_provider_changed($old_provider, $new_provider) { $admin = identity::admin_user(); $db = Database::instance(); - $db->query("UPDATE {tasks} SET owner_id = {$admin->id}"); - $db->query("UPDATE {items} SET owner_id = {$admin->id}"); + $db->from("tasks") + ->set(array("owner_id" => $admin->id)) + ->where("1 = 1") + ->update(); + $db->from("items") + ->set(array("owner_id" => $admin->id)) + ->where("1 = 1") + ->update(); + $db->from("logs") + ->set(array("user_id" => $admin->id)) + ->where("1 = 1") + ->update(); } static function group_created($group) { diff --git a/modules/notification/helpers/notification_event.php b/modules/notification/helpers/notification_event.php index b82e4f0f..6b2df574 100644 --- a/modules/notification/helpers/notification_event.php +++ b/modules/notification/helpers/notification_event.php @@ -53,11 +53,14 @@ class notification_event_Core { } static function user_deleted($user) { - Database::instance()->query("DELETE FROM {subscriptions} where user_id = {$user->id}"); + ORM::factory("subscriptions") + ->where(array("user_id", $user->id)) + ->delete_all(); } static function identity_provider_changed($old_provider, $new_provider) { - Database::instance()->query("DELETE FROM {subscriptions}"); + ORM::factory("subscriptions") + ->delete_all(); } static function comment_created($comment) { -- cgit v1.2.3