summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/helpers/album.php4
-rw-r--r--core/helpers/core_installer.php1
-rw-r--r--core/helpers/photo.php4
-rw-r--r--core/models/item.php25
4 files changed, 29 insertions, 5 deletions
diff --git a/core/helpers/album.php b/core/helpers/album.php
index 3c97f7e8..2801c570 100644
--- a/core/helpers/album.php
+++ b/core/helpers/album.php
@@ -32,13 +32,13 @@ class Album_Core {
* @param string $description (optional) the longer description of this album
* @return Item_Model
*/
- static function create($parent_id, $name, $title, $description=null, $user_id = null) {
+ static function create($parent_id, $name, $title, $description=null, $owner_id = null) {
$album = ORM::factory("item");
$album->type = "album";
$album->title = $title;
$album->description = $description;
$album->name = $name;
- $album->user_id = $user_id;
+ $album->owner_id = $owner_id;
while (ORM::Factory("item")
->where("parent_id", $parent_id)
diff --git a/core/helpers/core_installer.php b/core/helpers/core_installer.php
index df194497..a3350f22 100644
--- a/core/helpers/core_installer.php
+++ b/core/helpers/core_installer.php
@@ -53,6 +53,7 @@ class core_installer {
`thumbnail_height` int(9) default NULL,
`resize_width` int(9) default NULL,
`resize_height` int(9) default NULL,
+ `owner_id` int(9) default NULL,
PRIMARY KEY (`id`),
KEY `parent_id` (`parent_id`),
KEY `type` (`type`))
diff --git a/core/helpers/photo.php b/core/helpers/photo.php
index 231e3a9c..44350f2f 100644
--- a/core/helpers/photo.php
+++ b/core/helpers/photo.php
@@ -33,13 +33,13 @@ class Photo_Core {
* @param string $description (optional) the longer description of this photo
* @return Item_Model
*/
- static function create($parent_id, $filename, $name, $title, $description=null, $user_id = null) {
+ static function create($parent_id, $filename, $name, $title, $description=null, $owner_id = null) {
$photo = ORM::factory("item");
$photo->type = "photo";
$photo->title = $title;
$photo->description = $description;
$photo->name = $name;
- $photo->user_id = $user_id;
+ $photo->owner_id = $owner_id;
$pi = pathinfo(basename($filename));
if (empty($pi["extension"])) {
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);
+ }
+ }
}