diff options
author | Bharat Mediratta <bharat@menalto.com> | 2008-11-08 07:48:36 +0000 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2008-11-08 07:48:36 +0000 |
commit | 418c0aab69a72da512646541be2d88a866cb9fdb (patch) | |
tree | fea9ea900fbf33d3e94082b901922ad74b832f50 /modules | |
parent | ea7cc4f46edc730ff873c579a6c63490d24496a6 (diff) |
Create permanent owner_id column in the item table, and use a soft
relationship to bind the two. To do this, I overrode __get in
Item_Model so that $item->owner returns the appropriate User_Model.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/info/views/info_block.html.php | 12 | ||||
-rw-r--r-- | modules/user/helpers/user_installer.php | 10 |
2 files changed, 10 insertions, 12 deletions
diff --git a/modules/info/views/info_block.html.php b/modules/info/views/info_block.html.php index 543ce3db..3fa9350f 100644 --- a/modules/info/views/info_block.html.php +++ b/modules/info/views/info_block.html.php @@ -2,21 +2,23 @@ <table class="gMetadata"> <tbody> <tr> - <th>Title:</th> + <th><?= _("Title:") ?></th> <td><?= $item->title; ?></td> </tr> <tr> - <th>Description:</th> + <th><?= _("Description:") ?></th> <td><?= $item->description; ?></td> </tr> <tr> - <th>Name:</th> + <th><?= _("Name:") ?></th> <td><?= $item->name; ?></td> </tr> + <? if ($item->owner): ?> <tr> - <th>Owner:</th> - <td><a href="#"><?= isset($item->user_id) ? $item->user->name : "anonymous"?></a></td> + <th><?= _("Owner:") ?></th> + <td><a href="#"><?= $item->owner->name ?></a></td> </tr> + <? endif ?> <tr> <td colspan="2" class="toggle"> <a href="#">more \/</a> diff --git a/modules/user/helpers/user_installer.php b/modules/user/helpers/user_installer.php index 82221f10..93f36d99 100644 --- a/modules/user/helpers/user_installer.php +++ b/modules/user/helpers/user_installer.php @@ -19,7 +19,7 @@ */ class user_installer { protected $has_many = array('items'); - + public static function install() { Kohana::log("debug", "user_installer::install"); $db = Database::instance(); @@ -58,8 +58,6 @@ class user_installer { PRIMARY KEY (`group_id`, `user_id`), UNIQUE KEY(`user_id`, `group_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - - $db->query("ALTER TABLE `items` ADD `user_id` INT(9) NULL"); $user_module = ORM::factory("module")->where("name", "user")->find(); $user_module->name = "user"; @@ -71,15 +69,14 @@ class user_installer { $user->display_name = "Gallery Administrator"; $user->save(); $id = $user->id; - $db->query("UPDATE `items` SET `user_id` = $id "); + $db->query("UPDATE `items` SET `owner_id` = $id WHERE `owner_id` IS NULL"); foreach (array("administrator", "registered") as $group_name) { $group = ORM::factory("group")->where("name", $group_name)->find(); $group->name = $group_name; $group->save(); if (!$group->add($user)) { - /** @todo replace this by throwing an exception once exceptions are implemented */ - Kohana::Log("debug", "{$user->name} was not added to {$group_name}"); + throw new Exception("@todo {$user->name} WAS_NOT_ADDED_TO {$group_name}"); } } } @@ -87,7 +84,6 @@ class user_installer { public static function uninstall() { $db = Database::instance(); - $db->query("ALTER TABLE `items` DROP `user_id`"); $db->query("DROP TABLE IF EXISTS `users`;"); $db->query("DROP TABLE IF EXISTS `groups`;"); $db->query("DROP TABLE IF EXISTS `groups_users`;"); |