Bug 4103 In Pro Adv Search, superlibrarian search always all libraries

Now, when 'independantbranches' syspref is activated, 'Individual Libraries'
combo list is set by default to the current user branch. It shouldn't be the
case for superlibrarian user who is supposed to manage all libraries.

Signed-off-by: Nicole C. Engard <nengard@bywatersolutions.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
This commit is contained in:
Frédéric Demians 2011-02-27 04:20:33 -05:00 committed by Chris Cormack
parent de6b9fc534
commit ee3707d0de
1 changed files with 13 additions and 9 deletions

View File

@ -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');