From 6ed6d05a37f8c5b9831c2ef8d538a6fbbad53377 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Sat, 1 Aug 2020 03:09:33 +0000 Subject: [PATCH] Bug 23420: Add OPACSuggestionUnwantedFields option To test: -Apply patch -Check OPACSuggestionUnwantedFields -Check some fields as unwanted -Go to the OPAC suggestion page and make sure these correct fields are hidden -Go through each option and make sure it hides properly Signed-off-by: Lisette Scheer --- ...0_add_OPACSuggestionUnwantedFields_syspref.perl | 8 + installer/data/mysql/sysprefs.sql | 1 + .../prog/en/modules/admin/preferences/opac.pref | 16 ++ .../bootstrap/en/modules/opac-suggestions.tt | 201 ++++++++++++--------- opac/opac-suggestions.pl | 10 + 5 files changed, 147 insertions(+), 89 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_23420_add_OPACSuggestionUnwantedFields_syspref.perl diff --git a/installer/data/mysql/atomicupdate/bug_23420_add_OPACSuggestionUnwantedFields_syspref.perl b/installer/data/mysql/atomicupdate/bug_23420_add_OPACSuggestionUnwantedFields_syspref.perl new file mode 100644 index 0000000000..6d1401320e --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_23420_add_OPACSuggestionUnwantedFields_syspref.perl @@ -0,0 +1,8 @@ +$DBversion = 'XXX'; # will be replaced by the RM + if ( CheckVersion($DBversion) ) { + $dbh->do(q{ + INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('OPACSuggestionUnwantedFields','', NULL,'Define the hidden fields for a patron purchase suggestions made via OPAC.','multiple'); + }); + + NewVersion($DBversion, 23420, "Allow configuration of hidden fields on the suggestion form in OPAC"); +} diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index d1efc4b42c..15b7afc934 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -446,6 +446,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('OPACShowUnusedAuthorities','1','','Show authorities that are not being used in the OPAC.','YesNo'), ('OpacStarRatings','all','disable|all|details',NULL,'Choice'), ('OpacSuggestionManagedBy',1,'','Show the name of the staff member who managed a suggestion in OPAC','YesNo'), +('OPACSuggestionUnwantedFields', '', NULL , 'Define the hidden fields for a patron purchase suggestions made via OPAC.' , 'multiple'), ('OpacSuppression','0','','Turn ON the OPAC Suppression feature, requires further setup, ask your system administrator for details','YesNo'), ('OpacSuppressionByIPRange','','','Restrict the suppression to IP adresses outside of the IP range','free'), ('OpacSuppressionMessage','','Display this message on the redirect page for suppressed biblios','70|10','Textarea'), 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 dcf8d39520..ec0dccf548 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 @@ -641,6 +641,22 @@ OPAC: note: Note - "
Note: if none of the above options are selected, 'Title' field would be mandatory anyway, by default." - + - "Fields that should be hidden for patron purchase suggestions:" + - pref: OPACSuggestionUnwantedFields + multiple: + title: Title + author: Author + copyrightdate: Copyright or publication date + isbn: ISBN, ISSN or other standard number + publishercode: Publisher name + collectiontitle: Collection title + place: Publication place + itemtype: Item type + quantity: Quantity + branch: Library or branch + patronreason: Patron reason + note: Note + - - pref: OpacHiddenItems type: textarea syntax: text/x-yaml 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 499f330fb0..71fad804b8 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt @@ -13,7 +13,6 @@ [% IF ( loggedinusername ) %][% INCLUDE 'bodytag.inc' bodyid='opac-usersuggestions' bodyclass='scrollto' %][% ELSE %][% INCLUDE 'bodytag.inc' bodyid='opac-suggestions' bodyclass='scrollto' %][% END %] [% INCLUDE 'masthead.inc' %] -
- -
  • - [% IF ( isbn_required ) %] - - - Required - [% ELSE %] - - - [% END %] -
  • -
  • - [% IF ( publishercode_required ) %] - - - Required - [% ELSE %] - - - [% END %] -
  • -
  • - [% IF ( collectiontitle_required ) %] - - - Required - [% ELSE %] - - - [% END %] -
  • + + [% END %]
  • - [% IF ( place_required ) %] - - - Required - [% ELSE %] - - - [% END %] -
  • -
  • - [% IF ( quantity_required ) %] - - - Required - [% ELSE %] - - - [% END %] + [% UNLESS ( author_hidden ) %] + [% IF ( author_required ) %] + + + Required + [% ELSE %] + + + [% END %]
  • + [% END %] + [% UNLESS ( copyrightdate_hidden )%] +
  • +
    + [% IF ( copyrightdate_required ) %] + + + Required + [% ELSE %] + + + [% END %] +
    +
  • + [% END %] + [% UNLESS ( isbn_hidden ) %] +
  • + [% IF ( isbn_required ) %] + + + Required + [% ELSE %] + + + [% END %] +
  • + [% END %] + [% UNLESS ( publishercode_hidden ) %] +
  • + [% IF ( publishercode_required ) %] + + + Required + [% ELSE %] + + + [% END %] +
  • + [% END %] + [% UNLESS ( collectiontitle_hidden ) %] +
  • + [% IF ( collectiontitle_required ) %] + + + Required + [% ELSE %] + + + [% END %] +
  • + [% END %] + [% UNLESS ( place_hidden )%] +
  • + [% IF ( place_required ) %] + + + Required + [% ELSE %] + + + [% END %] +
  • + [% END %] + [% UNLESS ( quantity_hidden )%] +
  • + [% IF ( quantity_required ) %] + + + Required + [% ELSE %] + + + [% END %] +
  • + [% END %] + [% UNLESS (itemtype_hidden) %]
  • [% IF ( itemtype_required ) %] @@ -149,7 +165,9 @@ [% PROCESS 'av-build-dropbox.inc' name="itemtype", category="SUGGEST_FORMAT", size = 20 %] [% END %]
  • + [% END %] [% IF branchcode %] + [% UNLESS ( branchcode_hidden )%]
  • [% IF ( branchcode_required ) %] @@ -165,7 +183,9 @@ [% END %]
  • [% END %] + [% END %] [% IF ( patron_reason_loop ) %] + [% UNLESS ( patronreason_hidden ) %]
  • [% IF ( patronreason_required ) %] @@ -187,16 +207,19 @@ [% END %]
  • [% END %] -
  • - [% IF ( note_required ) %] - - - Required - [% ELSE %] - - - [% END %] -
  • + [% END %] + [% UNLESS ( note_hidden ) %] +
  • + [% IF ( note_required ) %] + + + Required + [% ELSE %] + + + [% END %] +
  • + [% END %]
  • diff --git a/opac/opac-suggestions.pl b/opac/opac-suggestions.pl index 74e3079dfe..9c891384a0 100755 --- a/opac/opac-suggestions.pl +++ b/opac/opac-suggestions.pl @@ -257,6 +257,16 @@ my @mandatoryfields; } } +my @unwantedfields; +{ + last unless ($op eq 'add'); + my $fldsreq_sp = C4::Context->preference("OPACSuggestionUnwantedFields"); + @unwantedfields = sort split(/\s*\,\s*/, $fldsreq_sp); + foreach (@unwantedfields) { + $template->param( $_."_hidden" => 1); + } +} + $template->param( %$suggestion, suggestions_loop => $suggestions_loop, -- 2.11.0