From 5af8e4821466bb0abf9c8a987059dc3d491d5f6b 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 Signed-off-by: Bernardo Gonzalez Kriegel Comment: Applied all patches. Tested with and without XLST display. Works as described. No errors. Not tested with UNIMARC Signed-off-by: Chris Rohde --- C4/Search.pm | 16 ++++++++-------- C4/XSLT.pm | 2 +- Koha/Template/Plugin/Koha.pm | 1 + installer/data/mysql/sysprefs.sql | 2 +- installer/data/mysql/updatedatabase.pl | 4 ++-- .../prog/en/modules/admin/preferences/opac.pref | 3 +-- koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt | 9 +++++++-- .../opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl | 10 +++++----- .../opac-tmpl/prog/en/xslt/UNIMARCslim2OPACResults.xsl | 10 +++++----- 9 files changed, 31 insertions(+), 26 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index aec024b..39fd74e 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -1865,8 +1865,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++; @@ -1975,12 +1975,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 54aff60..74f3183 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -207,7 +207,7 @@ sub XSLTParse4Display { UseControlNumber IntranetBiblioDefaultView BiblioDefaultView singleBranchMode OPACItemLocation DisplayIconsXSLT AlternateHoldingsField AlternateHoldingsSeparator - TrackClicks OPACResultsBranchXSLT / ) + TrackClicks OPACResultsBranch / ) { my $sp = C4::Context->preference( $syspref ); next unless defined($sp); diff --git a/Koha/Template/Plugin/Koha.pm b/Koha/Template/Plugin/Koha.pm index 2eff9f1..4962552 100644 --- a/Koha/Template/Plugin/Koha.pm +++ b/Koha/Template/Plugin/Koha.pm @@ -21,6 +21,7 @@ use Modern::Perl; use base qw( Template::Plugin ); +use C4::Koha; use C4::Context; =pod diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 9ec8a49..8c86844 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -427,4 +427,4 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES(' INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('UseCourseReserves', '0', 'Enable the course reserves feature.', NULL, 'YesNo'); INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacHoldNotes',0,'Show hold notes on OPAC','','YesNo'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('CalculateFinesOnReturn','1','Switch to control if overdue fines are calculated on return or not', '', 'YesNo'); -INSERT INTO systempreferences (variable, value, options, explanation, type) VALUES ('OPACResultsBranchXSLT', 'homebranch', 'homebranch|holdingbranch', 'Defines whether the OPAC displays the holding or home branch in search results when using XSLT', 'Choice'); +INSERT INTO systempreferences (variable, value, options, explanation, type) VALUES ('OPACResultsBranch', 'homebranch', 'homebranch|holdingbranch', 'Defines whether the OPAC displays the holding or home branch in search results.', 'Choice'); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 9d80dec..bda914e 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -7012,8 +7012,8 @@ CREATE TABLE IF NOT EXISTS borrower_files ( $DBversion = "3.13.00.XXX"; if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { - $dbh->do("INSERT INTO systempreferences (variable, value, options, explanation, type) VALUES ('OPACResultsBranchXSLT', 'homebranch', 'homebranch|holdingbranch', 'Defines whether the OPAC displays the holding or home branch in search results when using XSLT', 'Choice')"); - print "Upgrade to $DBversion done (Add syspref OPACResultsBranchXSLT)\n"; + $dbh->do("INSERT INTO systempreferences (variable, value, options, explanation, type) VALUES ('OPACResultsBranch', 'homebranch', 'homebranch|holdingbranch', 'Defines whether the OPAC displays the holding or home branch in search results when using XSLT', 'Choice')"); + print "Upgrade to $DBversion done (Add syspref OPACResultsBranch)\n"; SetVersion($DBversion); } 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 e377fd6..9406ecc 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 @@ -84,11 +84,10 @@ OPAC: - the format, audience, and material type icons in XSLT MARC21 results and detail pages in the OPAC. - - On search result pages displayed with XSLT stylesheets on the OPAC, show the item's - - pref: OPACResultsBranchXSLT + - pref: OPACResultsBranch choices: holdingbranch: "holding branch" homebranch: "home branch" - - icons for itemtype and authorized values. - - pref: COinSinOPACResults choices: diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt index 923effa..64ff3fa 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt @@ -1,3 +1,5 @@ +[% USE Koha %] +[% USE KohaBranchName %] [% SET TagsShowEnabled = ( TagsEnabled && TagsShowOnList ) %] [% SET TagsInputEnabled = ( opacuserlogin && TagsEnabled && TagsInputOnList ) %] @@ -538,9 +540,12 @@ $(document).ready(function(){ [% IF ( singleBranchMode ) %] [% available_items_loo.location %] [% ELSE %] - [% available_items_loo.branchname %] + [% IF Koha.Preference('OPACResultsBranch') == 'homebranch' %] + [% available_items_loo.homebranch | $KohaBranchName %] + [% ELSE %] + [% available_items_loo.holdingbranch | $KohaBranchName %] + [% END %] [% END %] - [% IF ( OPACItemsResultsDisplay ) %] [% UNLESS ( singleBranchMode ) %][% available_items_loo.location %][% END %] [% IF ( available_items_loo.itemcallnumber ) %][[% available_items_loo.itemcallnumber %]][% END %] diff --git a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl index 08a5139..1e9bbf4 100644 --- a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl +++ b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl @@ -20,7 +20,7 @@ - + @@ -1064,7 +1064,7 @@ - + [] @@ -1074,7 +1074,7 @@ . , - + [] @@ -1099,7 +1099,7 @@ - + [] @@ -1109,7 +1109,7 @@ . , - + [] diff --git a/koha-tmpl/opac-tmpl/prog/en/xslt/UNIMARCslim2OPACResults.xsl b/koha-tmpl/opac-tmpl/prog/en/xslt/UNIMARCslim2OPACResults.xsl index 77315e1..89240fe 100644 --- a/koha-tmpl/opac-tmpl/prog/en/xslt/UNIMARCslim2OPACResults.xsl +++ b/koha-tmpl/opac-tmpl/prog/en/xslt/UNIMARCslim2OPACResults.xsl @@ -28,7 +28,7 @@ - + @@ -147,7 +147,7 @@ - + [] @@ -157,7 +157,7 @@ . , - + [] @@ -180,7 +180,7 @@ - + [] @@ -190,7 +190,7 @@ . , - + [] -- 1.7.10.4