diff options
Diffstat (limited to 'modules/tag')
| -rw-r--r-- | modules/tag/controllers/admin_tags.php | 14 | ||||
| -rw-r--r-- | modules/tag/helpers/tag.php | 1 | 
2 files changed, 13 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)); diff --git a/modules/tag/helpers/tag.php b/modules/tag/helpers/tag.php index fac2ab70..897d4d13 100644 --- a/modules/tag/helpers/tag.php +++ b/modules/tag/helpers/tag.php @@ -89,6 +89,7 @@ class tag_Core {      $form = new Forge("admin/tags/rename/$tag->id", "", "post", array("id" => "gRenameTagForm"));      $group = $form->group("rename_tag")->label(_("Rename Tag"));      $group->input("name")->label(_("Tag name"))->value($tag->name); +    $group->inputs["name"]->error_messages("in_use", _("There is already a tag with that name"));      $group->submit(_("Rename"));      $form->add_rules_from(ORM::factory("tag"));      return $form;  | 
