use Memoize;
use DateTime::Format::MySQL;
use autouse 'Data::Dumper' => qw(Dumper);
+use DBI qw(:sql_types);
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $DEBUG);
{
idx => 'location',
label => 'Location',
- tags => [ qw/ 995c / ],
+ tags => [ qw/ 995e / ],
}
];
- my $library_facet;
- unless ( C4::Context->preference("singleBranchMode") || GetBranchesCount() == 1 ) {
- $library_facet = {
- idx => 'branch',
- label => 'Libraries',
- tags => [ qw/ 995b / ],
- };
+ unless ( C4::Context->preference("singleBranchMode")
+ || GetBranchesCount() == 1 )
+ {
+ my $DisplayLibraryFacets = C4::Context->preference('DisplayLibraryFacets');
+ if ( $DisplayLibraryFacets eq 'both'
+ || $DisplayLibraryFacets eq 'holding' )
+ {
+ push(
+ @$facets,
+ {
+ idx => 'holdingbranch',
+ label => 'HoldingLibrary',
+ tags => [qw / 995b /],
+ }
+ );
+ }
+
+ if ( $DisplayLibraryFacets eq 'both'
+ || $DisplayLibraryFacets eq 'home' )
+ {
+ push(
+ @$facets,
+ {
+ idx => 'homebranch',
+ label => 'HomeLibrary',
+ tags => [qw / 995a /],
+ }
+ );
+ }
}
- push( @$facets, $library_facet );
}
else {
$facets = [
},
];
- my $library_facet;
- unless ( C4::Context->preference("singleBranchMode") || GetBranchesCount() == 1 ) {
- $library_facet = {
- idx => 'branch',
- label => 'Libraries',
- tags => [ qw / 952b / ],
- };
+ unless ( C4::Context->preference("singleBranchMode")
+ || GetBranchesCount() == 1 )
+ {
+ my $DisplayLibraryFacets = C4::Context->preference('DisplayLibraryFacets');
+ if ( $DisplayLibraryFacets eq 'both'
+ || $DisplayLibraryFacets eq 'holding' )
+ {
+ push(
+ @$facets,
+ {
+ idx => 'holdingbranch',
+ label => 'HoldingLibrary',
+ tags => [qw / 952b /],
+ }
+ );
+ }
+
+ if ( $DisplayLibraryFacets eq 'both'
+ || $DisplayLibraryFacets eq 'home' )
+ {
+ push(
+ @$facets,
+ {
+ idx => 'homebranch',
+ label => 'HomeLibrary',
+ tags => [qw / 952a /],
+ }
+ );
+ }
}
- push( @$facets, $library_facet );
}
return $facets;
}
$sth = C4::Context->dbh->prepare('SELECT count(*) FROM quotes;');
$sth->execute;
my $range = ($sth->fetchrow_array)[0];
- if ($range > 1) {
- # chose a random id within that range if there is more than one quote
- my $id = int(rand($range));
- # grab it
- $query = 'SELECT * FROM quotes WHERE id = ?;';
- $sth = C4::Context->dbh->prepare($query);
- $sth->execute($id);
- }
- else {
- $query = 'SELECT * FROM quotes;';
- $sth = C4::Context->dbh->prepare($query);
- $sth->execute();
- }
+ # chose a random id within that range if there is more than one quote
+ my $offset = int(rand($range));
+ # grab it
+ $query = 'SELECT * FROM quotes ORDER BY id LIMIT 1 OFFSET ?';
+ $sth = C4::Context->dbh->prepare($query);
+ # see http://www.perlmonks.org/?node_id=837422 for why
+ # we're being verbose and using bind_param
+ $sth->bind_param(1, $offset, SQL_INTEGER);
+ $sth->execute();
$quote = $sth->fetchrow_hashref();
# update the timestamp for that quote
$query = 'UPDATE quotes SET timestamp = ? WHERE id = ?';
return;
}
-=head2 Log( $message );
-
- Writes data to /tmp/koha.log.
-
- This is useful for debugging forked processes
- that do not write to the apache error log
-
-=cut
-
-sub Log {
- my ($data) = @_;
- warn $data;
- open my $fh, '>>/tmp/koha.log';
- print $fh "$data\n";
- close $fh;
-}
1;
__END__