diff options
| author | Bharat Mediratta <bharat@menalto.com> | 2008-11-26 04:13:57 +0000 |
|---|---|---|
| committer | Bharat Mediratta <bharat@menalto.com> | 2008-11-26 04:13:57 +0000 |
| commit | 5ccb050413c15b4c16a20b2806886759332a90a7 (patch) | |
| tree | 75928903df082c8a43b51e42c384f7dc39ca16c8 /modules/user/helpers/group.php | |
| parent | 242b3a1403aec688f82024adfa0ca20b25981a60 (diff) | |
group::create() and group::delete() now manage the view_## columns in
the items table.
Convert installer over to using new creation API.
Diffstat (limited to 'modules/user/helpers/group.php')
| -rw-r--r-- | modules/user/helpers/group.php | 12 |
1 files changed, 11 insertions, 1 deletions
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 |
