summaryrefslogtreecommitdiff
path: root/core/helpers
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2008-12-07 08:46:44 +0000
committerBharat Mediratta <bharat@menalto.com>2008-12-07 08:46:44 +0000
commitbf7ab8904aa9ccbb201b1ef9634a8b13834e5f6d (patch)
treed62ae674a2a81696420ef293b0a033605c84da02 /core/helpers
parente40b54a4689f1565e0f76c536d0d4b05b23afc1e (diff)
Change ORM_MPTT::add_to_parent() to take an ORM instead of an id so
that it's consistent with ORM_MPTT::move_to()
Diffstat (limited to 'core/helpers')
-rw-r--r--core/helpers/album.php7
-rw-r--r--core/helpers/photo.php9
2 files changed, 13 insertions, 3 deletions
diff --git a/core/helpers/album.php b/core/helpers/album.php
index 3e3b6054..83bbfbab 100644
--- a/core/helpers/album.php
+++ b/core/helpers/album.php
@@ -47,7 +47,12 @@ class album_Core {
$album->name = "{$name}-" . rand();
}
- $album = $album->add_to_parent($parent_id);
+ $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());
$thumbnail_dir = dirname($album->thumbnail_path());
if (!file_exists($thumbnail_dir)) {
diff --git a/core/helpers/photo.php b/core/helpers/photo.php
index 6d9887a4..0c098c84 100644
--- a/core/helpers/photo.php
+++ b/core/helpers/photo.php
@@ -69,7 +69,12 @@ class photo_Core {
}
// This saves the photo
- $photo->add_to_parent($parent_id);
+ $parent = ORM::factory("item", $parent_id);
+ if (!$parent->loaded) {
+ throw new Exception("@todo INVALID_PARENT_ID");
+ }
+
+ $photo->add_to_parent($parent);
copy($filename, $photo->file_path());
// @todo: parameterize these dimensions
@@ -84,7 +89,7 @@ class photo_Core {
}
static function get_add_form($parent) {
- $form = new Forge("albums/{$parent->id}", "", "post",
+ $form = new Forge("albums/{$parent->id}", "", "post",
array("id" => "gAddPhotoForm", "enctype" => "multipart/form-data"));
$group = $form->group(sprintf(_("Add Photo to %s"), $parent->title));
$group->input("name")->label(true);