[Koha-patches] [PATCH] Bug 5977 : MT3617 : opac search advanced Library set to my library

Chris Cormack chrisc at catalyst.net.nz
Mon Mar 28 22:40:33 CEST 2011


From: Henri-Damien LAURENT <henridamien.laurent at biblibre.com>

Without any consideration of the System preference SearchMyLibraryFirst,
When patron is logged in, the library set is set to the patron's library.
This is not the expected behaviour and is implied by GetBranchesLoop
and the fact that users library is selected by default.

Overwriting this behaviour in opac-search.pl when user not logged in
or SearchMyLibraryFirst not set i.e. mybranch not set
---
 opac/opac-search.pl |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/opac/opac-search.pl b/opac/opac-search.pl
index d22049f..3ed7e1b 100755
--- a/opac/opac-search.pl
+++ b/opac/opac-search.pl
@@ -141,9 +141,17 @@ if (C4::Context->preference('TagsEnabled')) {
 
 # load the branches
 
-my $branches = GetBranches();   # used later in *getRecords, probably should be internalized by those functions after caching in C4::Branch is established
+my $mybranch = ( C4::Context->preference('SearchMyLibraryFirst') && C4::Context->userenv && C4::Context->userenv->{branch} ) ? C4::Context->userenv->{branch} : '';
+my $branches = GetBranches();    # used later in *getRecords, probably should be internalized by those functions after caching in C4::Branch is established
+my $branchloop = GetBranchesLoop( $mybranch, 0 );
+unless ($mybranch){
+    foreach (@$branchloop){
+        $_->{'selected'}=0;
+    }
+}
 $template->param(
-    searchdomainloop => GetBranchCategories(undef,'searchdomain'),
+    branchloop       => $branchloop,
+    searchdomainloop => GetBranchCategories( undef, 'searchdomain' ),
 );
 
 # load the language limits (for search)
-- 
1.7.1



More information about the Koha-patches mailing list