From be6449dafb253f338aa61af21e553560f8d737f3 Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@biblibre.com>
Date: Wed, 3 Dec 2014 12:33:48 +0100
Subject: [PATCH] [PASSED QA] Bug 13379: Extends authorised_values.category to varchar(32)
This patch does 2 things:
1/ It fixes a bug caused by the different data fields used for
authorised_values.category and
borrower_attribute_types.authorised_value_category (varchar(16) vs
varchar(10)).
To reproduce:
- Create a AV category with a length > 10
- Try to link a patron attribute type with this AV, it won't work.
2/ Extends this field to varchar(32): sometime 16 is not enough to
describe something
Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
No koha-qa errors. Error reproduced, fixed by patch.
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
---
installer/data/mysql/kohastructure.sql | 6 +++---
installer/data/mysql/updatedatabase.pl | 16 ++++++++++++++++
.../prog/en/modules/admin/authorised_values.tt | 2 +-
3 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql
index 4ffbbf2..5796add 100644
--- a/installer/data/mysql/kohastructure.sql
+++ b/installer/data/mysql/kohastructure.sql
@@ -98,7 +98,7 @@ CREATE TABLE `auth_types` (
DROP TABLE IF EXISTS `authorised_values`;
CREATE TABLE `authorised_values` ( -- stores values for authorized values categories and values
`id` int(11) NOT NULL auto_increment, -- unique key, used to identify the authorized value
- `category` varchar(16) NOT NULL default '', -- key used to identify the authorized value category
+ `category` varchar(32) NOT NULL default '', -- key used to identify the authorized value category
`authorised_value` varchar(80) NOT NULL default '', -- code use to identify the authorized value
`lib` varchar(200) default NULL, -- authorized value description as printed in the staff client
`lib_opac` varchar(200) default NULL, -- authorized value description as printed in the OPAC
@@ -291,7 +291,7 @@ CREATE TABLE `borrower_attribute_types` ( -- definitions for custom patron field
`opac_display` tinyint(1) NOT NULL default 0, -- defines if this field is visible to patrons on their account in the OPAC (1 for yes, 0 for no)
`password_allowed` tinyint(1) NOT NULL default 0, -- defines if it is possible to associate a password with this custom field (1 for yes, 0 for no)
`staff_searchable` tinyint(1) NOT NULL default 0, -- defines if this field is searchable via the patron search in the staff client (1 for yes, 0 for no)
- `authorised_value_category` varchar(10) default NULL, -- foreign key from authorised_values that links this custom field to an authorized value category
+ `authorised_value_category` varchar(32) default NULL, -- foreign key from authorised_values that links this custom field to an authorized value category
`display_checkout` tinyint(1) NOT NULL default 0,-- defines if this field displays in checkout screens
`category_code` VARCHAR(10) NULL DEFAULT NULL,-- defines a category for an attribute_type
`class` VARCHAR(255) NOT NULL DEFAULT '',-- defines a class for an attribute_type
@@ -3495,7 +3495,7 @@ CREATE TABLE items_search_fields (
label VARCHAR(255) NOT NULL,
tagfield CHAR(3) NOT NULL,
tagsubfield CHAR(1) NULL DEFAULT NULL,
- authorised_values_category VARCHAR(16) NULL DEFAULT NULL,
+ authorised_values_category VARCHAR(32) NULL DEFAULT NULL,
PRIMARY KEY(name),
CONSTRAINT items_search_fields_authorised_values_category
FOREIGN KEY (authorised_values_category) REFERENCES authorised_values (category)
diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl
index cf17e0b..89ba683 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -9585,6 +9585,22 @@ if ( CheckVersion($DBversion) ) {
SetVersion ($DBversion);
}
+$DBversion = "3.19.00.XXX";
+if(CheckVersion($DBversion)) {
+ $dbh->do(q{
+ ALTER TABLE authorised_values MODIFY COLUMN category VARCHAR(32) NOT NULL DEFAULT ''
+ });
+
+ $dbh->do(q{
+ ALTER TABLE borrower_attribute_types MODIFY COLUMN authorised_value_category VARCHAR(32) DEFAULT NULL
+ });
+
+ print "Upgrade to $DBversion done (Bug 13379 - Modify authorised_values.category to varchar(32))\n";
+ SetVersion($DBversion);
+}
+
+
+
=head1 FUNCTIONS
=head2 TableExists($table)
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt
index 1248e28..353824d 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt
@@ -77,7 +77,7 @@ $(document).ready(function() {
<fieldset class="rows"><ol>
<li>
[% IF ( action_add_category ) %]<label for="category">Category: </label>
- <input type="text" name="category" id="category" size="16" maxlength="16" class="focus" />
+ <input type="text" name="category" id="category" size="32" maxlength="32" class="focus" />
[% ELSE %]<span class="label">Category</span>
<input type="hidden" name="category" value="[% category %]" /> [% category %]
[% END %]
--
1.7.2.5