diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-11-01 10:22:56 -0800 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-11-01 10:22:56 -0800 |
commit | 376eb5673fd9cbc06abf308a04f83231de1a1d11 (patch) | |
tree | f240f33cc832a5bea3836a39334b7d56b06784d2 /modules/gallery/helpers | |
parent | 808fd4d3a0f38a2ea80bb8d56e1f8c6ce499e42d (diff) |
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.
Diffstat (limited to 'modules/gallery/helpers')
-rw-r--r-- | modules/gallery/helpers/gallery_event.php | 28 |
1 files changed, 24 insertions, 4 deletions
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) { |