Bug 16041: Turn off StaffAuthorisedValueImages by default
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 30 Mar 2016 07:42:12 +0000 (08:42 +0100)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 29 Apr 2016 13:47:26 +0000 (13:47 +0000)
This feature is enabled by default, but the users are not aware of it
and it costs a lot of time processing to get the images.

There are 2 prefs to drive this feature: StaffAuthorisedValueImages and
AuthorisedValueImages. AuthorisedValueImages is not added by sysprefs.sql and
does not appear in updatedatabase.pl, we could easily imagine that
nobody uses it.
With XSLT enabled, the feature is only visible on a record detail page
at the OPAC, if AuthorisedValueImages is set.
Otherwise you need to turn the XSLT off. In this case you will see the
images on the result list (OPAC+Staff interfaces) and OPAC detail page,
but not the Staff detail page.

The idea of this patch is to introduce a quick switch if the feature is
not used by the library.

Test plan:
1/ Turn the pref on and set authorised_values.imageurl to NULL
Execute the DB entry
=> The pref have been turned off
2/ Turn the pref on and set an image for an authorised value
Execute the DB entry
You will get a warning
3/ Turn the pref off and set an image for an authorised value
Execute the DB entry
You will get a warning
4/ Turn the pref off and set authorised_values.imageurl to NULL
Execute the DB entry
You won't get a warning

Note that the opac detail page now checks the pref before retrieving the
images.

Followed test plan, works as expected.
Signed-off-by: Marc VĂ©ron <veron@veron.ch>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Fixed update message 'that means'.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
installer/data/mysql/atomicupdate/bug_16041.perl [new file with mode: 0644]
installer/data/mysql/sysprefs.sql
opac/opac-detail.pl

diff --git a/installer/data/mysql/atomicupdate/bug_16041.perl b/installer/data/mysql/atomicupdate/bug_16041.perl
new file mode 100644 (file)
index 0000000..809325c
--- /dev/null
@@ -0,0 +1,23 @@
+my $dbh = C4::Context->dbh;
+my ( $count_imageurl ) = $dbh->selectrow_array(q|
+    SELECT COUNT(*)
+    FROM authorised_values
+    WHERE imageurl IS NOT NULL
+        AND imageurl <> ""
+|);
+unless ( $count_imageurl ) {
+    if ( C4::Context->preference('AuthorisedValueImages')
+        or C4::Context->preference('StaffAuthorisedValueImages') ) {
+        $dbh->do(q|
+            UPDATE systempreferences
+            SET value=0
+            WHERE variable="AuthorisedValueImages"
+               or variable="StaffAuthorisedValueImages"
+        |);
+        warn "The system preferences AuthorisedValueImages and StaffAuthorisedValueImages have been turned off\n";
+        warn "authorised_values.imageurl is not populated, that means you are not using this feature\n"
+    }
+} else {
+    warn "At least one authorised value has an icon defined (imageurl)\n";
+    warn "The system preference AuthorisedValueImages or StaffAuthorisedValueImages could be turned off if you are not aware of this feature\n";
+}
index 22d04f0..6cf083f 100644 (file)
@@ -450,7 +450,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
 ('SpineLabelAutoPrint','0','','If this setting is turned on, a print dialog will automatically pop up for the quick spine label printer.','YesNo'),
 ('SpineLabelFormat','<itemcallnumber><copynumber>','30|10','This preference defines the format for the quick spine label printer. Just list the fields you would like to see in the order you would like to see them, surrounded by <>, for example <itemcallnumber>.','Textarea'),
 ('SpineLabelShowPrintOnBibDetails','0','','If turned on, a \"Print Label\" link will appear for each item on the bib details page in the staff interface.','YesNo'),
-('StaffAuthorisedValueImages','1',NULL,'','YesNo'),
+('StaffAuthorisedValueImages','0',NULL,'','YesNo'),
 ('staffClientBaseURL','',NULL,'Specify the base URL of the staff client','free'),
 ('StaffDetailItemSelection', '1', NULL, 'Enable item selection in record detail page', 'YesNo'),
 ('StaffSearchResultsDisplayBranch','holdingbranch','holdingbranch|homebranch','Controls the display of the home or holding branch for staff search results','Choice'),
index 3d8025c..f1f3344 100755 (executable)
@@ -560,7 +560,9 @@ foreach my $subscription (@subscriptions) {
 $dat->{'count'} = scalar(@items);
 
 
-my $biblio_authorised_value_images = C4::Items::get_authorised_value_images( C4::Biblio::get_biblio_authorised_values( $biblionumber, $record ) );
+my $biblio_authorised_value_images = C4::Context->preference('AuthorisedValueImages')
+    ? C4::Items::get_authorised_value_images( C4::Biblio::get_biblio_authorised_values( $biblionumber, $record ) )
+    : [];
 
 my (%item_reserves, %priority);
 my ($show_holds_count, $show_priority);