From 91c4bda1ec6640abb8b1a585e1fd1f8955d53fd1 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 1 Dec 2008 08:50:00 +0000 Subject: Prototype access control model. There's much left to do, but it's a working implementation. --- modules/user/helpers/group.php | 8 +++----- modules/user/helpers/user_installer.php | 13 ++++++------- 2 files changed, 9 insertions(+), 12 deletions(-) (limited to 'modules/user/helpers') diff --git a/modules/user/helpers/group.php b/modules/user/helpers/group.php index 2e6a3962..12118432 100644 --- a/modules/user/helpers/group.php +++ b/modules/user/helpers/group.php @@ -24,6 +24,7 @@ * Note: by design, this class does not do any permission checking. */ class group_Core { + const EVERYBODY = 0; const REGISTERED_USERS = 1; /** @@ -41,9 +42,7 @@ class group_Core { $group->name = $name; $group->save(); - // Create the view column for this group in the items table. - Database::instance()->query("ALTER TABLE `items` ADD `view_{$group->id}` BOOLEAN DEFAULT 0"); - + module::event("group_created", $group); return $group; } @@ -56,8 +55,7 @@ class group_Core { $group = ORM::factory("group", $id); if ($group->loaded) { - // Drop the view column for this group in the items table. - Database::instance()->query("ALTER TABLE `items` DROP `view_{$group->id}`"); + module::event("group_before_delete", $group); $group->delete(); } } diff --git a/modules/user/helpers/user_installer.php b/modules/user/helpers/user_installer.php index 0f030d0e..58066acd 100644 --- a/modules/user/helpers/user_installer.php +++ b/modules/user/helpers/user_installer.php @@ -66,14 +66,13 @@ class user_installer { } public static function uninstall() { - // Remove all our groups so that we clean up the items table + // Delete all users and groups so that we give other modules an opportunity to clean up + foreach (ORM::factory("user")->find_all() as $user) { + user::delete($user->id); + } + foreach (ORM::factory("group")->find_all() as $group) { - try { - group::delete($group->id); - } catch (Kohana_Database_Exception $e) { - // We may get errors when we try to remove the view columns from the items table. - // Ignore those for now. - } + group::delete($group->id); } try { -- cgit v1.2.3