diff options
author | Bharat Mediratta <bharat@menalto.com> | 2008-11-15 08:44:01 +0000 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2008-11-15 08:44:01 +0000 |
commit | db6061096e23e77c4ea895fa3c1bd20d65c6db4c (patch) | |
tree | 68e7becf15c9419e4d712b846d627ebbe118d6fd /core/models | |
parent | 6dbf5ae172e8336caa0971024ffdfa0148bcf718 (diff) |
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.
Diffstat (limited to 'core/models')
-rw-r--r-- | core/models/item.php | 17 |
1 files changed, 9 insertions, 8 deletions
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 "<span class=\"gInPlaceEdit gEditField-{$this->id}-{$real_column}\">" . "{$this->$real_column}</span>"; + } 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); } |