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

(-)a/Koha/Virtualshelf.pm (-4 / +9 lines)
Lines 256-271 sub can_be_managed { Link Here
256
sub can_biblios_be_added {
256
sub can_biblios_be_added {
257
    my ( $self, $borrowernumber ) = @_;
257
    my ( $self, $borrowernumber ) = @_;
258
258
259
    my $patron = Koha::Patrons->find( $borrowernumber ) or return 0;
259
    my $patron = Koha::Patrons->find($borrowernumber) or return 0;
260
    return 1
260
    return 1
261
      if $borrowernumber
261
        if $borrowernumber
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 );
262
        and ( ( $self->owner == $borrowernumber && $self->allow_change_from_owner )
263
        or ( $self->allow_change_from_staff           && $patron->can_patron_change_staff_only_lists )
264
        or ( $self->allow_change_from_permitted_staff && $patron->can_patron_change_permitted_staff_lists )
265
        or $self->allow_change_from_others )
266
        and ( ( $self->public && C4::Auth::haspermission( $patron->userid, { lists => 'edit_public_list_contents' } ) )
267
        or !$self->public );
263
    return 0;
268
    return 0;
264
}
269
}
265
270
266
sub can_biblios_be_removed {
271
sub can_biblios_be_removed {
267
    my ( $self, $borrowernumber ) = @_;
272
    my ( $self, $borrowernumber ) = @_;
268
    return $self->can_biblios_be_added( $borrowernumber );
273
    return $self->can_biblios_be_added($borrowernumber);
269
    # Same answer since bug 18228
274
    # Same answer since bug 18228
270
}
275
}
271
276
(-)a/installer/data/mysql/atomicupdate/bug_13888-Add-extra-list-perms.pl (+21 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number  => "13888",
5
    description => "'Lists' permission should allow/disallow using the lists module in staff",
6
    up          => sub {
7
        my ($args) = @_;
8
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
10
        $dbh->do(
11
            q{ INSERT IGNORE INTO permissions (module_bit,code,description) VALUES (20, 'use_public_lists', 'Use public lists') }
12
        );
13
        say $out "Added permission 'use_public_lists'";
14
15
        $dbh->do(
16
            q{ INSERT IGNORE INTO permissions (module_bit,code,description) VALUES (20, 'create_public_lists', 'Create public lists') }
17
        );
18
        say $out "Added permission 'create_public_lists'";
19
20
    },
21
};
(-)a/installer/data/mysql/mandatory/userpermissions.sql (+2 lines)
Lines 144-152 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
144
   (19, 'report', 'Use report plugins'),
144
   (19, 'report', 'Use report plugins'),
145
   (19, 'admin', 'Use administrative plugins'),
145
   (19, 'admin', 'Use administrative plugins'),
146
   (19, 'configure', 'Configure plugins'),
146
   (19, 'configure', 'Configure plugins'),
147
   (20, 'create_public_lists', 'Create public lists'),
147
   (20, 'delete_public_lists', 'Delete public lists'),
148
   (20, 'delete_public_lists', 'Delete public lists'),
148
   (20, 'edit_public_lists', 'Edit public lists'),
149
   (20, 'edit_public_lists', 'Edit public lists'),
149
   (20, 'edit_public_list_contents', 'Edit public list contents'),
150
   (20, 'edit_public_list_contents', 'Edit public list contents'),
151
   (20, 'use_public_lists', 'Use public lists'),
150
   (21, 'edit_templates', 'Create and update club templates'),
152
   (21, 'edit_templates', 'Create and update club templates'),
151
   (21, 'edit_clubs', 'Create and update clubs'),
153
   (21, 'edit_clubs', 'Create and update clubs'),
152
   (21, 'enroll', 'Enroll patrons in clubs'),
154
   (21, 'enroll', 'Enroll patrons in clubs'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc (+3 lines)
Lines 228-233 Link Here
228
                        <li class="toplinks-mycheckouts">
228
                        <li class="toplinks-mycheckouts">
229
                            <a class="toplinks" href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% loggedinusernumber | html %]">My checkouts</a>
229
                            <a class="toplinks" href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% loggedinusernumber | html %]">My checkouts</a>
230
                        </li>
230
                        </li>
231
                        <li class="toplinks-mylists">
232
                            <a class="toplinks" href="/cgi-bin/koha/virtualshelves/shelves.pl">My lists</a>
233
                        </li>
231
                    [% END %]
234
                    [% END %]
232
                    [% IF Koha.Preference( 'CookieConsent' ) %]
235
                    [% IF Koha.Preference( 'CookieConsent' ) %]
233
                        <li class="toplinks-myconsents">
236
                        <li class="toplinks-myconsents">
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc (+10 lines)
Lines 757-762 Link Here
757
            Use administrative plugins
757
            Use administrative plugins
758
        </span>
758
        </span>
759
        <span class="permissioncode">([% name | html %])</span>
759
        <span class="permissioncode">([% name | html %])</span>
760
    [%- CASE 'create_public_lists' -%]
761
        <span class="sub_permission create_public_lists_subpermission">
762
            Create public lists
763
        </span>
764
        <span class="permissioncode">([% name | html %])</span>
760
    [%- CASE 'delete_public_lists' -%]
765
    [%- CASE 'delete_public_lists' -%]
761
        <span class="sub_permission delete_public_lists_subpermission">
766
        <span class="sub_permission delete_public_lists_subpermission">
762
            Delete public lists
767
            Delete public lists
Lines 772-777 Link Here
772
            Edit public lists contents
777
            Edit public lists contents
773
        </span>
778
        </span>
774
        <span class="permissioncode">([% name | html %])</span>
779
        <span class="permissioncode">([% name | html %])</span>
780
    [%- CASE 'use_public_lists' -%]
781
        <span class="sub_permission use_public_lists_subpermission">
782
            Use public lists
783
        </span>
784
        <span class="permissioncode">([% name | html %])</span>
775
    [%- CASE 'upload_general_files' -%]
785
    [%- CASE 'upload_general_files' -%]
776
        <span class="sub_permission upload_general_files_subpermission">
786
        <span class="sub_permission upload_general_files_subpermission">
777
            Upload any file
787
            Upload any file
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt (+2 lines)
Lines 91-99 Link Here
91
                            </li>
91
                            </li>
92
                            [% END %]
92
                            [% END %]
93
93
94
                            [% IF ( CAN_user_lists ) %]
94
                            <li>
95
                            <li>
95
                                <a class="icon_general icon_lists" href="/cgi-bin/koha/virtualshelves/shelves.pl"><i class="fa fa-fw fa-list-alt"></i>Lists</a>
96
                                <a class="icon_general icon_lists" href="/cgi-bin/koha/virtualshelves/shelves.pl"><i class="fa fa-fw fa-list-alt"></i>Lists</a>
96
                            </li>
97
                            </li>
98
                            [% END %]
97
99
98
                            [% IF ( UseCourseReserves ) %]
100
                            [% IF ( UseCourseReserves ) %]
99
                                <li>
101
                                <li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt (-14 / +22 lines)
Lines 455-473 Link Here
455
                                </select>
455
                                </select>
456
                            </li>
456
                            </li>
457
                            <li>
457
                            <li>
458
                                <label for="public">Public: </label>
458
                                [% IF ( CAN_user_lists_create_public_lists ) %]
459
                                <select id="public" name="public" onchange="AdjustRemark()">
459
                                    <label for="public">Public: </label>
460
                                    [% IF shelf.is_private %]
460
                                    <select id="public" name="public" onchange="AdjustRemark()">
461
                                        <option value="0" selected="selected">Private</option>
461
                                        [% IF shelf.is_private %]
462
                                    [% ELSE %]
462
                                            <option value="0" selected="selected">Private</option>
463
                                        <option value="0">Private</option>
463
                                        [% ELSE %]
464
                                    [% END %]
464
                                            <option value="0">Private</option>
465
                                    [% IF shelf.is_public %]
465
                                        [% END %]
466
                                        <option value="1" selected="selected">Public</option>
466
                                        [% IF shelf.is_public %]
467
                                    [% ELSE %]
467
                                            <option value="1" selected="selected">Public</option>
468
                                        <option value="1">Public</option>
468
                                        [% ELSE %]
469
                                    [% END %]
469
                                            <option value="1">Public</option>
470
                                </select>
470
                                        [% END %]
471
                                    </select>
472
                                [% ELSE %]
473
                                    <label>Public: </label>
474
                                    <span>Private</span>
475
                                    <input id="public" name="public" value="0" type="hidden" />
476
                                [% END %]
471
                            </li>
477
                            </li>
472
                            [% INCLUDE list_permissions %]
478
                            [% INCLUDE list_permissions %]
473
                        </ol>
479
                        </ol>
Lines 494-500 Link Here
494
                [% WRAPPER tabs id= "tabs" %]
500
                [% WRAPPER tabs id= "tabs" %]
495
                    [% WRAPPER tabs_nav %]
501
                    [% WRAPPER tabs_nav %]
496
                        [% WRAPPER tab_item tabname= "privateshelves_tab" bt_active= 1 %] <span>Your lists</span> [% END %]
502
                        [% WRAPPER tab_item tabname= "privateshelves_tab" bt_active= 1 %] <span>Your lists</span> [% END %]
497
                        [% WRAPPER tab_item tabname= "publicshelves_tab" %] <span>Public lists</span> [% END %]
503
                        [% IF ( CAN_user_lists_use_public_lists ) %]
504
                            [% WRAPPER tab_item tabname= "publicshelves_tab" %] <span>Public lists</span> [% END %]
505
                        [% END %]
498
                    [% END # /WRAPPER tabs_nav %]
506
                    [% END # /WRAPPER tabs_nav %]
499
507
500
                    [% WRAPPER tab_panels %]
508
                    [% WRAPPER tab_panels %]
(-)a/t/Koha/Auth/Permissions.t (+2 lines)
Lines 167-175 subtest 'superlibrarian tests' => sub { Link Here
167
        'CAN_user_editcatalogue_set_record_sources'                 => 1,
167
        'CAN_user_editcatalogue_set_record_sources'                 => 1,
168
        'CAN_user_editcatalogue'                                    => 1,
168
        'CAN_user_editcatalogue'                                    => 1,
169
        'CAN_user_ill'                                              => 1,
169
        'CAN_user_ill'                                              => 1,
170
        'CAN_user_lists_create_public_lists'                        => 1,
170
        'CAN_user_lists_delete_public_lists'                        => 1,
171
        'CAN_user_lists_delete_public_lists'                        => 1,
171
        'CAN_user_lists_edit_public_lists'                          => 1,
172
        'CAN_user_lists_edit_public_lists'                          => 1,
172
        'CAN_user_lists_edit_public_list_contents'                  => 1,
173
        'CAN_user_lists_edit_public_list_contents'                  => 1,
174
        'CAN_user_lists_use_public_lists'                           => 1,
173
        'CAN_user_lists'                                            => 1,
175
        'CAN_user_lists'                                            => 1,
174
        'CAN_user_parameters_manage_accounts'                       => 1,
176
        'CAN_user_parameters_manage_accounts'                       => 1,
175
        'CAN_user_parameters_manage_additional_fields'              => 1,
177
        'CAN_user_parameters_manage_additional_fields'              => 1,
(-)a/virtualshelves/shelves.pl (-3 / +9 lines)
Lines 57-64 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
57
my $op      = $query->param('op')      || 'list';
57
my $op      = $query->param('op')      || 'list';
58
my $referer = $query->param('referer') || $op;
58
my $referer = $query->param('referer') || $op;
59
my $page    = int( $query->param('page') || 1 );
59
my $page    = int( $query->param('page') || 1 );
60
my $public  = $query->param('public') ? 1 : 0;
60
my ( $public, $shelf, $shelfnumber, @messages, $allow_transfer, $allow_create_public_lists );
61
my ( $shelf, $shelfnumber, @messages, $allow_transfer );
61
62
# work out permissions once
63
# this check is for the create list permission
64
$allow_create_public_lists = haspermission( $loggedinuser, { lists => 'create_public_lists' } ) ? 1 : 0;
65
66
# we want the user to be able to pick if public or private only if they are allowed
67
$public = ( $query->param('public') == 1 && $allow_create_public_lists == 1 ) ? 1 : 0;
62
68
63
# PART1: Perform a few actions
69
# PART1: Perform a few actions
64
if ( $op eq 'add_form' ) {
70
if ( $op eq 'add_form' ) {
Lines 397-402 $template->param( Link Here
397
    print    => scalar $query->param('print') || 0,
403
    print    => scalar $query->param('print') || 0,
398
    csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' })->as_list ],
404
    csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' })->as_list ],
399
    allow_transfer => $allow_transfer,
405
    allow_transfer => $allow_transfer,
406
    allow_create_public_lists => $allow_create_public_lists,
400
);
407
);
401
408
402
output_html_with_http_headers $query, $cookie, $template->output;
409
output_html_with_http_headers $query, $cookie, $template->output;
403
- 

Return to bug 13888