my $template_name = $query->param('rss') ? "opac-shelves-rss.tt" : "opac-shelves.tt";
+# if virtualshelves is disabled, leave immediately
+if ( ! C4::Context->preference('virtualshelves') ) {
+ print $query->redirect("/cgi-bin/koha/errors/404.pl");
+ exit;
+}
+
my ( $template, $loggedinuser, $cookie ) = get_template_and_user({
template_name => $template_name,
query => $query,
if ( $loggedinuser ) {
eval {
$shelf = Koha::Virtualshelf->new(
- { shelfname => $query->param('shelfname'),
- sortfield => $query->param('sortfield'),
- category => $query->param('category') || 1,
- allow_add => $query->param('allow_add'),
- allow_delete_own => $query->param('allow_delete_own'),
- allow_delete_other => $query->param('allow_delete_other'),
- owner => $loggedinuser,
+ { shelfname => scalar $query->param('shelfname'),
+ sortfield => scalar $query->param('sortfield'),
+ category => scalar $query->param('category') || 1,
+ allow_add => scalar $query->param('allow_add'),
+ allow_delete_own => scalar $query->param('allow_delete_own'),
+ allow_delete_other => scalar $query->param('allow_delete_other'),
+ owner => scalar $loggedinuser,
}
);
$shelf->store;
} elsif ( $op eq 'remove_biblios' ) {
$shelfnumber = $query->param('shelfnumber');
$shelf = Koha::Virtualshelves->find($shelfnumber);
- my @biblionumber = $query->param('biblionumber');
+ my @biblionumber = $query->multi_param('biblionumber');
if ($shelf) {
if ( $shelf->can_biblios_be_removed( $loggedinuser ) ) {
my $number_of_biblios_removed = eval {
$category = $shelf->category;
my $sortfield = $query->param('sortfield') || $shelf->sortfield; # Passed in sorting overrides default sorting
my $direction = $query->param('direction') || 'asc';
+ $direction = 'asc' if $direction ne 'asc' and $direction ne 'desc';
my ( $page, $rows );
unless ( $query->param('print') or $query->param('rss') ) {
$rows = C4::Context->preference('OPACnumSearchResults') || 20;
$page = ( $query->param('page') ? $query->param('page') : 1 );
}
- my $contents = $shelf->get_contents->search({}, { join => [ 'biblionumber' ], page => $page, rows => $rows, order_by => "$sortfield $direction", });
+ my $order_by = $sortfield eq 'itemcallnumber' ? 'items.itemcallnumber' : $sortfield;
+ my $contents = $shelf->get_contents->search(
+ {},
+ {
+ prefetch => [ { 'biblionumber' => { 'biblioitems' => 'items' } } ],
+ page => $page,
+ rows => $rows,
+ order_by => { "-$direction" => $order_by },
+ }
+ );
# get biblionumbers stored in the cart
my @cart_list;
my $borrower = GetMember( borrowernumber => $loggedinuser );
+ my $xslfile = C4::Context->preference('OPACXSLTResultsDisplay');
+ my $lang = $xslfile ? C4::Languages::getlanguage() : undef;
+ my $sysxml = $xslfile ? C4::XSLT::get_xslt_sysprefs() : undef;
+
my @items;
while ( my $content = $contents->next ) {
- my $this_item;
my $biblionumber = $content->biblionumber->biblionumber;
+ my $this_item = GetBiblioData($biblionumber);
my $record = GetMarcBiblio($biblionumber);
- if ( C4::Context->preference("OPACXSLTResultsDisplay") ) {
- $this_item->{XSLTBloc} = XSLTParse4Display( $biblionumber, $record, "OPACXSLTResultsDisplay" );
+ if ( $xslfile ) {
+ $this_item->{XSLTBloc} = XSLTParse4Display( $biblionumber, $record, "OPACXSLTResultsDisplay",
+ 1, undef, $sysxml, $xslfile, $lang);
}
my $marcflavour = C4::Context->preference("marcflavour");
- my $itemtypeinfo = getitemtypeinfo( $content->biblionumber->biblioitems->first->itemtype, 'intranet' );
+ my $itemtypeinfo = getitemtypeinfo( $content->biblionumber->biblioitems->first->itemtype, 'opac' );
$this_item->{imageurl} = $itemtypeinfo->{imageurl};
$this_item->{description} = $itemtypeinfo->{description};
$this_item->{notforloan} = $itemtypeinfo->{notforloan};
shelf => $shelf,
messages => \@messages,
category => $category,
- print => $query->param('print') || 0,
+ print => scalar $query->param('print') || 0,
listsview => 1,
);