+
+ my $delflag = 0;
+
+ SWITCH: {
+ if ($op) {
+ unless ($okmanage) {
+ push @paramsloop, { nopermission => $shelfnumber };
+ last SWITCH;
+ }
+ if ( $op eq 'modifsave' ) {
+ my $shelf = {
+ 'shelfname' => $query->param('shelfname'),
+ 'category' => $query->param('category'),
+ 'sortfield' => $query->param('sortfield'),
+ };
+
+ ModShelf( $shelfnumber, $shelf );
+
+ } elsif ( $op eq 'modif' ) {
+ my ( $shelfnumber2, $shelfname, $owner, $category, $sortfield ) = GetShelf($shelfnumber);
+ my $member = GetMember( 'borrowernumber' => $owner );
+ my $ownername = defined($member) ? $member->{firstname} . " " . $member->{surname} : '';
+ $template->param(
+ edit => 1,
+ shelfnumber => $shelfnumber2,
+ shelfname => $shelfname,
+ owner => $owner,
+ ownername => $ownername,
+ "category$category" => 1,
+ category => $category,
+ "sort_$sortfield" => 1,
+ );
+ }
+ last SWITCH;
+ }
+ if ( $shelfnumber = $query->param('viewshelf') ) {
+ # explicitly fetch this shelf
+ my ($shelfnumber2,$shelfname,$owner,$category,$sorton) = GetShelf($shelfnumber);
+
+ $template->param( 'AllowOnShelfHolds' => C4::Context->preference('AllowOnShelfHolds') );
+ if (C4::Context->preference('TagsEnabled')) {
+ $template->param(TagsEnabled => 1);
+ foreach (qw(TagsShowOnList TagsInputOnList)) {
+ C4::Context->preference($_) and $template->param($_ => 1);
+ }
+ }
+ #check that the user can view the shelf
+ if ( ShelfPossibleAction( $loggedinuser, $shelfnumber, 'view' ) ) {
+ my $items;
+ my $authorsort;
+ my $yearsort;
+ my $tag_quantity;
+ my $sortfield = ( $query->param('sortfield') ? $query->param('sortfield') : 'title' );
+ if ( $sortfield eq 'author' ) {
+ $authorsort = 'author';
+ }
+ if ( $sortfield eq 'year' ) {
+ $yearsort = 'year';
+ }
+ ( $items, $totitems ) = GetShelfContents( $shelfnumber, $shelflimit, $shelfoffset );
+ for my $this_item (@$items) {
+ my $biblionumber = $this_item->{'biblionumber'};
+ my $record = GetMarcBiblio($biblionumber);
+ $this_item->{XSLTBloc} =
+ XSLTParse4Display($biblionumber, $record, 'Results', 'opac')
+ if C4::Context->preference("OPACXSLTResultsDisplay");
+
+ # the virtualshelfcontents table does not store these columns nor are they retrieved from the items
+ # and itemtypes tables, so I'm commenting them out for now to quiet the log -crn
+ #$this_item->{imageurl} = $imgdir."/".$itemtypes->{ $this_item->{itemtype} }->{'imageurl'};
+ #$this_item->{'description'} = $itemtypes->{ $this_item->{itemtype} }->{'description'};
+ $this_item->{'dateadded'} = format_date( $this_item->{'dateadded'} );
+ $this_item->{'imageurl'} = getitemtypeinfo( $this_item->{'itemtype'} )->{'imageurl'};
+ $this_item->{'coins'} = GetCOinSBiblio( $this_item->{'biblionumber'} );
+ $this_item->{'subtitle'} = GetRecordValue('subtitle', $record, GetFrameworkCode($this_item->{'biblionumber'}));
+ $this_item->{'normalized_upc'} = GetNormalizedUPC( $record,$marcflavour);
+ $this_item->{'normalized_ean'} = GetNormalizedEAN( $record,$marcflavour);
+ $this_item->{'normalized_oclc'} = GetNormalizedOCLCNumber($record,$marcflavour);
+ $this_item->{'normalized_isbn'} = GetNormalizedISBN(undef,$record,$marcflavour);
+ # Getting items infos for location display
+ my @items_infos = &GetItemsLocationInfo( $this_item->{'biblionumber'});
+ $this_item->{'itemsissued'} = CountItemsIssued( $this_item->{'biblionumber'} );
+ $this_item->{'ITEM_RESULTS'} = \@items_infos;
+
+ if (C4::Context->preference('TagsEnabled') and $tag_quantity = C4::Context->preference('TagsShowOnList')) {
+ $this_item->{'TagLoop'} = get_tags({
+ biblionumber=>$this_item->{'biblionumber'}, approved=>1, 'sort'=>'-weight',
+ limit=>$tag_quantity
+ });
+ }
+
+ }
+ push @paramsloop, { display => 'privateshelves' } if $category == 1;
+ $showadd = 1;
+ my $i = 0;
+ my $manageshelf = ShelfPossibleAction( $loggedinuser, $shelfnumber, 'manage' );
+ $template->param(
+ shelfname => $shelfname,
+ shelfnumber => $shelfnumber,
+ viewshelf => $shelfnumber,
+ authorsort => $authorsort,
+ yearsort => $yearsort,
+ manageshelf => $manageshelf,
+ itemsloop => $items,
+ );