diff options
| author | Bharat Mediratta <bharat@menalto.com> | 2009-01-04 22:58:18 +0000 |
|---|---|---|
| committer | Bharat Mediratta <bharat@menalto.com> | 2009-01-04 22:58:18 +0000 |
| commit | 3381f1d01a09a3846dd8984f6fbf6f8eeb40a5b1 (patch) | |
| tree | c92f4bced98e93e7c39aa0440e4c075eb51ac27e /modules/tag/controllers | |
| parent | 99804a34b2440589e91d5fe06f8b39b44d6561f2 (diff) | |
Put up an error if you try to reuse an existing tag name
Diffstat (limited to 'modules/tag/controllers')
| -rw-r--r-- | modules/tag/controllers/admin_tags.php | 14 |
1 files changed, 12 insertions, 2 deletions
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)); |
