From 7cc37451f4b7f7fe833fd5d355dab0f2a904d35e Mon Sep 17 00:00:00 2001 From: Jan Koprowski Date: Sat, 12 Sep 2009 20:36:02 +0200 Subject: Forbid from add symbolink link in admin server add. Read ticket #744 for more details. --- modules/server_add/controllers/admin_server_add.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/server_add/controllers/admin_server_add.php b/modules/server_add/controllers/admin_server_add.php index fac2aa44..af9c5b22 100644 --- a/modules/server_add/controllers/admin_server_add.php +++ b/modules/server_add/controllers/admin_server_add.php @@ -34,15 +34,17 @@ class Admin_Server_Add_Controller extends Admin_Controller { $form = $this->_get_admin_form(); $paths = unserialize(module::get_var("server_add", "authorized_paths", "a:0:{}")); if ($form->validate()) { - if (is_readable($form->add_path->path->value)) { + if (is_link($form->add_path->path->value)) { + $form->add_path->path->add_error("is_symlink", 1); + } else if (! is_readable($form->add_path->path->value)) { + $form->add_path->path->add_error("not_readable", 1); + } else { $path = $form->add_path->path->value; $paths[$path] = 1; module::set_var("server_add", "authorized_paths", serialize($paths)); message::success(t("Added path %path", array("path" => $path))); server_add::check_config($paths); url::redirect("admin/server_add"); - } else { - $form->add_path->path->add_error("not_readable", 1); } } @@ -84,9 +86,10 @@ class Admin_Server_Add_Controller extends Admin_Controller { array("id" => "gServerAddAdminForm")); $add_path = $form->group("add_path"); $add_path->input("path")->label(t("Path"))->rules("required") - ->error_messages("not_readable", t("This directory is not readable by the webserver")); + ->error_messages("not_readable", t("This directory is not readable by the webserver")) + ->error_messages("is_symlink", t("Path can not be symbolic link")); $add_path->submit("add")->value(t("Add Path")); return $form; } -} \ No newline at end of file +} -- cgit v1.2.3 From c3f8b623766fe20768fb86c21e8455785b8e9928 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 15 Sep 2009 19:57:12 -0700 Subject: Adjust the text of the symlink error message. --- modules/server_add/controllers/admin_server_add.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/server_add/controllers/admin_server_add.php b/modules/server_add/controllers/admin_server_add.php index af9c5b22..7cd82d60 100644 --- a/modules/server_add/controllers/admin_server_add.php +++ b/modules/server_add/controllers/admin_server_add.php @@ -87,7 +87,7 @@ class Admin_Server_Add_Controller extends Admin_Controller { $add_path = $form->group("add_path"); $add_path->input("path")->label(t("Path"))->rules("required") ->error_messages("not_readable", t("This directory is not readable by the webserver")) - ->error_messages("is_symlink", t("Path can not be symbolic link")); + ->error_messages("is_symlink", t("Symbolic links are not allowed")); $add_path->submit("add")->value(t("Add Path")); return $form; -- cgit v1.2.3 From 548bfc9455c859251d62ba406d1d40135b158f67 Mon Sep 17 00:00:00 2001 From: Jan Koprowski Date: Sun, 13 Sep 2009 07:00:31 +0200 Subject: Autopopulation text form now clear content after getting focus every time. Problem described in #630. --- lib/gallery.form.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/gallery.form.js b/lib/gallery.form.js index e69be326..e1a24290 100644 --- a/lib/gallery.form.js +++ b/lib/gallery.form.js @@ -26,16 +26,23 @@ function shortFormInit(formID) { $(inputID).val(labelValue); } + // Attach event listeners to the input - $(inputID).bind("focus blur", function(e){ + $(inputID).bind("focus", function(e){ var eLabelVal = $(this).siblings("label").html(); var eInputVal = $(this).val(); // Empty input value if it equals it's label if (eLabelVal == eInputVal) { $(this).val(""); + } + }); + + $(inputID).bind("blur", function(e){ + var eLabelVal = $(this).siblings("label").html(); + // Reset the input value if it's empty - } else if ($(this).val() == "") { + if ($(this).val() == "") { $(this).val(eLabelVal); } }); -- cgit v1.2.3 From 8b7e3e6c1a6a708b7b60837c33a895682c7de32f Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 15 Sep 2009 20:21:12 -0700 Subject: Refactor all the short form code to tighten it up, and make it such that the form button is disabled if we're showing the placeholder text. --- lib/gallery.form.js | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/lib/gallery.form.js b/lib/gallery.form.js index e1a24290..67245e60 100644 --- a/lib/gallery.form.js +++ b/lib/gallery.form.js @@ -3,47 +3,45 @@ * * @param shortForms array Array of short form IDs */ -function handleShortFormEvent(shortForms) { - for (var i in shortForms) { - shortFormInit(shortForms[i]); +function handle_short_form_event(short_forms) { + for (var i in short_forms) { + short_form_init(short_forms[i]); } } /** * Initialize a short form. Short forms may contain only one text input. * - * @param formID string The form's ID, including # + * @param form_id string The form's CSS id */ -function shortFormInit(formID) { - $(formID).addClass("gShortForm"); +function short_form_init(form_id) { + var form = $(form_id); + form.addClass("gShortForm"); - // Get the input ID and it's label text - var labelValue = $(formID + " label:first").html(); - var inputID = "#" + $(formID + " input[type=text]:first").attr("id"); + var label = form.find("label:first"); + var input = form.find("input[type=text]:first"); + var button = form.find("input[type=submit]"); // Set the input value equal to label text - if ($(inputID).val() == "") { - $(inputID).val(labelValue); + if (input.val() == "") { + input.val(label.html()); + button.enable(false); } - // Attach event listeners to the input - $(inputID).bind("focus", function(e){ - var eLabelVal = $(this).siblings("label").html(); - var eInputVal = $(this).val(); - + input.bind("focus", function(e) { // Empty input value if it equals it's label - if (eLabelVal == eInputVal) { - $(this).val(""); + if ($(this).val() == label.html()) { + $(this).val(""); } + button.enable(true); }); - $(inputID).bind("blur", function(e){ - var eLabelVal = $(this).siblings("label").html(); - + input.bind("blur", function(e){ // Reset the input value if it's empty if ($(this).val() == "") { - $(this).val(eLabelVal); + $(this).val(label.html()); + button.enable(false); } }); } -- cgit v1.2.3 From ffccfb9e634de527261dca8e46ac4053806ec87b Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 15 Sep 2009 20:23:32 -0700 Subject: Move the code that adds the .gShortForm CSS class out of gallery.short_forms.js and into the theme, since this is really a theme decision. --- lib/gallery.form.js | 13 ------------- themes/default/js/ui.init.js | 7 +++++-- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/lib/gallery.form.js b/lib/gallery.form.js index 67245e60..77ce3b7d 100644 --- a/lib/gallery.form.js +++ b/lib/gallery.form.js @@ -1,14 +1,3 @@ -/** - * Handle initialization of all short forms - * - * @param shortForms array Array of short form IDs - */ -function handle_short_form_event(short_forms) { - for (var i in short_forms) { - short_form_init(short_forms[i]); - } -} - /** * Initialize a short form. Short forms may contain only one text input. * @@ -16,8 +5,6 @@ function handle_short_form_event(short_forms) { */ function short_form_init(form_id) { var form = $(form_id); - form.addClass("gShortForm"); - var label = form.find("label:first"); var input = form.find("input[type=text]:first"); var button = form.find("input[type=submit]"); diff --git a/themes/default/js/ui.init.js b/themes/default/js/ui.init.js index 949933e9..93dfb275 100644 --- a/themes/default/js/ui.init.js +++ b/themes/default/js/ui.init.js @@ -2,7 +2,7 @@ * Initialize jQuery UI and Gallery Plugin elements */ -var shortForms = new Array( +var short_forms = new Array( "#gQuickSearchForm", "#gAddTagForm", "#gSearchForm" @@ -36,7 +36,10 @@ $(document).ready(function() { } // Initialize short forms - handleShortFormEvent(shortForms); + for (var i in short_forms) { + short_form_init(short_forms[i]); + $(short_forms[i]).addClass("gShortForm"); + } $(".gShortForm input[type=text]").addClass("ui-corner-left"); $(".gShortForm input[type=submit]").addClass("ui-state-default ui-corner-right"); -- cgit v1.2.3