From 5713e3c66ed8bab3b86490d7b6e90f7947d53429 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 23 Dec 2008 04:36:09 +0000 Subject: Change photo::create() and album::create() to take ORM instances instead of ids. --- core/helpers/album.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'core/helpers/album.php') diff --git a/core/helpers/album.php b/core/helpers/album.php index 53af0079..70b05006 100644 --- a/core/helpers/album.php +++ b/core/helpers/album.php @@ -32,7 +32,11 @@ 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, $owner_id=null) { + static function create($parent, $name, $title, $description=null, $owner_id=null) { + if (!$parent->loaded || $parent->type != "album") { + throw new Exception("@todo INVALID_PARENT"); + } + $album = ORM::factory("item"); $album->type = "album"; $album->title = $title; @@ -43,17 +47,12 @@ class album_Core { $album->resize_dirty = 1; while (ORM::factory("item") - ->where("parent_id", $parent_id) + ->where("parent_id", $parent->id) ->where("name", $album->name) ->find()->id) { $album->name = "{$name}-" . rand(); } - $parent = ORM::factory("item", $parent_id); - if (!$parent->loaded) { - throw new Exception("@todo INVALID_PARENT_ID"); - } - $album = $album->add_to_parent($parent); mkdir($album->file_path()); mkdir(dirname($album->thumb_path())); -- cgit v1.2.3