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

(-)a/Koha/Schema/Result/Letter.pm (-4 / +2 lines)
Lines 29-36 __PACKAGE__->table("letter"); Link Here
29
  is_auto_increment: 1
29
  is_auto_increment: 1
30
  is_nullable: 0
30
  is_nullable: 0
31
31
32
primary key identifier
33
34
=head2 module
32
=head2 module
35
33
36
  data_type: 'varchar'
34
  data_type: 'varchar'
Lines 217-224 __PACKAGE__->belongs_to( Link Here
217
);
215
);
218
216
219
217
220
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2021-02-11 12:33:50
218
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2021-04-09 22:58:34
221
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:qqdTVEicMu5rHppY5qsEuA
219
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:2QkUwMWgZ9WfOk9Ngf7yFA
222
220
223
sub koha_object_class {
221
sub koha_object_class {
224
    'Koha::Notice::Template';
222
    'Koha::Notice::Template';
(-)a/Koha/Schema/Result/Virtualshelve.pm (-2 / +10 lines)
Lines 97-102 can owner change contents? Link Here
97
97
98
can others change contents?
98
can others change contents?
99
99
100
=head2 allow_change_from_staff
101
102
  data_type: 'tinyint'
103
  default_value: 0
104
  is_nullable: 1
105
100
=cut
106
=cut
101
107
102
__PACKAGE__->add_columns(
108
__PACKAGE__->add_columns(
Lines 132-137 __PACKAGE__->add_columns( Link Here
132
  { data_type => "tinyint", default_value => 1, is_nullable => 1 },
138
  { data_type => "tinyint", default_value => 1, is_nullable => 1 },
133
  "allow_change_from_others",
139
  "allow_change_from_others",
134
  { data_type => "tinyint", default_value => 0, is_nullable => 1 },
140
  { data_type => "tinyint", default_value => 0, is_nullable => 1 },
141
  "allow_change_from_staff",
142
  { data_type => "tinyint", default_value => 0, is_nullable => 1 },
135
);
143
);
136
144
137
=head1 PRIMARY KEY
145
=head1 PRIMARY KEY
Lines 199-206 __PACKAGE__->has_many( Link Here
199
);
207
);
200
208
201
209
202
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-01-21 13:39:29
210
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2021-04-09 23:02:21
203
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:6ZQ6kL/0DzyOMymz+4+LhA
211
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:4FyGa/O1QtVe1t5ih9PK5A
204
212
205
sub koha_object_class {
213
sub koha_object_class {
206
    'Koha::Virtualshelf';
214
    'Koha::Virtualshelf';
(-)a/Koha/Virtualshelf.pm (-3 / +9 lines)
Lines 184-191 sub add_biblio { Link Here
184
    )->count;
184
    )->count;
185
    return if $already_exists;
185
    return if $already_exists;
186
186
187
    my $patron = Koha::Patrons->find( $borrowernumber );
188
    my $staffuser = 1 if ( C4::Auth::haspermission( $patron->userid, {'catalogue' => 1 }) );
189
187
    # Check permissions
190
    # Check permissions
188
    return unless ( $self->owner == $borrowernumber && $self->allow_change_from_owner ) || $self->allow_change_from_others;
191
    return unless ( $self->owner == $borrowernumber && $self->allow_change_from_owner ) || ( $self->allow_change_from_staff && $staffuser ) || $self->allow_change_from_others;
189
192
190
    my $content = Koha::Virtualshelfcontent->new(
193
    my $content = Koha::Virtualshelfcontent->new(
191
        {
194
        {
Lines 251-259 sub can_be_managed { Link Here
251
sub can_biblios_be_added {
254
sub can_biblios_be_added {
252
    my ( $self, $borrowernumber ) = @_;
255
    my ( $self, $borrowernumber ) = @_;
253
256
257
    my $patron = Koha::Patrons->find( $borrowernumber );
258
    my $staffuser = 1 if ( C4::Auth::haspermission( $patron->userid, {'catalogue' => 1 } ));
259
254
    return 1
260
    return 1
255
      if $borrowernumber
261
      if $borrowernumber
256
      and ( ( $self->owner == $borrowernumber && $self->allow_change_from_owner ) or $self->allow_change_from_others );
262
      and ( ( $self->owner == $borrowernumber && $self->allow_change_from_owner ) or ( $self->allow_change_from_staff && $staffuser ) or $self->allow_change_from_others );
257
    return 0;
263
    return 0;
258
}
264
}
259
265
Lines 267-270 sub _type { Link Here
267
    return 'Virtualshelve';
273
    return 'Virtualshelve';
268
}
274
}
269
275
270
1;
276
(-)a/Koha/Virtualshelves.pm (-10 / +28 lines)
Lines 23-28 use Koha::Database; Link Here
23
23
24
use Koha::Virtualshelf;
24
use Koha::Virtualshelf;
25
25
26
use C4::Auth;
27
26
use base qw(Koha::Objects);
28
use base qw(Koha::Objects);
27
29
28
=head1 NAME
30
=head1 NAME
Lines 88-103 sub get_some_shelves { Link Here
88
90
89
    my @conditions;
91
    my @conditions;
90
    if ( $add_allowed ) {
92
    if ( $add_allowed ) {
91
        push @conditions, {
93
        my $patron = Koha::Patrons->find( $borrowernumber );
92
            -or =>
94
        my $staffuser = haspermission( $patron->userid, {'catalogue' => 1});
93
            [
95
        if ( $staffuser ) {
94
                {
96
            push @conditions, {
95
                    "me.owner" => $borrowernumber,
97
                -or =>
96
                    "me.allow_change_from_owner" => 1,
98
                [
97
                },
99
                    {
98
                "me.allow_change_from_others" => 1,
100
                        "me.owner" => $borrowernumber,
99
            ]
101
                        "me.allow_change_from_owner" => 1,
100
        };
102
                    },
103
                    "me.allow_change_from_others" => 1,
104
                    "me.allow_change_from_staff"  => 1
105
                ]
106
            };
107
        } else {
108
            push @conditions, {
109
                -or =>
110
                [
111
                    {
112
                        "me.owner" => $borrowernumber,
113
                        "me.allow_change_from_owner" => 1,
114
                    },
115
                    "me.allow_change_from_others" => 1,
116
                ]
117
            };
118
        }
101
    }
119
    }
102
    if ( $category == 1 ) {
120
    if ( $category == 1 ) {
103
        push @conditions, {
121
        push @conditions, {
(-)a/installer/data/mysql/atomicupdate/bug_26346.perl (+7 lines)
Line 0 Link Here
1
$DBversion = 'XXX';
2
if ( CheckVersion($DBversion) ) {
3
    if ( !column_exists( 'virtualshelves', 'allow_change_from_staff' ) ) {
4
        $dbh->do(q{ALTER TABLE virtualshelves ADD COLUMN `allow_change_from_staff` tinyint(1) DEFAULT '0'});
5
    }
6
    NewVersion( $DBversion, 26346, "Add allow_change_from_staff to virtualshelves table" );
7
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt (+2 lines)
Lines 25-30 Link Here
25
25
26
            [% 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 %]
26
            [% 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 %]
27
27
28
            [% IF shelf.allow_change_from_staff %]<option value="3" selected="selected">Staff only</option>[% ELSE %]<option value="3">Staff only</option>[% END %]
29
28
        </select>
30
        </select>
29
        &emsp; <span id="anyone_remark" style="display:none;color:red;">The Anyone permission has no actual effect while this list is strictly private.</span>
31
        &emsp; <span id="anyone_remark" style="display:none;color:red;">The Anyone permission has no actual effect while this list is strictly private.</span>
30
    </li>
32
    </li>
(-)a/opac/opac-addbybiblionumber.pl (-12 / +31 lines)
Lines 118-135 if ($newvirtualshelf) { Link Here
118
            },
118
            },
119
            { join => 'virtualshelfshares', }
119
            { join => 'virtualshelfshares', }
120
        );
120
        );
121
        my $public_shelves = Koha::Virtualshelves->search(
121
        my $public_shelves;
122
            {   category => 2,
122
        my $logged_in_patron = Koha::Patrons->find( $loggedinuser );
123
                -or      => [
123
        if ( haspermission( $logged_in_patron->userid, {'catalogue' => 1})) {
124
                    -and => {
124
            $public_shelves = Koha::Virtualshelves->search(
125
                        allow_change_from_owner => 1,
125
                {   category => 2,
126
                        owner     => $loggedinuser,
126
                    -or      => [
127
                    },
127
                        -and => {
128
                    allow_change_from_others => 1,
128
                            allow_change_from_owner => 1,
129
                ],
129
                            owner     => $loggedinuser,
130
            },
130
                        },
131
            { order_by => 'shelfname' }
131
                        allow_change_from_others => 1,
132
        );
132
                        allow_change_from_staff  => 1
133
                    ],
134
                },
135
                { order_by => 'shelfname' }
136
            );
137
        } else {
138
            $public_shelves = Koha::Virtualshelves->search(
139
                {   category => 2,
140
                    -or      => [
141
                        -and => {
142
                            allow_change_from_owner => 1,
143
                            owner => $loggedinuser,
144
                        },
145
                        allow_change_from_others => 1,
146
                    ],
147
                },
148
                {order_by => 'shelfname' }
149
            );
150
        }
151
133
        $template->param(
152
        $template->param(
134
            private_shelves                => $private_shelves,
153
            private_shelves                => $private_shelves,
135
            private_shelves_shared_with_me => $shelves_shared_with_me,
154
            private_shelves_shared_with_me => $shelves_shared_with_me,
(-)a/virtualshelves/shelves.pl (-1 / +3 lines)
Lines 36-41 use Koha::Patrons; Link Here
36
use Koha::Virtualshelves;
36
use Koha::Virtualshelves;
37
37
38
use constant ANYONE => 2;
38
use constant ANYONE => 2;
39
use constant STAFF  => 3;
39
40
40
my $query = CGI->new;
41
my $query = CGI->new;
41
42
Lines 79-84 if ( $op eq 'add_form' ) { Link Here
79
                category           => scalar $query->param('category'),
80
                category           => scalar $query->param('category'),
80
                allow_change_from_owner => $allow_changes_from > 0,
81
                allow_change_from_owner => $allow_changes_from > 0,
81
                allow_change_from_others => $allow_changes_from == ANYONE,
82
                allow_change_from_others => $allow_changes_from == ANYONE,
83
                allow_change_from_staff => $allow_changes_from == STAFF,
82
                owner              => scalar $query->param('owner'),
84
                owner              => scalar $query->param('owner'),
83
            }
85
            }
84
        );
86
        );
Lines 108-113 if ( $op eq 'add_form' ) { Link Here
108
            my $allow_changes_from = $query->param('allow_changes_from');
110
            my $allow_changes_from = $query->param('allow_changes_from');
109
            $shelf->allow_change_from_owner( $allow_changes_from > 0 );
111
            $shelf->allow_change_from_owner( $allow_changes_from > 0 );
110
            $shelf->allow_change_from_others( $allow_changes_from == ANYONE );
112
            $shelf->allow_change_from_others( $allow_changes_from == ANYONE );
113
            $shelf->allow_change_from_staff( $allow_changes_from == STAFF );
111
            $shelf->category( scalar $query->param('category') );
114
            $shelf->category( scalar $query->param('category') );
112
            eval { $shelf->store };
115
            eval { $shelf->store };
113
116
114
- 

Return to bug 26346