From b33467f2aacf427a6f083f679acc9f219ee34f43 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Fri, 18 Sep 2020 22:17:58 +0000 Subject: [PATCH] Bug 23420: Add OPACSuggestionUnwantedFields system pref 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 --- ...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 | 186 ++++++++++++--------- opac/opac-suggestions.pl | 10 ++ 5 files changed, 139 insertions(+), 82 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..6f0699f2c2 --- /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 1df6a1fb53..d16c262f4a 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -451,6 +451,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 e078692ff6..3cb298c423 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 @@ -630,6 +630,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: + 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 + - "
Note: Do not make OPACSuggestionMandatoryFields unwanted fields " + - - 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 4d8a055ec5..c1eba30fb1 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt @@ -76,79 +76,94 @@ [% END %] -
  • - [% IF ( author_required ) %] - - - Required - [% ELSE %] - - - [% END %] -
  • -
  • -
    - [% IF ( copyrightdate_required ) %] - - - Required + [% 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 %] - -
  • -
  • - [% IF ( isbn_required ) %] - - - Required - [% ELSE %] - - - [% END %] -
  • -
  • - [% IF ( publishercode_required ) %] - - - Required - [% ELSE %] - - - [% END %] -
  • -
  • - [% IF ( collectiontitle_required ) %] - - - Required - [% ELSE %] - - - [% END %] -
  • -
  • - [% IF ( place_required ) %] - - - Required - [% ELSE %] - - - [% END %] -
  • -
  • - [% IF ( quantity_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 ) %] [% PROCESS 'av-build-dropbox.inc' name="itemtype", category="SUGGEST_FORMAT", size = 20 %] @@ -157,8 +172,10 @@ [% PROCESS 'av-build-dropbox.inc' name="itemtype", category="SUGGEST_FORMAT", size = 20 %] [% END %] -
  • + + [% END %] [% IF branchcode %] + [% UNLESS ( branchcode_hidden )%]
  • [% IF ( branchcode_required ) %] @@ -174,7 +191,9 @@ [% END %]
  • [% END %] + [% END %] [% IF ( patron_reason_loop ) %] + [% UNLESS ( patronreason_hidden )%]
  • [% IF ( patronreason_required ) %] @@ -196,16 +215,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 22f6442c9b..4b4793bc9a 100755 --- a/opac/opac-suggestions.pl +++ b/opac/opac-suggestions.pl @@ -256,6 +256,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