OPAC Advanced Search - have user's branch selected by default
authorMichael Hafen <mdhafen@tech.washk12.org>
Tue, 28 Apr 2009 20:16:31 +0000 (14:16 -0600)
committerHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Tue, 26 May 2009 19:15:20 +0000 (21:15 +0200)
If SearchMyLibraryFirst is on, and the user is logged in, then have
their branch selected in the Location And Availability drop-down.

Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
Signed-off-by: Henri-Damien LAURENT <henridamien.laurent@biblibre.com>
opac/opac-search.pl

index c4b078b..82e67b4 100755 (executable)
@@ -115,10 +115,15 @@ if (C4::Context->preference('TagsEnabled')) {
 #}
 
 # load the branches
+my $mybranch = ( C4::Context->preference( 'SearchMyLibraryFirst' ) && C4::Context->userenv ) ? C4::Context->userenv->{branch} : '';
 my $branches = GetBranches();
 # FIXME: next line duplicates GetBranchesLoop(0,0);
 my @branch_loop = map {
-                    {value => $_, branchname => $branches->{$_}->{branchname}}
+                    {
+                        value => $_,
+                        branchname => $branches->{$_}->{branchname},
+                        selected => ( $mybranch eq $_ ) ? 1 : 0
+                    }
                 } sort {
                     $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname}
                 } keys %$branches;