Lines 509-516
C<$opac> If set to a true value, displays OPAC descriptions rather than normal o
Link Here
|
509 |
=cut |
509 |
=cut |
510 |
|
510 |
|
511 |
sub GetAuthorisedValues { |
511 |
sub GetAuthorisedValues { |
512 |
my $category = shift // ''; # optional parameter |
512 |
my $category = shift // ''; # optional parameter |
513 |
my $opac = shift ? 1 : 0; # normalise to be safe |
513 |
my $opac = shift ? 1 : 0; # normalise to be safe |
|
|
514 |
my $options = shift // ''; |
515 |
my $no_limit = $options->{'no_limit'} if $options; #optional parameter to ignore library limitation |
514 |
|
516 |
|
515 |
# Is this cached already? |
517 |
# Is this cached already? |
516 |
my $branch_limit = C4::Context::mybranch(); |
518 |
my $branch_limit = C4::Context::mybranch(); |
Lines 521-541
sub GetAuthorisedValues {
Link Here
|
521 |
|
523 |
|
522 |
my @results; |
524 |
my @results; |
523 |
my $dbh = C4::Context->dbh; |
525 |
my $dbh = C4::Context->dbh; |
|
|
526 |
|
527 |
my $select_clause = 'SELECT av.*'; |
528 |
my @where_args; |
529 |
if ($branch_limit && $no_limit) { |
530 |
$select_clause .= ', IF (branchcode = ? OR branchcode IS NULL, 0, 1) as restricted'; |
531 |
push @where_args, $branch_limit; |
532 |
} |
524 |
my $query = qq{ |
533 |
my $query = qq{ |
525 |
SELECT DISTINCT av.* |
534 |
$select_clause |
526 |
FROM authorised_values av |
535 |
FROM authorised_values av |
527 |
}; |
536 |
}; |
528 |
$query .= qq{ |
537 |
$query .= qq{ |
529 |
LEFT JOIN authorised_values_branches ON ( id = av_id ) |
538 |
LEFT JOIN authorised_values_branches ON ( id = av_id ) |
530 |
} if $branch_limit; |
539 |
} if $branch_limit; |
531 |
my @where_strings; |
540 |
my @where_strings; |
532 |
my @where_args; |
541 |
if($category) { |
533 |
|
|
|
534 |
if ($category) { |
535 |
push @where_strings, "category = ?"; |
542 |
push @where_strings, "category = ?"; |
536 |
push @where_args, $category; |
543 |
push @where_args, $category; |
537 |
} |
544 |
} |
538 |
if ($branch_limit) { |
545 |
if($branch_limit && !defined $no_limit) { |
539 |
push @where_strings, "( branchcode = ? OR branchcode IS NULL )"; |
546 |
push @where_strings, "( branchcode = ? OR branchcode IS NULL )"; |
540 |
push @where_args, $branch_limit; |
547 |
push @where_args, $branch_limit; |
541 |
} |
548 |
} |