From 5025420992a0feec8e757e2a9f49a23266e90c26 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 14 Oct 2015 15:09:33 +0100 Subject: [PATCH] Bug 14544: allow_delete_own == 0 could represent a read-only list This patch reintroduces the previous behavior. --- 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(-) diff --git a/Koha/Virtualshelf.pm b/Koha/Virtualshelf.pm index 7ce2738..6253e33 100644 --- a/Koha/Virtualshelf.pm +++ b/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; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt index 59ffa65..c36a183 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt @@ -609,6 +609,7 @@ function placeHold () {
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt index 113c056..cadce37 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt +++ b/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.)
  • diff --git a/t/db_dependent/Virtualshelves.t b/t/db_dependent/Virtualshelves.t index 42c7ea9..7051ecb 100644 --- a/t/db_dependent/Virtualshelves.t +++ b/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' ); -- 2.1.0