X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=catalogue%2Fsearch.pl;h=b0fea2aa565704c78fd1530c72ea50a8b49c71a4;hb=ee3707d0de8ba0a0e88dcffad31f5b89997b3f5f;hp=8cb737d3233f52b8e4cf54f5d74e6bda85727f33;hpb=13bc505c5ffdd22533b49ddc4d1e79ecce49ed4d;p=koha_fer diff --git a/catalogue/search.pl b/catalogue/search.pl index 8cb737d323..b0fea2aa56 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -207,16 +207,20 @@ if (C4::Context->preference("marcflavour") eq "UNIMARC" ) { # load the branches my $branches = GetBranches(); -my @branch_loop; -# we need to know the borrower branch code to set a default branch -my $borrowerbranchcode = C4::Context->userenv->{'branch'}; - -for my $branch_hash (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %$branches) { - # if independantbranches is activated, set the default branch to the borrower branch - my $selected = (C4::Context->preference("independantbranches") and ($borrowerbranchcode eq $branch_hash)) ? 1 : undef; - push @branch_loop, {value => "$branch_hash" , branchname => $branches->{$branch_hash}->{'branchname'}, selected => $selected}; -} +# Populate branch_loop with all branches sorted by their name. If +# independantbranches is activated, set the default branch to the borrower +# branch, except for superlibrarian who need to search all libraries. +my $user = C4::Context->userenv; +my @branch_loop = map { + { + value => $_, + branchname => $branches->{$_}->{branchname}, + selected => $user->{branch} eq $_ && C4::Branch::onlymine(), + } +} sort { + $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} +} keys %$branches; my $categories = GetBranchCategories(undef,'searchdomain');