From 6dbf5ae172e8336caa0971024ffdfa0148bcf718 Mon Sep 17 00:00:00 2001 From: Felix Rabinovich Date: Sat, 15 Nov 2008 08:19:14 +0000 Subject: Clean user / item relationship. Upload files gets the ownership of current user; and the views don't break if user module is not installed --- core/models/item.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'core/models') diff --git a/core/models/item.php b/core/models/item.php index 7209a46a..b592b706 100644 --- a/core/models/item.php +++ b/core/models/item.php @@ -19,7 +19,14 @@ */ class Item_Model extends ORM_MPTT { protected $children = 'items'; - protected $has_one = array('owner' => 'user'); + + function __construct($id) { + parent::__construct($id); + $module = ORM::factory("module")->where("name", 'user')->find(); + if ($module->loaded) { + $this->has_one = array('owner' => 'user'); + } + } /** * Is this item an album? -- cgit v1.2.3