From ecf674c5a64b68ea625c5e74f018ebe126eec3b6 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 2 Jan 2013 10:06:11 -0500 Subject: [PATCH] Bug 7441 - search results showing wrong branch? - Followup - Use syspref for XSLT and non-XSLT --- C4/Search.pm | 16 +++--- C4/XSLT.pm | 2 +- Koha/Template/Plugin/Koha.pm | 49 ++++++++++++++++++++ installer/data/mysql/sysprefs.sql | 2 +- installer/data/mysql/updatedatabase.pl | 4 +- .../prog/en/modules/admin/preferences/opac.pref | 3 +- .../opac-tmpl/prog/en/modules/opac-results.tt | 9 +++- .../prog/en/xslt/MARC21slim2OPACResults.xsl | 10 ++-- .../prog/en/xslt/UNIMARCslim2OPACResults.xsl | 10 ++-- opac/opac-search.pl | 3 +- 10 files changed, 80 insertions(+), 28 deletions(-) create mode 100644 Koha/Template/Plugin/Koha.pm diff --git a/C4/Search.pm b/C4/Search.pm index 50f7d2b..faa90cb 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -1819,8 +1819,8 @@ sub searchResults { $item->{'branchname'} = $branches{$item->{$otherbranch}}; } - my $prefix = $item->{$hbranch} . '--' . $item->{location} . $item->{itype} . $item->{itemcallnumber}; -# For each grouping of items (onloan, available, unavailable), we build a key to store relevant info about that item + my $prefix = $item->{$hbranch} . '--' . $item->{location} . $item->{itype} . $item->{itemcallnumber}; + # For each grouping of items (onloan, available, unavailable), we build a key to store relevant info about that item my $userenv = C4::Context->userenv; if ( $item->{onloan} && !(C4::Members::GetHideLostItemsPreference($userenv->{'number'}) && $item->{itemlost}) ) { $onloan_count++; @@ -1930,12 +1930,12 @@ sub searchResults { else { $can_place_holds = 1; $available_count++; - $available_items->{$prefix}->{count}++ if $item->{$hbranch}; - foreach (qw(branchname itemcallnumber description)) { - $available_items->{$prefix}->{$_} = $item->{$_}; - } - $available_items->{$prefix}->{location} = $shelflocations->{ $item->{location} }; - $available_items->{$prefix}->{imageurl} = getitemtypeimagelocation( $search_context, $itemtypes{ $item->{itype} }->{imageurl} ); + $available_items->{$prefix}->{count}++ if $item->{$hbranch}; + foreach (qw(branchname itemcallnumber description homebranch holdingbranch)) { + $available_items->{$prefix}->{$_} = $item->{$_}; + } + $available_items->{$prefix}->{location} = $shelflocations->{ $item->{location} }; + $available_items->{$prefix}->{imageurl} = getitemtypeimagelocation( $search_context, $itemtypes{ $item->{itype} }->{imageurl} ); } } } # notforloan, item level and biblioitem level diff --git a/C4/XSLT.pm b/C4/XSLT.pm index 7fab3f8..d3089e0 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -188,7 +188,7 @@ sub XSLTParse4Display { UseAuthoritiesForTracings TraceSubjectSubdivisions Display856uAsImage OPACDisplay856uAsImage UseControlNumber IntranetBiblioDefaultView BiblioDefaultView - singleBranchMode OPACResultsBranchXSLT + singleBranchMode OPACResultsBranch AlternateHoldingsField AlternateHoldingsSeparator / ) { my $sp = C4::Context->preference( $syspref ); diff --git a/Koha/Template/Plugin/Koha.pm b/Koha/Template/Plugin/Koha.pm new file mode 100644 index 0000000..09bd97b --- /dev/null +++ b/Koha/Template/Plugin/Koha.pm @@ -0,0 +1,49 @@ +package Koha::Template::Plugin::Koha; + +# Copyright ByWater Solutions 2013 + +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Template::Plugin; +use base qw( Template::Plugin ); + +use C4::Koha; +use C4::Context; + +=pod + +This plugin contains various Koha replated Template Toolkit functions +to help streamline Koha and to move logic from the Perl code into the +Templates when it makes sense to do so. + +To use, first, include the line '[% USE Koha %]' at the top +of the template to enable the plugin. + +For example: [% IF Koha.Preference( 'MyPreference ) == 'SettingA' %] +removes the necessity of setting a template variable in Perl code for +each and every system preference, even if no evaluation of the setting +is necessary. + +=cut + +sub Preference { + my ( $self, $pref ) = @_; + return C4::Context->preference( $pref ); +} + +1; diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 85be65e..db2d1ce 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -406,4 +406,4 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES(' INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('NotesBlacklist','','List of notes fields that should not appear in the title notes/description separator of details',NULL,'free'); INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('SCOUserCSS', '', NULL, 'Add CSS to be included in the SCO module in an embedded