use Koha::Virtualshelf;
+
use base qw(Koha::Objects);
=head1 NAME
$self->search(
{
- category => 1,
+ public => 0,
-or => {
'virtualshelfshares.borrowernumber' => $borrowernumber,
'me.owner' => $borrowernumber,
$self->search(
{
- category => 2,
+ public => 1,
},
{
distinct => 'shelfnumber',
sub get_some_shelves {
my ( $self, $params ) = @_;
my $borrowernumber = $params->{borrowernumber} || 0;
- my $category = $params->{category} || 1;
+ my $public = $params->{public} || 0;
my $add_allowed = $params->{add_allowed};
my @conditions;
+ my $patron;
+ my $staffuser = 0;
+ if ( $borrowernumber != 0 ) {
+ $patron = Koha::Patrons->find( $borrowernumber );
+ $staffuser = $patron->can_patron_change_staff_only_lists;
+ }
if ( $add_allowed ) {
- push @conditions, {
- -or =>
- [
- {
- "me.owner" => $borrowernumber,
- "me.allow_change_from_owner" => 1,
- },
- "me.allow_change_from_others" => 1,
- ]
- };
+ if ( $staffuser ) {
+ push @conditions, {
+ -or =>
+ [
+ {
+ "me.owner" => $borrowernumber,
+ "me.allow_change_from_owner" => 1,
+ },
+ "me.allow_change_from_others" => 1,
+ "me.allow_change_from_staff" => 1
+ ]
+ };
+ } else {
+ push @conditions, {
+ -or =>
+ [
+ {
+ "me.owner" => $borrowernumber,
+ "me.allow_change_from_owner" => 1,
+ },
+ "me.allow_change_from_others" => 1,
+ ]
+ };
+ }
}
- if ( $category == 1 ) {
+ if ( !$public ) {
push @conditions, {
-or =>
{
$self->search(
{
- category => $category,
+ public => $public,
( @conditions ? ( -and => \@conditions ) : () ),
},
{
{
-or => [
{
- category => 1,
+ public => 0,
-or => {
'me.owner' => $borrowernumber,
-or => {
},
}
},
- { category => 2 },
+ { public => 1 },
]
};
} else {
- push @conditions, { category => 2 };
+ push @conditions, { public => 1 };
}
return Koha::Virtualshelves->search(