View | Details | Raw Unified | Return to bug 14544
Collapse All | Expand All

(-)a/Koha/Virtualshelf.pm (-3 / +2 lines)
Lines 192-198 sub remove_biblios { Link Here
192
192
193
    my $number_removed = 0;
193
    my $number_removed = 0;
194
    for my $biblionumber ( @$biblionumbers ) {
194
    for my $biblionumber ( @$biblionumbers ) {
195
        if ( $self->owner == $borrowernumber or $self->allow_delete_own ) {
195
        if ( $self->allow_delete_own ) {
196
            $number_removed += $self->get_contents->search(
196
            $number_removed += $self->get_contents->search(
197
                {
197
                {
198
                    biblionumber => $biblionumber,
198
                    biblionumber => $biblionumber,
Lines 267-274 sub can_biblios_be_removed { Link Here
267
267
268
    return 1
268
    return 1
269
      if $borrowernumber
269
      if $borrowernumber
270
      and (  $self->owner == $borrowernumber
270
      and (  $self->allow_delete_own
271
          or $self->allow_delete_own
272
          or $self->allow_delete_other );
271
          or $self->allow_delete_other );
273
    return 0;
272
    return 0;
274
}
273
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt (+1 lines)
Lines 609-614 function placeHold () { Link Here
609
        <div class="help"><ul>
609
        <div class="help"><ul>
610
            <li><b>Private list:</b> Is managed by you and can be seen only by you.</li>
610
            <li><b>Private list:</b> Is managed by you and can be seen only by you.</li>
611
            <li><b>Public list:</b> Can be seen by everybody, but managed only by you.</li>
611
            <li><b>Public list:</b> Can be seen by everybody, but managed only by you.</li>
612
            <li>The owner of a list is always allowed to add entries, but needs permission to remove.</li>
612
        </ul>
613
        </ul>
613
        </div>
614
        </div>
614
    </div>
615
    </div>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt (-1 / +1 lines)
Lines 17-23 Link Here
17
            [% IF shelf.allow_add %]<option value="0">Do not allow</option>[% ELSE %]<option value="0" selected="selected">Do not allow</option>[% END %]
17
            [% IF shelf.allow_add %]<option value="0">Do not allow</option>[% ELSE %]<option value="0" selected="selected">Do not allow</option>[% END %]
18
            [% IF shelf.allow_add %]<option value="1" selected="selected">Allow</option>[% ELSE %]<option value="1">Allow</option>[% END %]
18
            [% IF shelf.allow_add %]<option value="1" selected="selected">Allow</option>[% ELSE %]<option value="1">Allow</option>[% END %]
19
        </select>
19
        </select>
20
        &nbsp;<span>anyone else to add entries.</span>
20
        &nbsp;<span>anyone else to add entries. (The owner of a list is always allowed to add entries, but needs permission to remove.)</span>
21
    </li>
21
    </li>
22
    <li>
22
    <li>
23
        <label>&nbsp;</label>
23
        <label>&nbsp;</label>
(-)a/t/db_dependent/Virtualshelves.t (-9 / +5 lines)
Lines 12-23 use Koha::Virtualshelfcontents; Link Here
12
12
13
use t::lib::TestBuilder;
13
use t::lib::TestBuilder;
14
14
15
my $builder = t::lib::TestBuilder->new;
15
my $dbh = C4::Context->dbh;
16
my $dbh = C4::Context->dbh;
16
$dbh->{AutoCommit} = 0;
17
teardown();
17
teardown();
18
18
19
my $builder = t::lib::TestBuilder->new;
20
21
subtest 'CRUD' => sub {
19
subtest 'CRUD' => sub {
22
    plan tests => 13;
20
    plan tests => 13;
23
    my $patron = $builder->build({
21
    my $patron = $builder->build({
Lines 207-216 subtest 'Shelf content' => sub { Link Here
207
    $shelf->allow_delete_own(0);
205
    $shelf->allow_delete_own(0);
208
    $shelf->store;
206
    $shelf->store;
209
    $number_of_deleted_biblios = $shelf->remove_biblios( { biblionumbers => [ $biblio2->{biblionumber} ], borrowernumber => $patron1->{borrowernumber} } );
207
    $number_of_deleted_biblios = $shelf->remove_biblios( { biblionumbers => [ $biblio2->{biblionumber} ], borrowernumber => $patron1->{borrowernumber} } );
210
    is( $number_of_deleted_biblios, 1, );
208
    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');
211
    $number_of_contents = Koha::Virtualshelfcontents->search->count;
209
    $number_of_contents = Koha::Virtualshelfcontents->search->count;
212
    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)' );
210
    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)' );
213
    $shelf->add_biblio( $biblio2->{biblionumber}, $patron1->{borrowernumber} );
214
211
215
    # allow_add = 1, allow_delete_own = 1
212
    # allow_add = 1, allow_delete_own = 1
216
    $shelf->allow_add(1);
213
    $shelf->allow_add(1);
Lines 273-279 subtest 'Shelf permissions' => sub { Link Here
273
    is( $public_shelf->can_biblios_be_added( $patron1->{borrowernumber} ), 1, 'The owner should be able to add biblios to his list' );
270
    is( $public_shelf->can_biblios_be_added( $patron1->{borrowernumber} ), 1, 'The owner should be able to add biblios to his list' );
274
    is( $public_shelf->can_biblios_be_added( $patron2->{borrowernumber} ), 0, 'Public list should not be modified (add) by someone else' );
271
    is( $public_shelf->can_biblios_be_added( $patron2->{borrowernumber} ), 0, 'Public list should not be modified (add) by someone else' );
275
272
276
    is( $public_shelf->can_biblios_be_removed( $patron1->{borrowernumber} ), 1, 'The owner should be able to remove biblios to his list' );
273
    is( $public_shelf->can_biblios_be_removed( $patron1->{borrowernumber} ), 0, 'The owner not should be able to remove biblios to his list' );
277
    is( $public_shelf->can_biblios_be_removed( $patron2->{borrowernumber} ), 0, 'Public list should not be modified (remove) by someone else' );
274
    is( $public_shelf->can_biblios_be_removed( $patron2->{borrowernumber} ), 0, 'Public list should not be modified (remove) by someone else' );
278
275
279
276
Lines 320-326 subtest 'Shelf permissions' => sub { Link Here
320
    is( $private_shelf->can_biblios_be_added( $patron1->{borrowernumber} ), 1, 'The owner should be able to add biblios to his list' );
317
    is( $private_shelf->can_biblios_be_added( $patron1->{borrowernumber} ), 1, 'The owner should be able to add biblios to his list' );
321
    is( $private_shelf->can_biblios_be_added( $patron2->{borrowernumber} ), 0, 'Private list should not be modified (add) by someone else' );
318
    is( $private_shelf->can_biblios_be_added( $patron2->{borrowernumber} ), 0, 'Private list should not be modified (add) by someone else' );
322
319
323
    is( $private_shelf->can_biblios_be_removed( $patron1->{borrowernumber} ), 1, 'The owner should be able to remove biblios to his list' );
320
    is( $private_shelf->can_biblios_be_removed( $patron1->{borrowernumber} ), 0, 'The owner should not be able to remove biblios to his list' );
324
    is( $private_shelf->can_biblios_be_removed( $patron2->{borrowernumber} ), 0, 'Private list should not be modified (remove) by someone else' );
321
    is( $private_shelf->can_biblios_be_removed( $patron2->{borrowernumber} ), 0, 'Private list should not be modified (remove) by someone else' );
325
322
326
323
327
- 

Return to bug 14544