Lines 135-140
Not yet completed...
Link Here
|
135 |
use strict; # always use |
135 |
use strict; # always use |
136 |
#use warnings; FIXME - Bug 2505 |
136 |
#use warnings; FIXME - Bug 2505 |
137 |
|
137 |
|
|
|
138 |
use List::MoreUtils qw(any); |
139 |
|
138 |
## STEP 1. Load things that are used in both search page and |
140 |
## STEP 1. Load things that are used in both search page and |
139 |
# results page and decide which template to load, operations |
141 |
# results page and decide which template to load, operations |
140 |
# to perform, etc. |
142 |
# to perform, etc. |
Lines 179-187
else {
Link Here
|
179 |
flagsrequired => { catalogue => 1 }, |
181 |
flagsrequired => { catalogue => 1 }, |
180 |
} |
182 |
} |
181 |
); |
183 |
); |
|
|
184 |
|
182 |
if (C4::Context->preference("marcflavour") eq "UNIMARC" ) { |
185 |
if (C4::Context->preference("marcflavour") eq "UNIMARC" ) { |
183 |
$template->param('UNIMARC' => 1); |
186 |
$template->param('UNIMARC' => 1); |
184 |
} |
187 |
} |
|
|
188 |
|
185 |
if (C4::Context->preference("IntranetNumbersPreferPhrase")) { |
189 |
if (C4::Context->preference("IntranetNumbersPreferPhrase")) { |
186 |
$template->param('numbersphr' => 1); |
190 |
$template->param('numbersphr' => 1); |
187 |
} |
191 |
} |
Lines 226-245
my $branches = GetBranches();
Link Here
|
226 |
# Populate branch_loop with all branches sorted by their name. If |
230 |
# Populate branch_loop with all branches sorted by their name. If |
227 |
# IndependentBranches is activated, set the default branch to the borrower |
231 |
# IndependentBranches is activated, set the default branch to the borrower |
228 |
# branch, except for superlibrarian who need to search all libraries. |
232 |
# branch, except for superlibrarian who need to search all libraries. |
229 |
my $user = C4::Context->userenv; |
233 |
$template->param( |
230 |
my @branch_loop = map { |
234 |
branchloop => GetBranchesLoop(), |
231 |
{ |
235 |
searchdomainloop => GetBranchCategories( undef, 'searchdomain' ), |
232 |
value => $_, |
236 |
); |
233 |
branchname => $branches->{$_}->{branchname}, |
|
|
234 |
selected => $user->{branch} eq $_ && C4::Branch::onlymine(), |
235 |
} |
236 |
} sort { |
237 |
$branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} |
238 |
} keys %$branches; |
239 |
|
240 |
my $categories = GetBranchCategories(undef,'searchdomain'); |
241 |
|
242 |
$template->param(branchloop => \@branch_loop, searchdomainloop => $categories); |
243 |
|
237 |
|
244 |
# load the Type stuff |
238 |
# load the Type stuff |
245 |
my $itemtypes = GetItemTypes; |
239 |
my $itemtypes = GetItemTypes; |
Lines 411-417
my @operands = $cgi->param('q');
Link Here
|
411 |
# limits are use to limit to results to a pre-defined category such as branch or language |
405 |
# limits are use to limit to results to a pre-defined category such as branch or language |
412 |
my @limits = $cgi->param('limit'); |
406 |
my @limits = $cgi->param('limit'); |
413 |
|
407 |
|
414 |
if($params->{'multibranchlimit'}) { |
408 |
if ( C4::Context->preference('IndependentBranchesRecordsAndItems') ) { |
|
|
409 |
# Get list of branches this branch can access |
410 |
my @branches = GetIndependentGroupModificationRights(); |
411 |
|
412 |
# Strip out any branch search limits that are not in the list of allowable branches |
413 |
my $has_valid_branch_limits; # If at least one allowable branch limit is passed, |
414 |
# use the valid ones, otherwise make it an "all branches" |
415 |
# search with the allowed branches |
416 |
|
417 |
my @new_limits; |
418 |
foreach my $limit ( @limits ) { |
419 |
if ( $limit =~ /^branch:/ ) { |
420 |
my ( undef, $branch ) = split(':', $limit); |
421 |
push( @new_limits, $limit ) if any { $_ eq $branch } @branches; |
422 |
$has_valid_branch_limits = 1; |
423 |
} else { |
424 |
push( @new_limits, $limit ); |
425 |
} |
426 |
} |
427 |
@limits = @new_limits; |
428 |
|
429 |
# If the limits contain any branch limits, if not, do a search on all allowable branches |
430 |
unless ($has_valid_branch_limits) { |
431 |
my $new_branch_limit = |
432 |
'(' . join( " or ", map { "branch: $_ " } @branches ) . ')'; |
433 |
push( @limits, $new_branch_limit ); |
434 |
} |
435 |
} |
436 |
elsif( $params->{'multibranchlimit'} ) { |
415 |
my $multibranch = '('.join( " or ", map { "branch: $_ " } @{ GetBranchesInCategory( $params->{'multibranchlimit'} ) } ).')'; |
437 |
my $multibranch = '('.join( " or ", map { "branch: $_ " } @{ GetBranchesInCategory( $params->{'multibranchlimit'} ) } ).')'; |
416 |
push @limits, $multibranch if ($multibranch ne '()'); |
438 |
push @limits, $multibranch if ($multibranch ne '()'); |
417 |
} |
439 |
} |