From 415ce8d40fce29845a8f5811ec82bc29308d99ec Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 30 Mar 2016 08:42:12 +0100 Subject: [PATCH] Bug 16041: Turn off StaffAuthorisedValueImages by default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- installer/data/mysql/atomicupdate/bug_16041.perl | 23 ++++++++++++++++++++++ installer/data/mysql/sysprefs.sql | 2 +- opac/opac-detail.pl | 4 +++- 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_16041.perl diff --git a/installer/data/mysql/atomicupdate/bug_16041.perl b/installer/data/mysql/atomicupdate/bug_16041.perl new file mode 100644 index 0000000..7aa8414 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_16041.perl @@ -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's mean 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"; +} diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index ef4c3f0..2ab3ccc 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -446,7 +446,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','','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 .','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'), diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 6d71bed..da94801 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -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); -- 1.7.10.4