Bug 4944: Add OpacNoItemTypeImages system preference
authorKatrin Fischer <katrin.fischer.83@web.de>
Fri, 27 Mar 2020 06:00:29 +0000 (06:00 +0000)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Mon, 6 Apr 2020 09:49:26 +0000 (10:49 +0100)
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 <david@davidnind.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

15 files changed:
C4/UsageStats.pm
installer/data/mysql/atomicupdate/bug_4944_OpacNoItemTypeImages.perl [new file with mode: 0644]
installer/data/mysql/sysprefs.sql
koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results-grouped.tt
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt

index 5585436..d608eb9 100644 (file)
@@ -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 (file)
index 0000000..77c2a5e
--- /dev/null
@@ -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");
+}
index f21e1fd..0006e1b 100644 (file)
@@ -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'),
index a024053..9045f6c 100644 (file)
@@ -140,13 +140,13 @@ Item types administration
                     </select>
                     <span class="hint">Options are defined as the authorized values for the ITEMTYPECAT category.</span>
                 </li>
-                [% IF Koha.Preference('noItemTypeImages') %]
+                [% IF ( Koha.Preference('noItemTypeImages') && Koha.Preference('OpacNoItemTypeImages') ) %]
                     <li>
-                        <span class="label">Image: </span>Item type images are disabled. To enable them, turn off the <a href="/cgi-bin/koha/admin/preferences.pl?op=search&amp;searchfield=noItemTypeImages">noItemTypeImages system preference</a>
+                        <span class="label">Image: </span>Item type images are disabled. To enable them, turn off the <a href="/cgi-bin/koha/admin/preferences.pl?op=search&amp;searchfield=noItemTypeImages">noItemTypeImages or OpacNoItemTypeImages system preferences</a>
                     </li>
                 [% END %]
             </ol>
-            [% UNLESS Koha.Preference('noItemTypeImages') %]
+            [% UNLESS Koha.Preference('noItemTypeImages') && Koha.Preference('OpacNoItemTypeImages') %]
                 <div id="icons" class="toptabs" style="clear:both">
                     <h5 style="margin-left:10px;">Choose an icon:</h5>
                     <ul>
@@ -342,7 +342,7 @@ Item types administration
                 <td>[% itemtype.itemtype | html %]</td>
             </tr>
             <tr><th scope="row">Description</th><td>[% itemtype.translated_description | html %]</td></tr>
-            [% UNLESS Koha.Preference('noItemTypeImages') %]
+            [% UNLESS Koha.Preference('noItemTypeImages') && Koha.Preference('OpacNoItemTypeImages') %]
                 <tr>
                     <th scope="row">Image</th>
                     <td>
@@ -368,7 +368,7 @@ Item types administration
     [% IF itemtypes %]
         <table id="table_item_type">
           <thead>
-            [% UNLESS Koha.Preference('noItemTypeImages') %]<th class="noExport">Image</th>[% END %]
+            [% UNLESS Koha.Preference('noItemTypeImages') && Koha.Preference('OpacNoItemTypeImages') %]<th class="noExport">Image</th>[% END %]
             <th>Code</th>
             <th>Description</th>
             <th>Search category</th>
@@ -385,7 +385,7 @@ Item types administration
           </thead>
           [% FOREACH itemtype IN itemtypes %]
             <tr>
-                [% UNLESS Koha.Preference('noItemTypeImages') %]
+                [% UNLESS Koha.Preference('noItemTypeImages') && Koha.Preference('OpacNoItemTypeImages') %]
                     <td>
                         [% SET image_location = itemtype.image_location('intranet') %]
                         [% IF image_location %]<img src="[% image_location | html %]" alt="" />[% ELSE %]&nbsp;[% 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 %]
 
index 3764386..39df333 100644 (file)
@@ -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:
index f653396..634c2d0 100644 (file)
@@ -109,6 +109,13 @@ OPAC:
               class: file
             - '<br />Options:<ul><li><a href="#" class="set_syspref" data-syspref="OPACXSLTDetailsDisplay" data-value="">Leave empty</a> for "no xslt"</li><li>enter "<a href="#" class="set_syspref" data-syspref="OPACXSLTDetailsDisplay" data-value="default">default</a>" for the default one</li><li>put a path to define a xslt file</li><li>put an URL for an external specific stylesheet.</li></ul>{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:
                   yes: Show
index 33ec524..9eb252d 100644 (file)
     <table>
         <tr>
     [% FOREACH itemtypeloo IN advsearchloo.code_loop %]
-        <td><input type="checkbox" id="[% itemtypeloo.ccl FILTER remove(',') | html %]-[% itemtypeloo.number | html %]" name="limit" value="mc-[% itemtypeloo.ccl | html %]:[% itemtypeloo.code | html %]"/><label for="[% itemtypeloo.ccl FILTER remove(',') | html %]-[% itemtypeloo.number | html %]">[% UNLESS ( noItemTypeImages ) %][% IF ( itemtypeloo.imageurl ) %]<img src="[% itemtypeloo.imageurl | html %]" alt="[% itemtypeloo.description | html %]" />[% END %]&nbsp;[% END %]
+        <td><input type="checkbox" id="[% itemtypeloo.ccl FILTER remove(',') | html %]-[% itemtypeloo.number | html %]" name="limit" value="mc-[% itemtypeloo.ccl | html %]:[% itemtypeloo.code | html %]"/><label for="[% itemtypeloo.ccl FILTER remove(',') | html %]-[% itemtypeloo.number | html %]">[% UNLESS ( Koha.Preference('OpacNoItemTypeImages') ) %][% IF ( itemtypeloo.imageurl ) %]<img src="[% itemtypeloo.imageurl | html %]" alt="[% itemtypeloo.description | html %]" />[% END %]&nbsp;[% END %]
         [% itemtypeloo.description | html %]</label></td>
         [% IF ( loop.last ) %]</tr>[% ELSE %][% UNLESS ( loop.count % 5 ) %]</tr><tr>[% END %][% END %]
     [% END %]
index 6248b36..f1b4e6d 100644 (file)
                                                         value="[% IF ( itemtypeloo.cat == 1 ) %][% itemtypeloo.code | html %][% ELSE %]mc-[% itemtypeloo.ccl | html %]:[% itemtypeloo.code | html %][% END %]"
                                                     />
                                                     <label for="[% itemtypeloo.ccl FILTER remove(',') | html %]-[% itemtypeloo.number | html %]">
-                                                        [% UNLESS ( noItemTypeImages ) %]
+                                                        [% UNLESS ( Koha.Preference('OpacNoItemTypeImages')) %]
                                                             [% IF ( itemtypeloo.imageurl ) %]
                                                                 <img src="[% itemtypeloo.imageurl | html %]" alt="[% itemtypeloo.description | html %]" />
                                                             [% END %]
index b34c369..bf7f7c6 100644 (file)
                         [% END %]
 
                         [% UNLESS ( item_level_itypes ) %]
-                            [% IF ( imgeurl ) %]
+                            [% IF ( imgeurl && !Koha.Preference('OpacNoItemTypeImages') ) %]
                                 <img src="[% imageurl | html %]" alt="" />
                             [% END %]
                             <span class="results_summary itemtype"><span class="label">Item type: </span>
                 [% END %]
                     [% IF ( item_level_itypes ) %]
                         <td class="itype">
-                            [% UNLESS ( noItemTypeImages ) %]
+                            [% UNLESS ( Koha.Preference('OpacNoItemTypeImages') ) %]
                                 [% IF ( ITEM_RESULT.imageurl ) %]
                                     <img src="[% ITEM_RESULT.imageurl | html %]" title="[% ITEM_RESULT.description | html %]" alt="[% ITEM_RESULT.description | html %]" />
                                 [% END %]
index 238b2e5..91da402 100644 (file)
 
                                                 </td>
                                                 <td>
-                                                [% UNLESS ( noItemTypeImages ) %]
+                                                [% UNLESS ( Koha.Preference('OpacNoItemTypeImages') ) %]
                                                     [% IF ( issue.imageurl ) %]
                                                         <img src="[% issue.imageurl | html %]" alt="" />
                                                     [% END %]
index c1c24cd..0981abe 100644 (file)
 
                                                             [% IF ( item_level_itypes ) %]
                                                                 <td class="itype">
-                                                                    [% UNLESS ( noItemTypeImages ) %]
+                                                                    [% UNLESS ( Koha.Preference('OpacNoItemTypeImages') ) %]
                                                                         [% IF ( itemLoo.imageurl ) %]
                                                                             <img src="[% itemLoo.imageurl | html %]" alt="" />
                                                                         [% END %]
index 1001aab..f254c49 100644 (file)
                                                                 <a class="p1" href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% GROUP_RESULT.biblionumber |url %]">[% IF ( GROUP_RESULT.isbn ) %]<img src="https://images-na.ssl-images-amazon.com/images/P/[% GROUP_RESULT.isbn | html %].01.TZZZZZZZ.jpg" alt="" class="thumbnail" />[% ELSE %]<img src="http://g-images.amazon.com/images/G/01/x-site/icons/no-img-sm.gif" alt="" class="thumbnail" />[% END %]
                                                             </a>
                                                         [% ELSE %]
-                                                            [% UNLESS ( noItemTypeImages ) %]
+                                                            [% UNLESS ( Koha.Preference('OpacNoItemTypeImages') ) %]
                                                                 [% IF ( GROUP_RESULT.imageurl ) %]
                                                                     <img src="[% GROUP_RESULT.imageurl | html %]" title="[% GROUP_RESULT.description | html %]" />
                                                                 [% END %]
index c0212c4..a226cee 100644 (file)
                                                 [% END %]
                                             </td>
 
-                                            [% IF ( !item_level_itypes && !noItemTypeImages ) %]
+                                            [% IF ( !item_level_itypes && !Koha.Preference('OpacNoItemTypeImages') ) %]
                                                 [% # Cell 3: Show item type image %]
                                                 <td class="itypecol">
                                                     [% IF ( SEARCH_RESULT.imageurl ) %]
index dd99fa2..4673581 100644 (file)
                                                 <td class="select selectcol"><input type="checkbox" class="cb" name="biblionumber" value="[% itemsloo.biblionumber | html %]" /></td>
                                                 [% UNLESS ( item_level_itypes ) %]
                                                     <td>
-                                                        [% UNLESS ( noItemTypeImages ) %]
+                                                        [% UNLESS ( Koha.Preference('OpacNoItemTypeImages') ) %]
                                                             <img src="[% itemsloo.imageurl | html %]" alt="[% itemsloo.description | html %]" title="[% itemsloo.description | html %]" />
                                                         [% END %]
                                                         [% itemsloo.description | html %]
index b4c92c6..2562628 100644 (file)
                                                 [% UNLESS ( item_level_itypes ) %]
                                                     <td class="itype">
                                                         <span class="tdlabel">Item type:</span>
-                                                        [% IF ( ISSUE.imageurl ) %]
+                                                        [% IF ( ISSUE.imageurl && !Koha.Preference('OpacNoItemTypeImages') ) %]
                                                             <img src="[% ISSUE.imageurl | html %]" title="[% ISSUE.description | html %]" alt="[% ISSUE.description | html %]" />
                                                         [% END %] [% ISSUE.description | html %]
                                                     </td>
 
                                                 [% UNLESS ( item_level_itypes ) %]
                                                     <td>
-                                                        [% IF ( OVERDUE.imageurl ) %]
+                                                        [% IF ( OVERDUE.imageurl  && !Koha.Preference('OpacNoItemTypeImages') ) %]
                                                             <img src="[% OVERDUE.imageurl | html %]" title="[% OVERDUE.description | html %]" alt="[% OVERDUE.description | html %]" />
                                                         [% END %] [% OVERDUE.description | html %]
                                                     </td>