summaryrefslogtreecommitdiff
path: root/core/models
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2008-11-08 07:48:36 +0000
committerBharat Mediratta <bharat@menalto.com>2008-11-08 07:48:36 +0000
commit418c0aab69a72da512646541be2d88a866cb9fdb (patch)
treefea9ea900fbf33d3e94082b901922ad74b832f50 /core/models
parentea7cc4f46edc730ff873c579a6c63490d24496a6 (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 'core/models')
-rw-r--r--core/models/item.php25
1 files changed, 24 insertions, 1 deletions
diff --git a/core/models/item.php b/core/models/item.php
index c8d8d1e2..a32becc9 100644
--- a/core/models/item.php
+++ b/core/models/item.php
@@ -19,7 +19,8 @@
*/
class Item_Model extends ORM_MPTT {
protected $children = 'items';
- protected $has_one = array('user');
+
+ private $owner = null;
/**
* Is this item an album?
@@ -166,4 +167,26 @@ class Item_Model extends ORM_MPTT {
}
return $path;
}
+
+ /**
+ * @see ORM::reload
+ */
+ function reload() {
+ $this->owner = null;
+ return parent::reload();
+ }
+
+ /**
+ * @see ORM::__get()
+ */
+ public function __get($column) {
+ if ($column == "owner") {
+ if (!isset($this->owner)) {
+ $this->owner = ORM::factory("user", $this->owner_id);
+ }
+ return $this->owner;
+ } else {
+ return parent::__get($column);
+ }
+ }
}