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

(-)a/Koha/Patron.pm (+15 lines)
Lines 2383-2388 sub can_patron_change_staff_only_lists { Link Here
2383
    return 0;
2383
    return 0;
2384
}
2384
}
2385
2385
2386
=head3 can_patron_change_permitted_staff_lists
2387
2388
$patron->can_patron_change_permitted_staff_lists;
2389
2390
Return 1 if a patron has 'Superlibrarian' or 'Catalogue' and 'edit_public_list_contents' permissions.
2391
Otherwise, return 0.
2392
2393
=cut
2394
2395
sub can_patron_change_permitted_staff_lists {
2396
    my ( $self, $params ) = @_;
2397
    return 1 if C4::Auth::haspermission( $self->userid, { 'catalogue' => 1, lists => 'edit_public_list_contents' } );
2398
    return 0;
2399
}
2400
2386
=head3 encode_secret
2401
=head3 encode_secret
2387
2402
2388
  $patron->encode_secret($secret32);
2403
  $patron->encode_secret($secret32);
(-)a/Koha/Virtualshelf.pm (-2 / +5 lines)
Lines 59-64 sub store { Link Here
59
        unless defined $self->allow_change_from_others;
59
        unless defined $self->allow_change_from_others;
60
    $self->allow_change_from_staff( 0 )
60
    $self->allow_change_from_staff( 0 )
61
        unless defined $self->allow_change_from_staff;
61
        unless defined $self->allow_change_from_staff;
62
    $self->allow_change_from_permitted_staff( 0 )
63
        unless defined $self->allow_change_from_permitted_staff;
62
64
63
    $self->created_on( dt_from_string )
65
    $self->created_on( dt_from_string )
64
        unless defined $self->created_on;
66
        unless defined $self->created_on;
Lines 181-187 sub add_biblio { Link Here
181
183
182
    # Check permissions
184
    # Check permissions
183
    my $patron = Koha::Patrons->find( $borrowernumber ) or return 0;
185
    my $patron = Koha::Patrons->find( $borrowernumber ) or return 0;
184
    return 0 unless ( $self->owner == $borrowernumber && $self->allow_change_from_owner ) || ( $self->allow_change_from_staff && $patron->can_patron_change_staff_only_lists ) || $self->allow_change_from_others;
186
    return 0 unless ( $self->owner == $borrowernumber && $self->allow_change_from_owner ) || ( $self->allow_change_from_staff && $patron->can_patron_change_staff_only_lists ) || ( $self->allow_change_from_permitted_staff && $patron->can_patron_change_permitted_staff_lists ) || $self->allow_change_from_others;
185
187
186
    my $content = Koha::Virtualshelfcontent->new(
188
    my $content = Koha::Virtualshelfcontent->new(
187
        {
189
        {
Lines 206-211 sub remove_biblios { Link Here
206
    my $patron = Koha::Patrons->find( $borrowernumber ) or return 0;
208
    my $patron = Koha::Patrons->find( $borrowernumber ) or return 0;
207
    if( ( $self->owner == $borrowernumber && $self->allow_change_from_owner )
209
    if( ( $self->owner == $borrowernumber && $self->allow_change_from_owner )
208
      || ( $self->allow_change_from_staff && $patron->can_patron_change_staff_only_lists )
210
      || ( $self->allow_change_from_staff && $patron->can_patron_change_staff_only_lists )
211
      || ( $self->allow_change_from_permitted_staff && $patron->can_patron_change_permitted_staff_lists )
209
      || $self->allow_change_from_others ) {
212
      || $self->allow_change_from_others ) {
210
        $number_removed += $self->get_contents->search({
213
        $number_removed += $self->get_contents->search({
211
            biblionumber => $biblionumbers,
214
            biblionumber => $biblionumbers,
Lines 256-262 sub can_biblios_be_added { Link Here
256
    my $patron = Koha::Patrons->find( $borrowernumber ) or return 0;
259
    my $patron = Koha::Patrons->find( $borrowernumber ) or return 0;
257
    return 1
260
    return 1
258
      if $borrowernumber
261
      if $borrowernumber
259
      and ( ( $self->owner == $borrowernumber && $self->allow_change_from_owner ) or ( $self->allow_change_from_staff && $patron->can_patron_change_staff_only_lists ) or $self->allow_change_from_others );
262
      and ( ( $self->owner == $borrowernumber && $self->allow_change_from_owner ) or ( $self->allow_change_from_staff && $patron->can_patron_change_staff_only_lists ) or ( $self->allow_change_from_permitted_staff && $patron->can_patron_change_permitted_staff_lists ) or $self->allow_change_from_others );
260
    return 0;
263
    return 0;
261
}
264
}
262
265
(-)a/Koha/Virtualshelves.pm (-3 / +18 lines)
Lines 136-147 sub get_some_shelves { Link Here
136
    my @conditions;
136
    my @conditions;
137
    my $patron;
137
    my $patron;
138
    my $staffuser = 0;
138
    my $staffuser = 0;
139
    my $permitteduser = 0;
139
    if ( $borrowernumber != 0 ) {
140
    if ( $borrowernumber != 0 ) {
140
        $patron = Koha::Patrons->find( $borrowernumber );
141
        $patron = Koha::Patrons->find( $borrowernumber );
141
        $staffuser = $patron->can_patron_change_staff_only_lists;
142
        $staffuser = $patron->can_patron_change_staff_only_lists;
143
        $permitteduser = $patron->can_patron_change_permitted_staff_lists;
142
    }
144
    }
143
    if ( $add_allowed ) {
145
    if ( $add_allowed ) {
144
        if ( $staffuser ) {
146
        if ( $permitteduser ) {
145
            push @conditions, {
147
            push @conditions, {
146
                -or =>
148
                -or =>
147
                [
149
                [
Lines 149-156 sub get_some_shelves { Link Here
149
                        "me.owner" => $borrowernumber,
151
                        "me.owner" => $borrowernumber,
150
                        "me.allow_change_from_owner" => 1,
152
                        "me.allow_change_from_owner" => 1,
151
                    },
153
                    },
152
                    "me.allow_change_from_others" => 1,
154
                    "me.allow_change_from_others"          => 1,
153
                    "me.allow_change_from_staff"  => 1
155
                    "me.allow_change_from_staff"           => 1,
156
                    "me.allow_change_from_permitted_staff" => 1
157
                ]
158
            };
159
        } elsif ( $staffuser ) {
160
            push @conditions, {
161
                -or =>
162
                [
163
                    {
164
                        "me.owner" => $borrowernumber,
165
                        "me.allow_change_from_owner" => 1,
166
                    },
167
                    "me.allow_change_from_others"          => 1,
168
                    "me.allow_change_from_staff"           => 1
154
                ]
169
                ]
155
            };
170
            };
156
        } else {
171
        } else {
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt (-1 / +1 lines)
Lines 51-57 Link Here
51
            [% IF shelf.allow_change_from_others %]<option value="2" selected="selected">Anyone seeing this list</option>[% ELSE %]<option value="2">Anyone seeing this list</option>[% END %]
51
            [% IF shelf.allow_change_from_others %]<option value="2" selected="selected">Anyone seeing this list</option>[% ELSE %]<option value="2">Anyone seeing this list</option>[% END %]
52
52
53
            [% IF staffuser == 1 %][% IF shelf.allow_change_from_staff %]<option value="3" selected="selected">Staff only</option>[% ELSE %]<option value="3">Staff only</option>[% END %][% END %]
53
            [% IF staffuser == 1 %][% IF shelf.allow_change_from_staff %]<option value="3" selected="selected">Staff only</option>[% ELSE %]<option value="3">Staff only</option>[% END %][% END %]
54
            [% IF permitteduser == 1 %][% shelf.allow_change_from_permitted_staff %]<option value="4" selected="selected">Permitted staff only</option>[% ELSE %]<option value="4">Permitted staff only</option>[% END %'[% END %]
54
            [% IF permitteduser == 1 %][% IF shelf.allow_change_from_permitted_staff %]<option value="4" selected="selected">Permitted staff only</option>[% ELSE %]<option value="4">Permitted staff only</option>[% END %][% END %]
55
55
56
        </select>
56
        </select>
57
        &emsp; <span id="anyone_remark" style="display:none;color:red;">The "Anyone" permission has no actual effect while this list is strictly private.</span>
57
        &emsp; <span id="anyone_remark" style="display:none;color:red;">The "Anyone" permission has no actual effect while this list is strictly private.</span>
(-)a/opac/opac-addbybiblionumber.pl (-3 / +18 lines)
Lines 119-125 if ($newvirtualshelf) { Link Here
119
        );
119
        );
120
        my $public_shelves;
120
        my $public_shelves;
121
        if ( $loggedinuser ) {
121
        if ( $loggedinuser ) {
122
            if ( Koha::Patrons->find( $loggedinuser )->can_patron_change_staff_only_lists ) {
122
            if ( Koha::Patrons->find( $loggedinuser )->can_patron_change_permitted_staff_lists ) {
123
                $public_shelves = Koha::Virtualshelves->search(
123
                $public_shelves = Koha::Virtualshelves->search(
124
                    {   public   => 1,
124
                    {   public   => 1,
125
                        -or      => [
125
                        -or      => [
Lines 127-134 if ($newvirtualshelf) { Link Here
127
                                allow_change_from_owner => 1,
127
                                allow_change_from_owner => 1,
128
                                owner     => $loggedinuser,
128
                                owner     => $loggedinuser,
129
                            },
129
                            },
130
                            allow_change_from_others => 1,
130
                            allow_change_from_others          => 1,
131
                            allow_change_from_staff  => 1
131
                            allow_change_from_staff           => 1,
132
                            allow_change_from_permitted_staff => 1
133
                        ],
134
                    },
135
                    { order_by => 'shelfname' }
136
                );
137
            } elsif ( Koha::Patrons->find( $loggedinuser )->can_patron_change_staff_only_lists ) {
138
                $public_shelves = Koha::Virtualshelves->search(
139
                    {   public   => 1,
140
                        -or      => [
141
                            -and => {
142
                                allow_change_from_owner => 1,
143
                                owner     => $loggedinuser,
144
                            },
145
                            allow_change_from_others          => 1,
146
                            allow_change_from_staff           => 1
132
                        ],
147
                        ],
133
                    },
148
                    },
134
                    { order_by => 'shelfname' }
149
                    { order_by => 'shelfname' }
(-)a/opac/opac-shelves.pl (-12 / +18 lines)
Lines 48-53 use Koha::RecordProcessor; Link Here
48
48
49
use constant ANYONE => 2;
49
use constant ANYONE => 2;
50
use constant STAFF => 3;
50
use constant STAFF => 3;
51
use constant PERMITTED => 4;
51
52
52
my $query = CGI->new;
53
my $query = CGI->new;
53
54
Lines 118-126 if ( $op eq 'add_form' ) { Link Here
118
                {   shelfname          => scalar $query->param('shelfname'),
119
                {   shelfname          => scalar $query->param('shelfname'),
119
                    sortfield          => scalar $query->param('sortfield'),
120
                    sortfield          => scalar $query->param('sortfield'),
120
                    public             => $public,
121
                    public             => $public,
121
                    allow_change_from_owner => $allow_changes_from > 0,
122
                    allow_change_from_owner            => $allow_changes_from > 0,
122
                    allow_change_from_others => $allow_changes_from == ANYONE,
123
                    allow_change_from_others           => $allow_changes_from == ANYONE,
123
                    allow_change_from_staff => $allow_changes_from == STAFF,
124
                    allow_change_from_staff            => $allow_changes_from == STAFF,
125
                    allow_change_from_permitted_staff => $allow_changes_from == PERMITTED,
124
                    owner              => scalar $loggedinuser,
126
                    owner              => scalar $loggedinuser,
125
                }
127
                }
126
            );
128
            );
Lines 153-158 if ( $op eq 'add_form' ) { Link Here
153
            $shelf->allow_change_from_owner( $allow_changes_from > 0 );
155
            $shelf->allow_change_from_owner( $allow_changes_from > 0 );
154
            $shelf->allow_change_from_others( $allow_changes_from == ANYONE );
156
            $shelf->allow_change_from_others( $allow_changes_from == ANYONE );
155
            $shelf->allow_change_from_staff( $allow_changes_from == STAFF );
157
            $shelf->allow_change_from_staff( $allow_changes_from == STAFF );
158
            $shelf->allow_change_from_permitted_staff( $allow_changes_from == PERMITTED );
156
            $shelf->public( $public );
159
            $shelf->public( $public );
157
            eval { $shelf->store };
160
            eval { $shelf->store };
158
161
Lines 487-503 if ( $op eq 'view' ) { Link Here
487
    );
490
    );
488
}
491
}
489
492
490
my $staffuser;
493
my ($staffuser, $permitteduser);
491
$staffuser = Koha::Patrons->find( $loggedinuser )->can_patron_change_staff_only_lists if $loggedinuser;
494
$staffuser = Koha::Patrons->find( $loggedinuser )->can_patron_change_staff_only_lists if $loggedinuser;
495
$permitteduser = Koha::Patrons->find( $loggedinuser )->can_patron_change_permitted_staff_lists if $loggedinuser;
496
492
$template->param(
497
$template->param(
493
    op       => $op,
498
    op            => $op,
494
    referer  => $referer,
499
    referer       => $referer,
495
    shelf    => $shelf,
500
    shelf         => $shelf,
496
    messages => \@messages,
501
    messages      => \@messages,
497
    public   => $public,
502
    public        => $public,
498
    print    => scalar $query->param('print') || 0,
503
    print         => scalar $query->param('print') || 0,
499
    listsview => 1,
504
    listsview     => 1,
500
    staffuser => $staffuser,
505
    staffuser     => $staffuser,
506
    permitteduser => $permitteduser
501
);
507
);
502
508
503
my $content_type = $query->param('rss')? 'rss' : 'html';
509
my $content_type = $query->param('rss')? 'rss' : 'html';
(-)a/virtualshelves/shelves.pl (-6 / +8 lines)
Lines 40-47 use Koha::CsvProfiles; Link Here
40
use Koha::Patrons;
40
use Koha::Patrons;
41
use Koha::Virtualshelves;
41
use Koha::Virtualshelves;
42
42
43
use constant ANYONE => 2;
43
use constant ANYONE    => 2;
44
use constant STAFF  => 3;
44
use constant STAFF     => 3;
45
use constant PERMITTED => 4;
45
46
46
my $query = CGI->new;
47
my $query = CGI->new;
47
48
Lines 84-92 if ( $op eq 'add_form' ) { Link Here
84
            {   shelfname          => scalar $query->param('shelfname'),
85
            {   shelfname          => scalar $query->param('shelfname'),
85
                sortfield          => scalar $query->param('sortfield'),
86
                sortfield          => scalar $query->param('sortfield'),
86
                public             => $public,
87
                public             => $public,
87
                allow_change_from_owner => $allow_changes_from > 0,
88
                allow_change_from_owner           => $allow_changes_from > 0,
88
                allow_change_from_others => $allow_changes_from == ANYONE,
89
                allow_change_from_others          => $allow_changes_from == ANYONE,
89
                allow_change_from_staff => $allow_changes_from == STAFF,
90
                allow_change_from_staff           => $allow_changes_from == STAFF,
91
                allow_change_from_permitted_staff => $allow_changes_from == PERMITTED,
90
                owner              => scalar $query->param('owner'),
92
                owner              => scalar $query->param('owner'),
91
            }
93
            }
92
        );
94
        );
Lines 117-122 if ( $op eq 'add_form' ) { Link Here
117
            $shelf->allow_change_from_owner( $allow_changes_from > 0 );
119
            $shelf->allow_change_from_owner( $allow_changes_from > 0 );
118
            $shelf->allow_change_from_others( $allow_changes_from == ANYONE );
120
            $shelf->allow_change_from_others( $allow_changes_from == ANYONE );
119
            $shelf->allow_change_from_staff( $allow_changes_from == STAFF );
121
            $shelf->allow_change_from_staff( $allow_changes_from == STAFF );
122
            $shelf->allow_change_from_permitted_staff( $allow_changes_from == PERMITTED );
120
            $shelf->public( scalar $query->param('public') );
123
            $shelf->public( scalar $query->param('public') );
121
            eval { $shelf->store };
124
            eval { $shelf->store };
122
125
123
- 

Return to bug 30418