From 96b05f3535425de2973ad7b4c03deeb8a74ef7ef Mon Sep 17 00:00:00 2001 From: Blou Date: Thu, 9 Jul 2015 09:22:20 -0400 Subject: [PATCH] Bug 10937: cleanup and rename DOCTYPECAT to ITEMTYPECAT - "Item" and not "Document" is the word used throughout Koha. - Moved the updates to an atomic update - changed searchcategory from varchar(20) to (80) - cleanup --- C4/Koha.pm | 3 +-- admin/authorised_values.pl | 2 +- admin/itemtypes.pl | 2 +- .../atomicupdate/bz10937_group_item_types.pl | 18 ++++++++++++++++++ installer/data/mysql/kohastructure.sql | 2 +- .../prog/en/modules/admin/itemtypes.tt | 2 +- t/db_dependent/Koha.t | 5 ++--- 7 files changed, 25 insertions(+), 9 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bz10937_group_item_types.pl diff --git a/C4/Koha.pm b/C4/Koha.pm index b1aede70ab..20a4e5c8f7 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -31,7 +31,6 @@ use DateTime::Format::MySQL; use Business::ISBN; use autouse 'Data::cselectall_arrayref' => qw(Dumper); use DBI qw(:sql_types); - use Data::Dumper; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $DEBUG); BEGIN { @@ -281,7 +280,7 @@ sub GetItemTypes { Returns a hashref containing search categories. A search category will be put in the hash if at least one of its itemtypes is visible in OPAC. -The categories must be part of Authorized Values (DOCTYPECAT) +The categories must be part of Authorized Values (ITEMTYPECAT) =cut diff --git a/admin/authorised_values.pl b/admin/authorised_values.pl index af6d0e6c3c..0f00126f9a 100755 --- a/admin/authorised_values.pl +++ b/admin/authorised_values.pl @@ -184,7 +184,7 @@ if ( $op eq 'list' ) { } # push koha system categories - foreach (qw(Asort1 Asort2 Bsort1 Bsort2 SUGGEST DAMAGED LOST REPORT_GROUP REPORT_SUBGROUP DEPARTMENT TERM SUGGEST_STATUS DOCTYPECAT)) { + foreach (qw(Asort1 Asort2 Bsort1 Bsort2 SUGGEST DAMAGED LOST REPORT_GROUP REPORT_SUBGROUP DEPARTMENT TERM SUGGEST_STATUS ITEMTYPECAT)) { push @category_list, $_ unless $categories{$_}; } diff --git a/admin/itemtypes.pl b/admin/itemtypes.pl index 1ec15c4717..61e59fe6cd 100755 --- a/admin/itemtypes.pl +++ b/admin/itemtypes.pl @@ -111,7 +111,7 @@ if ( $op eq 'add_form' ) { $remote_image = $data->{imageurl}; } - my $searchcategory = GetAuthorisedValues("DOCTYPECAT", $data->{'searchcategory'}); + my $searchcategory = GetAuthorisedValues("ITEMTYPECAT", $data->{'searchcategory'}); $template->param( itemtype => $itemtype, diff --git a/installer/data/mysql/atomicupdate/bz10937_group_item_types.pl b/installer/data/mysql/atomicupdate/bz10937_group_item_types.pl new file mode 100755 index 0000000000..649f43cd29 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bz10937_group_item_types.pl @@ -0,0 +1,18 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use C4::Context; + +my $dbh = C4::Context->dbh; + +my $DBversion = "3.21.00.XXX"; +#if ( CheckVersion($DBversion) ) { + $dbh->do(q{ + ALTER TABLE itemtypes + ADD hideinopac TINYINT(1) NOT NULL DEFAULT 0 AFTER sip_media_type, + ADD searchcategory VARCHAR(80) DEFAULT NULL AFTER hideinopac; + }); + print "Upgrade to $DBversion done (Bug 10937 - Option to hide and group itemtypes from advanced search)\n"; +# SetVersion($DBversion); +#} diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index e8298e0047..9b7ae676e5 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1275,7 +1275,7 @@ CREATE TABLE `itemtypes` ( -- defines the item types checkinmsgtype CHAR(16) DEFAULT 'message' NOT NULL, -- type (CSS class) for the checkinmsg, can be "alert" or "message" sip_media_type VARCHAR(3) DEFAULT NULL, -- SIP2 protocol media type for this itemtype hideinopac tinyint(1) NOT NULL DEFAULT 0, -- Hide the item type from the search options in OPAC - searchcategory varchar(20) default NULL, -- Group this item type with others with the same value on OPAC search options + searchcategory varchar(80) default NULL, -- Group this item type with others with the same value on OPAC search options PRIMARY KEY (`itemtype`), UNIQUE KEY `itemtype` (`itemtype`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt index a66317ea54..8311f48208 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt @@ -141,7 +141,7 @@ Item types administration [% END %] [% END %] - (Options are defined as the authorized values for the DOCTYPECAT category) + (Options are defined as the authorized values for the ITEMTYPECAT category) [% IF ( noItemTypeImages ) %] diff --git a/t/db_dependent/Koha.t b/t/db_dependent/Koha.t index 84fc5eb2fc..7fdd4192a0 100644 --- a/t/db_dependent/Koha.t +++ b/t/db_dependent/Koha.t @@ -7,7 +7,6 @@ use strict; use warnings; use C4::Context; use Koha::DateUtils qw(dt_from_string); -use Data::Dumper; use Test::More tests => 9; use DateTime::Format::MySQL; @@ -316,7 +315,7 @@ subtest 'GetFrameworksLoop() tests' => sub { subtest 'GetItemTypesByCategory GetItemTypesCategorized test' => sub{ plan tests => 7; - my $insertGroup = AddAuthorisedValue('DOCTYPECAT', 'Qwertyware'); + my $insertGroup = AddAuthorisedValue('ITEMTYPECAT', 'Qwertyware'); ok($insertGroup, "Create group Qwertyware"); my $query = "INSERT into itemtypes (itemtype, description, searchcategory, hideinopac) values (?,?,?,?)"; @@ -334,7 +333,7 @@ subtest 'GetItemTypesByCategory GetItemTypesCategorized test' => sub{ is_deeply(\@results,\@expected,'GetItemTypesByCategory: valid category returns itemtypes'); # add more data since GetItemTypesCategorized's search is more subtle - $insertGroup = AddAuthorisedValue('DOCTYPECAT', 'Veryheavybook'); + $insertGroup = AddAuthorisedValue('ITEMTYPECAT', 'Veryheavybook'); $insertSth->execute('BKghjklo4', 'Another hidden book', 'Veryheavybook', 1); my $hrCat = GetItemTypesCategorized(); -- 2.39.5