summaryrefslogtreecommitdiff
path: root/modules/tag
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-09-21 21:29:13 -0700
committerBharat Mediratta <bharat@menalto.com>2009-09-21 21:29:13 -0700
commite5a78d39ec49332054cbc1a398d7c110e1d9191c (patch)
treec2acb4731a381b7a1b28fa5ed505a76adb23a3ef /modules/tag
parent529ded3388673036314eefd5bfb1cfc0b76f7f9e (diff)
parent33690a32bcf132e5ab470ff77ba23c073ac26271 (diff)
Merge branch 'master' of git@github.com:gallery/gallery3 into bharat_dev
Conflicts: modules/gallery/controllers/albums.php
Diffstat (limited to 'modules/tag')
-rw-r--r--modules/tag/controllers/admin_tags.php15
-rw-r--r--modules/tag/controllers/tags.php5
-rw-r--r--modules/tag/js/tag.js6
3 files changed, 20 insertions, 6 deletions
diff --git a/modules/tag/controllers/admin_tags.php b/modules/tag/controllers/admin_tags.php
index 8b8dde21..63f7957c 100644
--- a/modules/tag/controllers/admin_tags.php
+++ b/modules/tag/controllers/admin_tags.php
@@ -81,15 +81,20 @@ class Admin_Tags_Controller extends Admin_Controller {
kohana::show_404();
}
- $form = tag::get_rename_form($tag);
- $valid = $form->validate();
+ // Don't use a form as the form is dynamically created in the js
+ $post = new Validation($_POST);
+ $post->add_rules("name", "required", "length[1,64]");
+ $valid = $post->validate();
if ($valid) {
- $new_name = $form->rename_tag->inputs["name"]->value;
+ $new_name = $this->input->post("name");
$new_tag = ORM::factory("tag")->where("name", $new_name)->find();
if ($new_tag->loaded) {
- $form->rename_tag->inputs["name"]->add_error("in_use", 1);
+ $error_msg = t("There is already a tag with that name");
$valid = false;
}
+ } else {
+ $error_msg = $post->errors();
+ $error_msg = $error_msg[0];
}
if ($valid) {
@@ -110,7 +115,7 @@ class Admin_Tags_Controller extends Admin_Controller {
} else {
print json_encode(
array("result" => "error",
- "form" => $form->__toString()));
+ "message" => (string) $error_msg));
}
}
}
diff --git a/modules/tag/controllers/tags.php b/modules/tag/controllers/tags.php
index c993e374..1bd6b3cc 100644
--- a/modules/tag/controllers/tags.php
+++ b/modules/tag/controllers/tags.php
@@ -22,7 +22,7 @@ class Tags_Controller extends REST_Controller {
public function _show($tag) {
$page_size = module::get_var("gallery", "page_size", 9);
- $page = $this->input->get("page", "1");
+ $page = (int) $this->input->get("page", "1");
$children_count = $tag->items_count();
$offset = ($page-1) * $page_size;
@@ -43,6 +43,9 @@ class Tags_Controller extends REST_Controller {
}
public function _index() {
+ // Far from perfection, but at least require view permission for the root album
+ $album = ORM::factory("item", 1);
+ access::required("view", $album);
print tag::cloud(30);
}
diff --git a/modules/tag/js/tag.js b/modules/tag/js/tag.js
index aaae9e72..52c695c6 100644
--- a/modules/tag/js/tag.js
+++ b/modules/tag/js/tag.js
@@ -19,6 +19,7 @@ function ajaxify_tag_form() {
function closeEditInPlaceForms() {
// closes currently open inplace edit forms
if ($("#gRenameTagForm").length) {
+ $("#gEditErrorMessage").remove();
var li = $("#gRenameTagForm").parent();
$("#gRenameTagForm").parent().html($("#gRenameTagForm").parent().data("revert"));
li.height("");
@@ -66,6 +67,11 @@ function editInPlace(element) {
$("#gTag-" + data.tag_id).text(data.new_tagname); // update tagname
console.log(data);
window.location.reload();
+ } else if (data.result == "error") {
+ $("#gRenameTagForm #name")
+ .addClass("gError")
+ .focus();
+ $("#gTagAdmin").before("<p id=\"gEditErrorMessage\" class=\"gError\">" + data.message + "</p>");
}
}
});