@@ -, +, @@ list --- Koha/Virtualshelf.pm | 5 ++--- .../intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt | 1 + koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt | 2 +- t/db_dependent/Virtualshelves.t | 13 +++++-------- 4 files changed, 9 insertions(+), 12 deletions(-) --- a/Koha/Virtualshelf.pm +++ a/Koha/Virtualshelf.pm @@ -192,7 +192,7 @@ sub remove_biblios { my $number_removed = 0; for my $biblionumber ( @$biblionumbers ) { - if ( $self->owner == $borrowernumber or $self->allow_delete_own ) { + if ( $self->allow_delete_own ) { $number_removed += $self->get_contents->search( { biblionumber => $biblionumber, @@ -267,8 +267,7 @@ sub can_biblios_be_removed { return 1 if $borrowernumber - and ( $self->owner == $borrowernumber - or $self->allow_delete_own + and ( $self->allow_delete_own or $self->allow_delete_other ); return 0; } --- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt @@ -609,6 +609,7 @@ function placeHold () {
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt +++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt @@ -17,7 +17,7 @@ [% IF shelf.allow_add %][% ELSE %][% END %] [% IF shelf.allow_add %][% ELSE %][% END %] -  anyone else to add entries. +  anyone else to add entries. (The owner of a list is always allowed to add entries, but needs permission to remove.)
  • --- a/t/db_dependent/Virtualshelves.t +++ a/t/db_dependent/Virtualshelves.t @@ -12,12 +12,10 @@ use Koha::Virtualshelfcontents; use t::lib::TestBuilder; +my $builder = t::lib::TestBuilder->new; my $dbh = C4::Context->dbh; -$dbh->{AutoCommit} = 0; teardown(); -my $builder = t::lib::TestBuilder->new; - subtest 'CRUD' => sub { plan tests => 13; my $patron = $builder->build({ @@ -207,10 +205,9 @@ subtest 'Shelf content' => sub { $shelf->allow_delete_own(0); $shelf->store; $number_of_deleted_biblios = $shelf->remove_biblios( { biblionumbers => [ $biblio2->{biblionumber} ], borrowernumber => $patron1->{borrowernumber} } ); - is( $number_of_deleted_biblios, 1, ); + is( $number_of_deleted_biblios, 0, 'A patron is not allowed to delete his own content if allow_delete_own=0, even if he is the owner of the list'); $number_of_contents = Koha::Virtualshelfcontents->search->count; - is( $number_of_contents, 0, 'The biblio should have been deleted to the shelf by the patron, it is his own content (allow_delete_own=0)' ); - $shelf->add_biblio( $biblio2->{biblionumber}, $patron1->{borrowernumber} ); + is( $number_of_contents, 1, 'The biblio should not have been deleted to the shelf by the patron, it is his own content (allow_delete_own=0)' ); # allow_add = 1, allow_delete_own = 1 $shelf->allow_add(1); @@ -273,7 +270,7 @@ subtest 'Shelf permissions' => sub { is( $public_shelf->can_biblios_be_added( $patron1->{borrowernumber} ), 1, 'The owner should be able to add biblios to his list' ); is( $public_shelf->can_biblios_be_added( $patron2->{borrowernumber} ), 0, 'Public list should not be modified (add) by someone else' ); - is( $public_shelf->can_biblios_be_removed( $patron1->{borrowernumber} ), 1, 'The owner should be able to remove biblios to his list' ); + is( $public_shelf->can_biblios_be_removed( $patron1->{borrowernumber} ), 0, 'The owner not should be able to remove biblios to his list' ); is( $public_shelf->can_biblios_be_removed( $patron2->{borrowernumber} ), 0, 'Public list should not be modified (remove) by someone else' ); @@ -320,7 +317,7 @@ subtest 'Shelf permissions' => sub { is( $private_shelf->can_biblios_be_added( $patron1->{borrowernumber} ), 1, 'The owner should be able to add biblios to his list' ); is( $private_shelf->can_biblios_be_added( $patron2->{borrowernumber} ), 0, 'Private list should not be modified (add) by someone else' ); - is( $private_shelf->can_biblios_be_removed( $patron1->{borrowernumber} ), 1, 'The owner should be able to remove biblios to his list' ); + is( $private_shelf->can_biblios_be_removed( $patron1->{borrowernumber} ), 0, 'The owner should not be able to remove biblios to his list' ); is( $private_shelf->can_biblios_be_removed( $patron2->{borrowernumber} ), 0, 'Private list should not be modified (remove) by someone else' ); --