From 3ec8fc73210c03e0bad8cc177fc1ce32e701ff3c 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 +- .../mysql/atomicupdate/bz10937_group_item_types.pl | 20 ++++++++++++++++++++ installer/data/mysql/kohastructure.sql | 2 +- .../intranet-tmpl/prog/en/modules/admin/itemtypes.tt | 2 +- t/db_dependent/Koha.t | 5 ++--- 7 files changed, 27 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 b1aede7..20a4e5c 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 2030ea9..296a11b 100755 --- a/admin/authorised_values.pl +++ b/admin/authorised_values.pl @@ -246,7 +246,7 @@ sub default_form { } # 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 8c176f0..b97245a 100755 --- a/admin/itemtypes.pl +++ b/admin/itemtypes.pl @@ -112,7 +112,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 0000000..9900a79 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bz10937_group_item_types.pl @@ -0,0 +1,20 @@ +#!/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 31b85fd..e49d2e1 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1283,7 +1283,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 20fd49f..297a14f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt @@ -125,7 +125,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 84fc5eb..7fdd419 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.1.0