Bugzilla – Attachment 69097 Details for
Bug 19560
Unable to delete library when branchcode contains special characters
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19560: Unable to delete library when branchcode contains special characters
Bug-19560-Unable-to-delete-library-when-branchcode.patch (text/plain), 8.67 KB, created by
David Bourgault
on 2017-11-10 22:04:56 UTC
(
hide
)
Description:
Bug 19560: Unable to delete library when branchcode contains special characters
Filename:
MIME Type:
Creator:
David Bourgault
Created:
2017-11-10 22:04:56 UTC
Size:
8.67 KB
patch
obsolete
>From 4796b58fef8f457ea9b0cb517a87de9a2749b5aa Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Thu, 9 Nov 2017 15:08:38 +0000 >Subject: [PATCH] Bug 19560: Unable to delete library when branchcode contains > special characters > >This patch modifies the library administration page so that the library >delete button submits a form using POST rather than linking to the >delete operation with GET variables. > >This patch also adds validation to the library entry form so that it >will only accept letters, numbers, hyphen, and underscore. > >The validation method for this already existed in categories.js, so it >has been moved to staff-global.js and the validator warning message has >been moved to validator-strings.inc so it is included globally. > >To test: > - Add a library with a branchcode containing characters like & or > #. > - Apply the patch and clear your browser cache if necessary. > - Try to delete the new library. It should delete successfully. > - Add a library again and try to include spaces and/or special > characters in the branchcode. The form validation script should > prevent you from submitting the form. > - Go do Administration -> Patron categories and add a new patron > category. The category code field should prevent you from entering a > code with spaces or special characters. > >Signed-off-by: David Bourgault <david.bourgault@inlibro.com> >--- > .../prog/en/includes/validator-strings.inc | 3 +- > koha-tmpl/intranet-tmpl/prog/en/js/categories.js | 10 ------- > .../prog/en/modules/admin/branches.tt | 34 +++++++++++++--------- > .../prog/en/modules/admin/categories.tt | 1 - > koha-tmpl/intranet-tmpl/prog/js/staff-global.js | 8 +++++ > 5 files changed, 30 insertions(+), 26 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/validator-strings.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/validator-strings.inc >index 2ca4430..b09440a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/validator-strings.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/validator-strings.inc >@@ -16,7 +16,8 @@ $(document).ready(function(){ > rangelength: $.validator.format(_("Please enter a value between {0} and {1} characters long.")), > range: $.validator.format(_("Please enter a value between {0} and {1}.")), > max: $.validator.format(_("Please enter a value less than or equal to {0}.")), >- min: $.validator.format(_("Please enter a value greater than or equal to {0}.")) >+ min: $.validator.format(_("Please enter a value greater than or equal to {0}.")), >+ letters_numbers: $.validator.format(_("This field can only contain the following characters: letters, numbers, hyphen, and underscore.")) > }); > }); > //]]> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/categories.js b/koha-tmpl/intranet-tmpl/prog/en/js/categories.js >index 0746ec7..f69b011 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/js/categories.js >+++ b/koha-tmpl/intranet-tmpl/prog/en/js/categories.js >@@ -1,13 +1,3 @@ >-jQuery.validator.addMethod( "letters_numbers", function(value,element){ >- var patt = /^[a-zA-Z0-9\-_]+$/g; >- if (patt.test(element.value)) { >- return true; >- } else { >- return false; >- } >- }, MSG_CATEGORYCODE_CHARS >-); >- > jQuery.validator.addMethod( "enrollment_period", function(){ > enrolmentperiod = $("#enrolmentperiod").val(); > enrolmentperioddate = $("#enrolmentperioddate").val(); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt >index 586091e..cb81850 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt >@@ -25,17 +25,15 @@ > "sPaginationType": "four_button" > })); > >- [% UNLESS library %] >- $("#Aform").on("submit", function( event ) { >- if ( $("#branchcode").val().match(/\s/) ) { >- event.preventDefault(); >- alert(_("The library code entered contains whitespace characters. Please remove any whitespace characters from the library code")); >- return false; >- } else { >- return true; >- } >- }); >- [% END %] >+ $("#library_entry").validate({ >+ rules: { >+ branchcode: { >+ required: true, >+ letters_numbers: true >+ }, >+ branchname: "required" >+ } >+ }); > }); > tinyMCE.init({ > mode : "textareas", >@@ -132,7 +130,7 @@ tinyMCE.init({ > > [% IF op == 'add_form' %] > <h3>[% IF library %]Modify library[% ELSE %]New library[% END %]</h3> >- <form action="/cgi-bin/koha/admin/branches.pl" id="Aform" name="Aform" class="validated" method="post"> >+ <form action="/cgi-bin/koha/admin/branches.pl" id="library_entry" method="post"> > <fieldset class="rows"> > <input type="hidden" name="op" value="add_validate" /> > [% IF library %] >@@ -271,7 +269,11 @@ tinyMCE.init({ > <td>[% library.branchip %]</td> > <td class="actions"> > <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/branches.pl?op=add_form&branchcode=[% library.branchcode %]"><i class="fa fa-pencil"></i> Edit</a> >- <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/branches.pl?op=delete_confirm&branchcode=[% library.branchcode %]"><i class="fa fa-trash"></i> Delete</a> >+ <form action="/cgi-bin/koha/admin/branches.pl" method="post"> >+ <input type="hidden" name="branchcode" value="[% library.branchcode %]" /> >+ <input type="hidden" name="op" value="delete_confirm" /> >+ <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-trash"></i> Delete</button> >+ </form> > </td> > </tr> > [% END %] >@@ -302,7 +304,11 @@ tinyMCE.init({ > <td>[% category.codedescription |html %]</td> > <td class="actions"> > <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/branches.pl?categorycode=[% category.categorycode %]&op=add_form_category"><i class="fa fa-pencil"></i> Edit</a> >- <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/branches.pl?categorycode=[% category.categorycode %]&op=delete_confirm_category"><i class="fa fa-trash"></i> Delete</a> >+ <form action="/cgi-bin/koha/admin/branches.pl" method="post"> >+ <input type="hidden" name="categorycode" value="[% category.categorycode %]" /> >+ <input type="hidden" name="op" value="delete_confirm_category" /> >+ <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-trash"></i> Delete</button> >+ </form> > </td> > </tr> > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt >index 9d8d65b..eb6be8d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt >@@ -10,7 +10,6 @@ > <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" /> > [% INCLUDE 'datatables.inc' %] > <script type="text/javascript"> >- var MSG_CATEGORYCODE_CHARS = _("Category code can only contain the following characters: letters, numbers, - and _."); > var MSG_BOTH_ENROLLMENTPERIODS = _("Please choose only one enrollment period setting."); > var MSG_ONE_ENROLLMENTPERIOD = ("Please choose an enrollment period in months OR by date."); > </script> >diff --git a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >index cd586da..ba6aaba 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >@@ -15,6 +15,14 @@ function formatstr(str, col) { > }); > } > >+jQuery.validator.addMethod( "letters_numbers", function(value,element){ >+ var patt = /^[a-zA-Z0-9\-_]+$/g; >+ if (patt.test(element.value)) { >+ return true; >+ } else { >+ return false; >+ } >+}); > > // http://stackoverflow.com/questions/14859281/select-tab-by-name-in-jquery-ui-1-10-0/16550804#16550804 > $.fn.tabIndex = function () { >-- >2.7.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 19560
:
69062
|
69097
|
69130
|
69423
|
69490
|
69700
|
69701
|
69735
|
69736
|
69775