From 27dd3feafde45c4a949d63829035885e995120f2 Mon Sep 17 00:00:00 2001 From: Katrin Fischer Date: Fri, 27 Mar 2020 06:00:29 +0000 Subject: [PATCH] Bug 4944: Add OpacNoItemTypeImages system preference At the moment noItemTypeImages pref controls staff and OPAC display. With this patch, there will be a separate OpacNoItemTypes preference that allows to control display of each separately. To test: - Apply patch and run database update In Administration: - Search for 'noItemTypes' preferences - Verify the settings of both prefs match - Toggle prefs, verify everything works ok - Go to the item types configuration page - Try different settings for both prefs: - Both set to No: Only a message with a link to the prefs should show - Both set to Yes or either set to Yes: image configuration options should show In the OPAC: - Check the following pages with item-level_itypes = record - advanced search - detail page - place hold page - Check the following pages with item-level_itypes = item - result list - a list (opac-shelves) - checkouts and overdues tabs in patron account (Note: this didn't work right before, but will now.) - reading history in patron account Signed-off-by: David Nind Signed-off-by: Jonathan Druart Signed-off-by: Martin Renvoize --- C4/UsageStats.pm | 1 + .../bug_4944_OpacNoItemTypeImages.perl | 12 ++++++++++++ installer/data/mysql/sysprefs.sql | 3 ++- .../prog/en/modules/admin/itemtypes.tt | 14 +++++++------- .../prog/en/modules/admin/preferences/admin.pref | 2 +- .../prog/en/modules/admin/preferences/opac.pref | 7 +++++++ .../prog/en/modules/catalogue/advsearch.tt | 2 +- .../bootstrap/en/modules/opac-advsearch.tt | 2 +- .../opac-tmpl/bootstrap/en/modules/opac-detail.tt | 4 ++-- .../bootstrap/en/modules/opac-readingrecord.tt | 2 +- .../opac-tmpl/bootstrap/en/modules/opac-reserve.tt | 2 +- .../bootstrap/en/modules/opac-results-grouped.tt | 2 +- .../opac-tmpl/bootstrap/en/modules/opac-results.tt | 2 +- .../opac-tmpl/bootstrap/en/modules/opac-shelves.tt | 2 +- .../opac-tmpl/bootstrap/en/modules/opac-user.tt | 4 ++-- 15 files changed, 41 insertions(+), 20 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_4944_OpacNoItemTypeImages.perl diff --git a/C4/UsageStats.pm b/C4/UsageStats.pm index 55854366e9..d608eb9ea9 100644 --- a/C4/UsageStats.pm +++ b/C4/UsageStats.pm @@ -100,6 +100,7 @@ sub BuildReport { DebugLevel delimiter noItemTypeImages + OpacNoItemTypeImages virtualshelves AutoLocation IndependentBranches diff --git a/installer/data/mysql/atomicupdate/bug_4944_OpacNoItemTypeImages.perl b/installer/data/mysql/atomicupdate/bug_4944_OpacNoItemTypeImages.perl new file mode 100644 index 0000000000..77c2a5eebb --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_4944_OpacNoItemTypeImages.perl @@ -0,0 +1,12 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + + my $noItemTypeImages = C4::Context->preference('noItemTypeImages'); + $dbh->do( "INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) + VALUES('OpacNoItemTypeImages',$noItemTypeImages,NULL,'If ON, disables itemtype images in the OPAC','YesNo')" ); + $dbh->do( "UPDATE systempreferences SET explanation = 'If ON, disables itemtype images in the staff interface' + WHERE variable = 'noItemTypeImages' "); + + # Always end with this (adjust the bug info) + NewVersion( $DBversion, 4944, "Add new system preference OpacNoItemTypeImages"); +} diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index f21e1fd3f1..0006e1b8e5 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -327,7 +327,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('NewsAuthorDisplay','none','none|opac|staff|both','Display the author name for news items.','Choice'), ('noissuescharge','5','','Define maximum amount withstanding before check outs are blocked','Integer'), ('NoIssuesChargeGuarantees','','','Define maximum amount withstanding before check outs are blocked','Integer'), -('noItemTypeImages','0',NULL,'If ON, disables item-type images','YesNo'), +('noItemTypeImages','0',NULL,'If ON, disables itemtype images in the staff interface','YesNo'), ('NoRenewalBeforePrecision','exact_time','date|exact_time','Calculate "No renewal before" based on date only or exact time of due date','Choice'), ('NotesBlacklist','',NULL,'List of notes fields that should not appear in the title notes/description separator of details','free'), ('NotHighlightedWords','and|or|not',NULL,'List of words to NOT highlight when OpacHitHighlight is enabled','free'), @@ -412,6 +412,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('OpacNav','Important links here.','70|10','Use HTML tags to add navigational links to the left-hand navigational bar in OPAC','Textarea'), ('OpacNavBottom','Important links here.','70|10','Use HTML tags to add navigational links to the left-hand navigational bar in OPAC','Textarea'), ('OpacNewsLibrarySelect','0','','Show selector for branches on OPAC news page','YesNo'), +('OpacNoItemTypeImages','0',NULL,'If ON, disables itemtype images in the OPAC','YesNo'), ('OPACNoResultsFound','','70|10','Display this HTML when no results are found for a search in the OPAC','Textarea'), ('OPACNumbersPreferPhrase','0',NULL,'Control the use of phr operator in callnumber and standard number OPAC searches','YesNo'), ('OPACnumSearchResults','20',NULL,'Specify the maximum number of results to display on a page of results','Integer'), 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 a0240539fa..9045f6c712 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt @@ -140,13 +140,13 @@ Item types administration Options are defined as the authorized values for the ITEMTYPECAT category. - [% IF Koha.Preference('noItemTypeImages') %] + [% IF ( Koha.Preference('noItemTypeImages') && Koha.Preference('OpacNoItemTypeImages') ) %]
  • - Image: Item type images are disabled. To enable them, turn off the noItemTypeImages system preference + Image: Item type images are disabled. To enable them, turn off the noItemTypeImages or OpacNoItemTypeImages system preferences
  • [% END %] - [% UNLESS Koha.Preference('noItemTypeImages') %] + [% UNLESS Koha.Preference('noItemTypeImages') && Koha.Preference('OpacNoItemTypeImages') %]
    Choose an icon:
      @@ -342,7 +342,7 @@ Item types administration [% itemtype.itemtype | html %] Description[% itemtype.translated_description | html %] - [% UNLESS Koha.Preference('noItemTypeImages') %] + [% UNLESS Koha.Preference('noItemTypeImages') && Koha.Preference('OpacNoItemTypeImages') %] Image @@ -368,7 +368,7 @@ Item types administration [% IF itemtypes %] - [% UNLESS Koha.Preference('noItemTypeImages') %][% END %] + [% UNLESS Koha.Preference('noItemTypeImages') && Koha.Preference('OpacNoItemTypeImages') %][% END %] @@ -385,7 +385,7 @@ Item types administration [% FOREACH itemtype IN itemtypes %] - [% UNLESS Koha.Preference('noItemTypeImages') %] + [% UNLESS Koha.Preference('noItemTypeImages') && Koha.Preference('OpacNoItemTypeImages') %]
      ImageImageCode Description Search category
      [% SET image_location = itemtype.image_location('intranet') %] [% IF image_location %][% ELSE %] [% END %] @@ -484,7 +484,7 @@ Item types administration $(document).ready(function() { $('#icons').tabs(); var columns_settings = [% ColumnsSettings.GetColumns( 'admin', 'itemtypes', 'table_item_type', 'json' ) | $raw %]; - [% IF Koha.Preference('noItemTypeImages') %] + [% IF ( Koha.Preference('noItemTypeImages') && Koha.Preference('OpacNoItemTypeImages') ) %] columns_settings.shift(); // Remove item type image column from configuration [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref index 3764386332..39df333dd8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref @@ -29,7 +29,7 @@ Administration: 1: Some 2: All - - - "Show itemtype icons in the catalog: " + - "Show itemtype icons in the staff interface: " - pref: noItemTypeImages default: 0 choices: 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 f653396792..634c2d0749 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 @@ -108,6 +108,13 @@ OPAC: - pref: OPACXSLTDetailsDisplay class: file - '
      Options:
      • Leave empty for "no xslt"
      • enter "default" for the default one
      • put a path to define a xslt file
      • put an URL for an external specific stylesheet.
      {langcode} will be replaced with current interface language' + - + - "Show itemtype icons in the OPAC: " + - pref: OpacNoItemTypeImages + default: 0 + choices: + yes: "No" + no: "Yes" - - pref: DisplayOPACiconsXSLT choices: diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt index 33ec5241cf..9eb252d68b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt @@ -142,7 +142,7 @@ [% FOREACH itemtypeloo IN advsearchloo.code_loop %] - [% IF ( loop.last ) %][% ELSE %][% UNLESS ( loop.count % 5 ) %][% END %][% END %] [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt index 6248b360b6..f1b4e6dba2 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt @@ -148,7 +148,7 @@ value="[% IF ( itemtypeloo.cat == 1 ) %][% itemtypeloo.code | html %][% ELSE %]mc-[% itemtypeloo.ccl | html %]:[% itemtypeloo.code | html %][% END %]" /> - [% IF ( !item_level_itypes && !noItemTypeImages ) %] + [% IF ( !item_level_itypes && !Koha.Preference('OpacNoItemTypeImages') ) %] [% # Cell 3: Show item type image %] [% UNLESS ( item_level_itypes ) %] @@ -590,7 +590,7 @@ [% UNLESS ( item_level_itypes ) %] -- 2.39.5
      - [% UNLESS ( noItemTypeImages ) %] + [% UNLESS ( Koha.Preference('OpacNoItemTypeImages') ) %] [% IF ( ITEM_RESULT.imageurl ) %] [% ITEM_RESULT.description | html %] [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt index 238b2e534c..91da402058 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt @@ -166,7 +166,7 @@ - [% UNLESS ( noItemTypeImages ) %] + [% UNLESS ( Koha.Preference('OpacNoItemTypeImages') ) %] [% IF ( issue.imageurl ) %] [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt index c1c24cd4b6..0981abe172 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt @@ -375,7 +375,7 @@ [% IF ( item_level_itypes ) %] - [% UNLESS ( noItemTypeImages ) %] + [% UNLESS ( Koha.Preference('OpacNoItemTypeImages') ) %] [% IF ( itemLoo.imageurl ) %] [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results-grouped.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results-grouped.tt index 1001aab19d..f254c499ce 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results-grouped.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results-grouped.tt @@ -167,7 +167,7 @@ [% IF ( GROUP_RESULT.isbn ) %][% ELSE %][% END %] [% ELSE %] - [% UNLESS ( noItemTypeImages ) %] + [% UNLESS ( Koha.Preference('OpacNoItemTypeImages') ) %] [% IF ( GROUP_RESULT.imageurl ) %] [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt index c0212c4e80..a226ceefc8 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt @@ -253,7 +253,7 @@ [% END %] [% IF ( SEARCH_RESULT.imageurl ) %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt index dd99fa2788..4673581146 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt @@ -314,7 +314,7 @@ - [% UNLESS ( noItemTypeImages ) %] + [% UNLESS ( Koha.Preference('OpacNoItemTypeImages') ) %] [% itemsloo.description | html %] [% END %] [% itemsloo.description | html %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt index b4c92c6176..256262818d 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -315,7 +315,7 @@ [% UNLESS ( item_level_itypes ) %] Item type: - [% IF ( ISSUE.imageurl ) %] + [% IF ( ISSUE.imageurl && !Koha.Preference('OpacNoItemTypeImages') ) %] [% ISSUE.description | html %] [% END %] [% ISSUE.description | html %] - [% IF ( OVERDUE.imageurl ) %] + [% IF ( OVERDUE.imageurl && !Koha.Preference('OpacNoItemTypeImages') ) %] [% OVERDUE.description | html %] [% END %] [% OVERDUE.description | html %]