1 package Koha::Virtualshelves;
3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
23 use Koha::Virtualshelf;
25 use base qw(Koha::Objects);
29 Koha::Virtualshelf - Koha Virtualshelf Object class
41 sub get_private_shelves {
42 my ( $self, $params ) = @_;
43 my $page = $params->{page};
44 my $rows = $params->{rows};
45 my $borrowernumber = $params->{borrowernumber} || 0;
51 'virtualshelfshares.borrowernumber' => $borrowernumber,
52 'me.owner' => $borrowernumber,
56 join => [ 'virtualshelfshares' ],
57 distinct => 'shelfnumber',
58 order_by => 'shelfname',
59 ( ( $page and $rows ) ? ( page => $page, rows => $rows ) : () ),
65 sub get_public_shelves {
66 my ( $self, $params ) = @_;
67 my $page = $params->{page};
68 my $rows = $params->{rows};
75 distinct => 'shelfnumber',
76 order_by => 'shelfname',
77 ( ( $page and $rows ) ? ( page => $page, rows => $rows ) : () ),
82 sub get_some_shelves {
83 my ( $self, $params ) = @_;
84 my $borrowernumber = $params->{borrowernumber} || 0;
85 my $category = $params->{category} || 1;
86 my $add_allowed = $params->{add_allowed};
94 "me.owner" => $borrowernumber,
95 "me.allow_change_from_owner" => 1,
97 "me.allow_change_from_others" => 1,
101 if ( $category == 1 ) {
105 "virtualshelfshares.borrowernumber" => $borrowernumber,
106 "me.owner" => $borrowernumber,
113 category => $category,
114 ( @conditions ? ( -and => \@conditions ) : () ),
117 join => [ 'virtualshelfshares' ],
118 distinct => 'shelfnumber',
119 order_by => { -desc => 'lastmodified' },
124 sub get_shelves_containing_record {
125 my ( $self, $params ) = @_;
126 my $borrowernumber = $params->{borrowernumber};
127 my $biblionumber = $params->{biblionumber};
129 my @conditions = ( 'virtualshelfcontents.biblionumber' => $biblionumber );
130 if ($borrowernumber) {
137 'me.owner' => $borrowernumber,
139 'virtualshelfshares.borrowernumber' => $borrowernumber,
147 push @conditions, { category => 2 };
150 return Koha::Virtualshelves->search(
155 join => [ 'virtualshelfcontents', 'virtualshelfshares' ],
156 distinct => 'shelfnumber',
157 order_by => { -asc => 'shelfname' },
163 return 'Virtualshelve';
167 return 'Koha::Virtualshelf';