From db6061096e23e77c4ea895fa3c1bd20d65c6db4c Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 15 Nov 2008 08:44:01 +0000 Subject: Item / Owner changes. * Hardcode the item has_one owner relationship again * Overload User_Model::__get to handle missing owners gracefully * Fix Item_Controller to take the owner_id from the session or from the parent album when adding new albums and photos. --- core/models/item.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'core/models') diff --git a/core/models/item.php b/core/models/item.php index b592b706..485975cb 100644 --- a/core/models/item.php +++ b/core/models/item.php @@ -19,14 +19,7 @@ */ class Item_Model extends ORM_MPTT { protected $children = 'items'; - - function __construct($id) { - parent::__construct($id); - $module = ORM::factory("module")->where("name", 'user')->find(); - if ($module->loaded) { - $this->has_one = array('owner' => 'user'); - } - } + protected $has_one = array("owner" => "user"); /** * Is this item an album? @@ -182,6 +175,14 @@ class Item_Model extends ORM_MPTT { $real_column = substr($column, 0, strlen($column) - 5); return "id}-{$real_column}\">" . "{$this->$real_column}"; + } else if ($column == "owner") { + // This relationship depends on an outside module, which may not be present so handle + // failures gracefully. + try { + return parent::__get($column); + } catch (Exception $e) { + return null; + } } else { return parent::__get($column); } -- cgit v1.2.3