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/gallery/helpers/gallery_event.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'modules/gallery/helpers/gallery_event.php') 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); } -- 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/gallery/helpers/gallery_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 c3dcfd136bea8ec4b627a7d38f618ac97c9ea4a0 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 31 Oct 2009 14:41:55 -0700 Subject: Move the identity provider menu item under the settings menu and make the User/Groups administration a first level menu item. As discussed via -devel mailing list. --- modules/gallery/helpers/gallery_event.php | 13 +++++-------- modules/user/helpers/user_event.php | 9 ++++----- 2 files changed, 9 insertions(+), 13 deletions(-) (limited to 'modules/gallery/helpers/gallery_event.php') diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index f3ad1630..582e3267 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -179,7 +179,11 @@ class gallery_event_Core { ->append(Menu::factory("link") ->id("advanced") ->label(t("Advanced")) - ->url(url::site("admin/advanced_settings")))) + ->url(url::site("admin/advanced_settings"))) + ->append(Menu::factory("link") + ->id("identity_drivers") + ->label(t("Identity drivers")) + ->url(url::site("admin/identity")))) ->append(Menu::factory("link") ->id("modules") ->label(t("Modules")) @@ -202,13 +206,6 @@ class gallery_event_Core { ->id("sidebar") ->label(t("Manage sidebar")) ->url(url::site("admin/sidebar")))) - ->append(Menu::factory("submenu") - ->id("identity_menu") - ->label(t("Identity management")) - ->append(Menu::factory("link") - ->id("identity_drivers") - ->label(t("Identity drivers")) - ->url(url::site("admin/identity")))) ->append(Menu::factory("submenu") ->id("statistics_menu") ->label(t("Statistics"))) diff --git a/modules/user/helpers/user_event.php b/modules/user/helpers/user_event.php index e3dbacb7..11b9c56c 100644 --- a/modules/user/helpers/user_event.php +++ b/modules/user/helpers/user_event.php @@ -20,11 +20,10 @@ class user_event_Core { static function admin_menu($menu, $theme) { - $menu->get("identity_menu") - ->append(Menu::factory("link") - ->id("users_groups") - ->label(t("Users/Groups")) - ->url(url::site("admin/users"))); + $menu->add_after("appearance_menu", Menu::factory("link") + ->id("users_groups") + ->label(t("Users/Groups")) + ->url(url::site("admin/users"))); return $menu; } -- cgit v1.2.3