From 3381f1d01a09a3846dd8984f6fbf6f8eeb40a5b1 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 4 Jan 2009 22:58:18 +0000 Subject: Put up an error if you try to reuse an existing tag name --- modules/tag/controllers/admin_tags.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'modules/tag/controllers') diff --git a/modules/tag/controllers/admin_tags.php b/modules/tag/controllers/admin_tags.php index 6199aebb..7370fb42 100644 --- a/modules/tag/controllers/admin_tags.php +++ b/modules/tag/controllers/admin_tags.php @@ -81,9 +81,19 @@ class Admin_Tags_Controller extends Admin_Controller { } $form = tag::get_rename_form($tag); - if ($form->validate()) { + $valid = $form->validate(); + if ($valid) { + $new_name = $form->rename_tag->inputs["name"]->value; + $new_tag = ORM::factory("tag")->where("name", $new_name)->find(); + if ($new_tag->loaded) { + $form->rename_tag->inputs["name"]->add_error("in_use", 1); + $valid = false; + } + } + + if ($valid) { $old_name = $tag->name; - $tag->name = $form->rename_tag->inputs["name"]->value; + $tag->name = $new_name; $tag->save(); message::success(sprintf(_("Renamed tag %s to %s"), $old_name, $tag->name)); -- cgit v1.2.3