@@ -, +, @@ --- C4/VirtualShelves/Page.pm | 17 ++++++++- Koha/Virtualshelves.pm | 43 ++++++++++++++++++++++ .../opac-tmpl/bootstrap/en/modules/opac-shelves.tt | 6 +-- 3 files changed, 61 insertions(+), 5 deletions(-) --- a/C4/VirtualShelves/Page.pm +++ a/C4/VirtualShelves/Page.pm @@ -90,7 +90,13 @@ sub shelfpage { # getting the Shelves list my $category = ( ( $displaymode eq 'privateshelves' ) ? 1 : 2 ); - my $shelflist = GetShelves( $category, $shelveslimit, $shelvesoffset, $loggedinuser ); + + my $shelflist; + if ( $category == 2 ) { + $shelflist = Koha::Virtualshelves->get_public_shelves({ limit => $shelveslimit, offset => $shelvesoffset }); + } else { + $shelflist = Koha::Virtualshelves->get_private_shelves({ limit => $shelveslimit, offset => $shelvesoffset, borrowernumber => $loggedinuser }); + } my $totshelves = C4::VirtualShelves::GetShelfCount( $loggedinuser, $category ); my $op = $query->param('op'); @@ -443,7 +449,14 @@ sub shelfpage { my $numberCanManage = 0; # rebuild shelflist in case a shelf has been added - $shelflist = GetShelves( $category, $shelveslimit, $shelvesoffset, $loggedinuser ) unless $delflag; + unless ( $delflag ) { + if ( $category == 2 ) { + $shelflist = Koha::Virtualshelves->get_public_shelves({ limit => $shelveslimit, offset => $shelvesoffset }); + } else { + $shelflist = Koha::Virtualshelves->get_private_shelves({ limit => $shelveslimit, offset => $shelvesoffset, borrowernumber => $loggedinuser }); + } + } + $totshelves = C4::VirtualShelves::GetShelfCount( $loggedinuser, $category ) unless $delflag; foreach my $element ( sort { lc( $shelflist->{$a}->{'shelfname'} ) cmp lc( $shelflist->{$b}->{'shelfname'} ) } keys %$shelflist ) { my %line; --- a/Koha/Virtualshelves.pm +++ a/Koha/Virtualshelves.pm @@ -39,6 +39,49 @@ Koha::Virtualshelf - Koha Virtualshelf Object class =cut +sub get_private_shelves { + my ( $self, $params ) = @_; + my $limit = $params->{limit}; + my $offset = $params->{offset} || 0; + my $borrowernumber = $params->{borrowernumber}; + + $self->search( + { + 'virtualshelfshares.borrowernumber' => $borrowernumber, + category => 1, + -or => { + 'virtualshelfshares.owner' => $borrowernumber, + 'virtualshelves.borrowernumber' => $borrowernumber, + } + }, + { + join => ['borrowers', 'virtualshelfcontents', 'virtualshelfshares' ], + group_by => 'shelfnumber', + order_by => 'shelfname', + limit => "$limit,$offset", + } + ); +} + + +sub get_public_shelves { + my ( $self, $params ) = @_; + my $limit = $params->{limit}; + my $offset = $params->{offset} || 0; + + $self->search( + { + category => 1, + }, + { + join => [ 'virtualshelfcontents' ], + group_by => 'shelfnumber', + order_by => 'shelfname', + limit => "$limit,$offset", + } + ); +} + sub type { return 'Virtualshelve'; } --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt +++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt @@ -115,7 +115,7 @@ [% IF ( paramsloo.need_confirm ) %]
The list [% paramsloo.need_confirm %] is not empty. -
It has [% paramsloo.count %] [% IF ( paramsloo.single ) %]entry[% ELSE %]entries[% END %]. +
It has [% paramsloo.count %] [% IF paramsloo.count == 1 %]entry[% ELSE %]entries[% END %].
Use the "Confirm" button below to confirm deletion.
[% END %] @@ -642,7 +642,7 @@ [% FOREACH shelveslooppri IN shelveslooppriv %] [% shelveslooppri.shelfname |html %] - [% IF ( shelveslooppri.count ) %][% shelveslooppri.count %] [% IF ( shelveslooppri.single ) %]item[% ELSE %]items[% END %][% ELSE %]Empty[% END %] + [% IF ( shelveslooppri.count ) %][% shelveslooppri.count %] [% IF shelveslooppri.count == 1 %]item[% ELSE %]items[% END %][% ELSE %]Empty[% END %] [% IF ( shelveslooppri.viewcategory1 ) %][% IF !shelveslooppri.shares %]Private[% ELSE %]Shared[% END %][% END %] @@ -716,7 +716,7 @@ [% FOREACH shelvesloo IN shelvesloop %] [% shelvesloo.shelfname |html %] - [% shelvesloo.count %] [% IF ( shelvesloo.single ) %]item[% ELSE %]item(s)[% END %] + [% shelvesloo.count %] [% IF shelvesloo.count == 1 %]item[% ELSE %]item(s)[% END %] [% IF ( shelvesloo.viewcategory2 ) %]Public[% END %] --