From e872f0dc3e819d5ccc5e6dd7cdcab4358c162bba Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 23 Jan 2013 14:23:08 -0500 Subject: [PATCH] Bug 9468 - Add ability to hide items from purchase suggestions forms Content-Type: text/plain; charset=utf-8 Test Plan: 1) Apply patch 2) Run updatedatabase.pl 3) Add some itemtypes to the new system pref SuggestionsHideItemTypes 4) Make a purchase suggestion 5) Verify those item types set in SuggestionsHideItemTypes do not appear in the pulldown menu for "Item type" Signed-off-by: Frederic Durand Signed-off-by: Marcel de Rooy --- C4/Koha.pm | 9 +++++++-- installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 7 +++++++ .../prog/en/modules/admin/preferences/opac.pref | 5 +++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/C4/Koha.pm b/C4/Koha.pm index 937ac5f..361ffd5 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -188,11 +188,16 @@ build a HTML select with the following code : sub GetSupportList{ my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes"); + + my $hidden_item_types = join( ',', map{ qq{'$_'} } split(qq{ }, C4::Context->preference("SuggestionsHideItemTypes") ) ); + my $hide_sql = $hidden_item_types ? "WHERE itemtype NOT IN ( $hidden_item_types )" : qq{}; + if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') { my $query = qq| SELECT * - FROM itemtypes - order by description + FROM itemtypes + $hide_sql + ORDER BY description |; my $sth = C4::Context->dbh->prepare($query); $sth->execute; diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 72eead2..5d342d1 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -358,6 +358,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('SubscriptionDuplicateDroppedInput','','','List of fields which must not be rewritten when a subscription is duplicated (Separated by pipe |)','Free'), ('SubscriptionHistory','simplified','simplified|full','Define the display preference for serials issue history in OPAC','Choice'), ('SubscriptionLog','1',NULL,'If ON, enables subscriptions log','YesNo'), +('SuggestionsHideItemTypes', '', 'Item types to hide from the purchase suggestion forms, delimited by spaces', 'free' ), ('suggestion','1','','If ON, enables patron suggestions feature in OPAC','YesNo'), ('SuspendHoldsIntranet','1','Allow holds to be suspended from the intranet.',NULL,'YesNo'), ('SuspendHoldsOpac','1','Allow holds to be suspended from the OPAC.',NULL,'YesNo'), diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 6162bc5..eaf7af7 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -7743,6 +7743,13 @@ if(CheckVersion($DBversion)) { SetVersion($DBversion); } +$DBversion = "3.13.00.XXX"; +if ( CheckVersion($DBversion) ) { + $dbh->do("INSERT INTO systempreferences ( variable, value, explanation, type ) VALUES ( 'SuggestionsHideItemTypes', '', 'Item types to hide from the purchase suggestion forms, delimited by spaces', 'free' )"); + print "Upgrade to $DBversion done (Bug 9468 - Add ability to hide items from purchase suggestions forms)\n"; + SetVersion ($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref index a75c7ef..cd5a34a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -356,6 +356,11 @@ OPAC: no: "Don't allow" - patrons to make purchase suggestions on the OPAC. - + - "Do not show the following item types for purchase suggestions:" + - pref: SuggestionsHideItemTypes + class: multi + - "(separate item types with spaces)" + - - pref: reviewson choices: yes: Allow -- 1.7.7.6