From 5ccb050413c15b4c16a20b2806886759332a90a7 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Wed, 26 Nov 2008 04:13:57 +0000 Subject: group::create() and group::delete() now manage the view_## columns in the items table. Convert installer over to using new creation API. --- modules/user/helpers/group.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'modules/user/helpers/group.php') diff --git a/modules/user/helpers/group.php b/modules/user/helpers/group.php index 95daa767..84272b79 100644 --- a/modules/user/helpers/group.php +++ b/modules/user/helpers/group.php @@ -38,6 +38,10 @@ 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"); + return $group; } @@ -47,6 +51,12 @@ class group_Core { * @param string $name the group name */ static function delete($name) { - ORM::factory("group")->where("name", $name)->find()->delete(); + $group = ORM::factory("group")->where("name", $name)->find(); + + if ($group->loaded) { + // Drop the view column for this group in the items table. + Database::instance()->query("ALTER TABLE `items` DROP `view_{$group->id}`"); + $group->delete(); + } } } \ No newline at end of file -- cgit v1.2.3