From f75de6087a68260bd14bc346e7614f4f8ebab29a Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Wed, 31 Jul 2013 12:33:32 -0400 Subject: [PATCH] Bug 9223 [Follow-up] Multiple values of AdvancedSearchTypes in suggestions This follow-up implements some things I think will improve on the previous patches: - Change the system preference name to "SuggestionsUseValues" - Change the description of the preference to "Suggestions can be submitted using the following authorized values:" - Move the new preference to the OPAC tab so that it is grouped with other suggestions-related preferences. - Add the option offer no itemtype/collection code chooser on the submission form. - Display the correct label on the submission form depending on the value of the SuggestionsUseValues preference. To test, apply this patch on top of the previous ones. Test submission of purchase suggestions through the OPAC and staff client with the SuggestionsUseValues preference set to all the various choices: item type, collection code, shelving location, and 'none.' The suggestion forms should look correct and work correctly. HOWEVER, neither the previous patches nor mine address the problem of the suggestions management page's "organize by" option, which is hard-coded to work with item types. Whether or not my patch is acceptable this issue will need to be addressed. Signed-off-by: Olli-Antti Kivilahti Tested the TEST PLAN. With ccode, itype, none, loc. On both OPAC and SC. Making a code review, but it is hard during the hackfest. Morbid lack of any kind of unit test! --- C4/Koha.pm | 4 +- installer/data/mysql/sysprefs.sql | 2 +- installer/data/mysql/updatedatabase.pl | 4 +- .../en/modules/admin/preferences/cataloguing.pref | 9 ---- .../prog/en/modules/admin/preferences/opac.pref | 9 ++++ .../prog/en/modules/suggestion/suggestion.tt | 47 ++++++++++++++------ .../bootstrap/en/modules/opac-suggestions.tt | 17 +++++-- 7 files changed, 61 insertions(+), 31 deletions(-) diff --git a/C4/Koha.pm b/C4/Koha.pm index 20049e5..716464d 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -140,7 +140,7 @@ Returns the name of the support corresponding to specified authorised value. sub GetSupportName { my $authorised_value = shift; return '' unless $authorised_value; - my $supports_av = C4::Context->preference("SupportsAuthorizedValues") || 'itemtypes'; + my $supports_av = C4::Context->preference("SuggestionsUseValues") || 'itemtypes'; if ( $supports_av eq 'itemtypes' ) { my $itemtype = getitemtypeinfo($authorised_value); return $itemtype->{'description'} if $itemtype; @@ -180,7 +180,7 @@ build a HTML select with the following code : =cut sub GetSupportList { - my $supports_av = C4::Context->preference("SupportsAuthorizedValues") || 'itemtypes'; + my $supports_av = C4::Context->preference("SuggestionsUseValues") || 'itemtypes'; if ( $supports_av eq 'itemtypes' ) { my @supports = map { { diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index ec31dad..711603c 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -410,7 +410,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('SubscriptionHistory','simplified','simplified|full','Define the display preference for serials issue history in OPAC','Choice'), ('SubscriptionLog','1',NULL,'If ON, enables subscriptions log','YesNo'), ('suggestion','1','','If ON, enables patron suggestions feature in OPAC','YesNo'), -('SupportsAuthorizedValues','itemtypes','itemtypes|ccode|loc','Authorized values representing document physical support','Choice'), +('SuggestionsUseValues','itemtypes','itemtypes|ccode|loc|none','Suggestions can be submitted using the following authorized values:','Choice'), ('SuspendHoldsIntranet','1','Allow holds to be suspended from the intranet.',NULL,'YesNo'), ('SuspendHoldsOpac','1','Allow holds to be suspended from the OPAC.',NULL,'YesNo'), ('SvcMaxReportRows','10',NULL,'Maximum number of rows to return via the report web service.','Integer'), diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 91fa832..0405368 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -10556,8 +10556,8 @@ if ( CheckVersion($DBversion) ) { $DBversion = "3.19.00.XXX"; if ( CheckVersion($DBversion) ) { - $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SupportsAuthorizedValues', 'itemtypes', 'Authorized values representing document physical support','itemtypes|ccode|loc','Choice')"); - print "Upgrade to $DBversion done (Bug 9223: Add SupportsAuthorizedValues syspref)\n"; + $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SuggestionsUseValues', 'itemtypes', 'Suggestions can be submitted using the following authorized values:','itemtypes|ccode|loc|none','Choice')"); + print "Upgrade to $DBversion done (Bug 9223: Add SuggestionsUseValues syspref)\n"; SetVersion ($DBversion); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref index ffab9d8..bc35aad 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref @@ -125,15 +125,6 @@ Cataloging: - 'MARC21: "952$a 952$b 952$c"' - Note that the FA framework is excluded from the permission. - If the pref is empty, no fields are restricted. - - - - pref: SupportsAuthorizedValues - default: itemtypes - choices: - itemtypes: "Item type" - loc: "Shelving Location" - ccode: "Collection code" - - represents document physical support. - - Display: - - 'Separate multiple displayed authors, series or subjects with ' 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 aa37af4..09bb356 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 @@ -529,6 +529,15 @@ OPAC: yes: Allow - patrons to select library when making a purchase suggestion - + - 'Suggestions can be submitted using the following authorized values:' + - pref: SuggestionsUseValues + default: itemtypes + choices: + itemtypes: "Item type" + loc: "Shelving location" + ccode: "Collection code" + none: "None. Hide this option" + - - pref: OpacHiddenItems type: textarea class: code diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt index ca70e09..d68e229 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt @@ -1,3 +1,4 @@ +[% USE Koha %] [% USE Branches %] [% USE AuthorisedValues %] [% USE KohaDates %] @@ -212,11 +213,21 @@ h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o
  • Publisher:[% publishercode |html %]
  • Publication place:[% place |html %]
  • Collection title:[% collectiontitle |html %]
  • -
  • Document type: - [% FOREACH supports_loo IN supports_loop %] - [% IF ( supports_loo.selected ) %][% supports_loo.lib %][% END %] - [% END %] -
  • + [% IF ( Koha.Preference( 'SuggestionsUseValues' ) != 'none' ) %] +
  • + [% IF ( Koha.Preference( 'SuggestionsUseValues' ) == 'itemtypes' ) %] + Item type: + [% ELSIF ( Koha.Preference( 'SuggestionsUseValues' ) == 'ccode' ) %] + Collection: + [% ELSIF ( Koha.Preference( 'SuggestionsUseValues' ) == 'loc' )%] + Shelving location: + [% END %] + [% FOREACH supports_loo IN supports_loop %] + [% IF ( supports_loo.selected ) %][% supports_loo.lib %][% END %] + [% END %] +
  • + [% END %] + [% IF ( patron_reason_loop ) %]
  • Reason for suggestion: [% FOREACH patron_reason_loo IN patron_reason_loop %] @@ -335,14 +346,24 @@ h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o
  • -
  • - -
  • + [% IF ( Koha.Preference( 'SuggestionsUseValues' ) != 'none' ) %] +
  • + [% IF ( Koha.Preference( 'SuggestionsUseValues' ) == 'itemtypes' ) %] + + [% ELSIF ( Koha.Preference( 'SuggestionsUseValues' ) == 'ccode' ) %] + + [% ELSIF ( Koha.Preference( 'SuggestionsUseValues' ) == 'loc' )%] + + [% END %] + +
  • + [% END %] [% IF ( patron_reason_loop ) %]
  • [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt index c88b902..c42c207 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt @@ -41,20 +41,29 @@
  • -
  • + [% IF ( Koha.Preference( 'SuggestionsUseValues' ) != 'none' ) %] +
  • + [% IF ( Koha.Preference( 'SuggestionsUseValues' ) == 'itemtypes' ) %] + + [% ELSIF ( Koha.Preference( 'SuggestionsUseValues' ) == 'ccode' ) %] + + [% ELSIF ( Koha.Preference( 'SuggestionsUseValues' ) == 'loc' )%] + + [% END %]
  • + [% END %] [% IF ( branchloop ) %]