diff options
author | Felix Rabinovich <virshu@users.sourceforge.net> | 2008-11-08 07:18:56 +0000 |
---|---|---|
committer | Felix Rabinovich <virshu@users.sourceforge.net> | 2008-11-08 07:18:56 +0000 |
commit | 28b739a2105cba83f877d4fc4022d710b920b5a7 (patch) | |
tree | e814afda14126e1ae3160d07040f90042c42a8cd /core | |
parent | 3bb9b9185cb9445157ab20df9178f9a892a0bbe0 (diff) |
Adding user (owner) to items; info module
Diffstat (limited to 'core')
-rw-r--r-- | core/controllers/welcome.php | 11 | ||||
-rw-r--r-- | core/helpers/album.php | 3 | ||||
-rw-r--r-- | core/helpers/photo.php | 3 | ||||
-rw-r--r-- | core/models/item.php | 1 |
4 files changed, 14 insertions, 4 deletions
diff --git a/core/controllers/welcome.php b/core/controllers/welcome.php index 8bf5138a..b411e314 100644 --- a/core/controllers/welcome.php +++ b/core/controllers/welcome.php @@ -91,15 +91,22 @@ class Welcome_Controller extends Template_Controller { function add($count) { srand(time()); $parents = ORM::factory("item")->where("type", "album")->find_all()->as_array(); + $user_module = ORM::factory("module")->where("name", "user")->find(); + + if ($user_module->loaded) { + $user_id = ORM::factory("user")->find()->id; + } else { + $user_id = null; + } for ($i = 0; $i < $count; $i++) { $parent = $parents[array_rand($parents)]; if (!rand(0, 10)) { - $parents[] = album::create($parent->id, "rnd_" . rand(), "Rnd $i", "rnd $i") + $parents[] = album::create($parent->id, "rnd_" . rand(), "Rnd $i", "rnd $i", "random album $i", $user_id) ->set_thumbnail(DOCROOT . "core/tests/test.jpg", 200, 150) ->save(); } else { photo::create($parent->id, DOCROOT . "themes/default/images/thumbnail.jpg", - "thumbnail.jpg", "rnd_" . rand(), "sample thumbnail"); + "thumbnail.jpg", "rnd_" . rand(), "sample thumbnail", $user_id); } if (!($i % 100)) { diff --git a/core/helpers/album.php b/core/helpers/album.php index 021c09f3..3c97f7e8 100644 --- a/core/helpers/album.php +++ b/core/helpers/album.php @@ -32,12 +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) { + static function create($parent_id, $name, $title, $description=null, $user_id = null) { $album = ORM::factory("item"); $album->type = "album"; $album->title = $title; $album->description = $description; $album->name = $name; + $album->user_id = $user_id; while (ORM::Factory("item") ->where("parent_id", $parent_id) diff --git a/core/helpers/photo.php b/core/helpers/photo.php index ef94f52b..231e3a9c 100644 --- a/core/helpers/photo.php +++ b/core/helpers/photo.php @@ -33,12 +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) { + static function create($parent_id, $filename, $name, $title, $description=null, $user_id = null) { $photo = ORM::factory("item"); $photo->type = "photo"; $photo->title = $title; $photo->description = $description; $photo->name = $name; + $photo->user_id = $user_id; $pi = pathinfo(basename($filename)); if (empty($pi["extension"])) { diff --git a/core/models/item.php b/core/models/item.php index 3a9faea0..c8d8d1e2 100644 --- a/core/models/item.php +++ b/core/models/item.php @@ -19,6 +19,7 @@ */ class Item_Model extends ORM_MPTT { protected $children = 'items'; + protected $has_one = array('user'); /** * Is this item an album? |