From a9e3692027dc767b340242ed18fe7184cbfd883d Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 21 May 2009 01:31:29 +0000 Subject: 1) This provides the editting functionality for albums and photos in the organize feature. 2) Remove the tag functionality at this point 3) Added a callback to handle validating conflicting names (only used by organize at this point. 4) Closes #231 --- core/helpers/item.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'core/helpers/item.php') diff --git a/core/helpers/item.php b/core/helpers/item.php index 8ff09535..7daaf1e1 100644 --- a/core/helpers/item.php +++ b/core/helpers/item.php @@ -79,9 +79,27 @@ class item_Core { } } - static function validate_no_trailing_period($input) { + static function validate_no_trailing_period($input) { if (rtrim($input->value, ".") !== $input->value) { $input->add_error("no_trailing_period", 1); } } + + static function validate_no_name_conflict($input) { + $itemid = Input::instance()->post("item"); + if (is_array($itemid)) { + $itemid = $itemid[0]; + } + $item = ORM::factory("item") + ->in("id", $itemid) + ->find(); + if (Database::instance() + ->from("items") + ->where("parent_id", $item->parent_id) + ->where("id <>", $item->id) + ->where("name", $input->value) + ->count_records()) { + $input->add_error("conflict", 1); + } + } } \ No newline at end of file -- cgit v1.2.3