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

(-)a/C4/Utils/DataTables/VirtualShelves.pm (-1 / +15 lines)
Lines 15-25 sub search { Link Here
15
    my $dt_params = $params->{dt_params};
15
    my $dt_params = $params->{dt_params};
16
16
17
    # public is default
17
    # public is default
18
    $type = 2 if not $type or $type != 1;
18
    $type = 2 unless $type && ( $type == 1 || $type == 3 );
19
19
20
    # If not logged in user, be carreful and set the borrowernumber to 0
20
    # If not logged in user, be carreful and set the borrowernumber to 0
21
    # to prevent private lists lack
21
    # to prevent private lists lack
22
    my $loggedinuser = C4::Context->userenv->{'number'} || 0;
22
    my $loggedinuser = C4::Context->userenv->{'number'} || 0;
23
    
24
    if ( $type == 3 ) {
25
        my $permissions =
26
          C4::Auth::haspermission( C4::Context->userenv->{id}, { lists => '*' } );
27
28
        unless ($permissions && $permissions->{lists} == 1) {
29
            return {
30
                iTotalRecords        => 0,
31
                iTotalDisplayRecords => 0,
32
                shelves => [],
33
            };
34
        }
35
    }
23
36
24
    my ($iTotalRecords, $iTotalDisplayRecords);
37
    my ($iTotalRecords, $iTotalDisplayRecords);
25
38
Lines 125-130 sub search { Link Here
125
        $shelf->{can_delete_shelf} = $s->can_be_deleted( $loggedinuser );
138
        $shelf->{can_delete_shelf} = $s->can_be_deleted( $loggedinuser );
126
        $shelf->{is_shared} = $s->is_shared;
139
        $shelf->{is_shared} = $s->is_shared;
127
    }
140
    }
141
128
    return {
142
    return {
129
        iTotalRecords => $iTotalRecords,
143
        iTotalRecords => $iTotalRecords,
130
        iTotalDisplayRecords => $iTotalDisplayRecords,
144
        iTotalDisplayRecords => $iTotalDisplayRecords,
(-)a/Koha/Virtualshelf.pm (-1 / +14 lines)
Lines 47-53 Koha::Virtualshelf - Koha Virtualshelf Object class Link Here
47
=cut
47
=cut
48
48
49
our $PRIVATE = 1;
49
our $PRIVATE = 1;
50
our $PUBLIC = 2;
50
our $PUBLIC  = 2;
51
our $STAFF   = 3;
51
52
52
sub store {
53
sub store {
53
    my ( $self ) = @_;
54
    my ( $self ) = @_;
Lines 81-86 sub is_private { Link Here
81
    return $self->category == $PRIVATE;
82
    return $self->category == $PRIVATE;
82
}
83
}
83
84
85
sub is_staff {
86
    my ( $self ) = @_;
87
    return $self->category == $STAFF;
88
}
89
84
sub is_shelfname_valid {
90
sub is_shelfname_valid {
85
    my ( $self ) = @_;
91
    my ( $self ) = @_;
86
92
Lines 243-250 sub can_be_deleted { Link Here
243
249
244
sub can_be_managed {
250
sub can_be_managed {
245
    my ( $self, $borrowernumber ) = @_;
251
    my ( $self, $borrowernumber ) = @_;
252
246
    return 1
253
    return 1
247
      if $borrowernumber and $self->owner == $borrowernumber;
254
      if $borrowernumber and $self->owner == $borrowernumber;
255
256
    my $patron = Koha::Patrons->find( $borrowernumber );
257
    my $permissions = C4::Auth::haspermission( $patron->userid, { lists => '*' } );
258
    return 1
259
      if $borrowernumber and $self->category == 3 and $permissions and $permissions->{lists} == 1;
260
248
    return 0;
261
    return 0;
249
}
262
}
250
263
(-)a/Koha/Virtualshelves.pm (-5 / +33 lines)
Lines 35-44 Koha::Virtualshelf - Koha Virtualshelf Object class Link Here
35
35
36
=cut
36
=cut
37
37
38
=head3 type
39
40
=cut
41
42
sub get_private_shelves {
38
sub get_private_shelves {
43
    my ( $self, $params ) = @_;
39
    my ( $self, $params ) = @_;
44
    my $page = $params->{page};
40
    my $page = $params->{page};
Lines 62-68 sub get_private_shelves { Link Here
62
    );
58
    );
63
}
59
}
64
60
65
66
sub get_public_shelves {
61
sub get_public_shelves {
67
    my ( $self, $params ) = @_;
62
    my ( $self, $params ) = @_;
68
    my $page = $params->{page};
63
    my $page = $params->{page};
Lines 80-85 sub get_public_shelves { Link Here
80
    );
75
    );
81
}
76
}
82
77
78
=head3 get_staff_shelves
79
80
    my $shelves = $virtual_shelves->get_staff_shelves( { page => $page, rows => $rowss );
81
82
    Returns item lists that are visible to all staff that can manage patron lists
83
84
=cut
85
86
sub get_staff_shelves {
87
    my ( $self, $params ) = @_;
88
    my $page = $params->{page};
89
    my $rows = $params->{rows};
90
91
    $self->search(
92
        {
93
            category => 3,
94
        },
95
        {
96
            group_by => 'shelfnumber',
97
            order_by => 'shelfname',
98
            ( ( $page and $rows ) ? ( page => $page, rows => $rows ) : () ),
99
        }
100
    );
101
}
102
83
sub get_some_shelves {
103
sub get_some_shelves {
84
    my ( $self, $params ) = @_;
104
    my ( $self, $params ) = @_;
85
    my $borrowernumber = $params->{borrowernumber} || 0;
105
    my $borrowernumber = $params->{borrowernumber} || 0;
Lines 160-169 sub get_shelves_containing_record { Link Here
160
    );
180
    );
161
}
181
}
162
182
183
=head3 _type
184
185
=cut
186
163
sub _type {
187
sub _type {
164
    return 'Virtualshelve';
188
    return 'Virtualshelve';
165
}
189
}
166
190
191
=head3 object_class
192
193
=cut
194
167
sub object_class {
195
sub object_class {
168
    return 'Koha::Virtualshelf';
196
    return 'Koha::Virtualshelf';
169
}
197
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt (-2 / +26 lines)
Lines 2-8 Link Here
2
[% USE Koha %]
2
[% USE Koha %]
3
[% USE KohaDates %]
3
[% USE KohaDates %]
4
[% SET PRIVATE = 1 %]
4
[% SET PRIVATE = 1 %]
5
[% SET PUBLIC = 2 %]
5
[% SET PUBLIC  = 2 %]
6
[% SET STAFF   = 3 %]
6
[% SET footerjs = 1 %]
7
[% SET footerjs = 1 %]
7
[% INCLUDE 'doc-head-open.inc' %]
8
[% INCLUDE 'doc-head-open.inc' %]
8
<title>Koha &rsaquo; [% IF op == 'view' %]Lists &rsaquo; Contents of [% shelf.shelfname | html %][% ELSE %]Lists[% END %][% IF op == 'add_form' %] &rsaquo; Create new list[% END %][% IF op == 'edit_form' %] &rsaquo; Edit list [% shelf.shelfname | html %][% END %]</title>
9
<title>Koha &rsaquo; [% IF op == 'view' %]Lists &rsaquo; Contents of [% shelf.shelfname | html %][% ELSE %]Lists[% END %][% IF op == 'add_form' %] &rsaquo; Create new list[% END %][% IF op == 'edit_form' %] &rsaquo; Edit list [% shelf.shelfname | html %][% END %]</title>
Lines 48-53 Link Here
48
        [% ELSE %]
49
        [% ELSE %]
49
            Your lists
50
            Your lists
50
        [% END %]
51
        [% END %]
52
    [% ELSIF shelf AND shelf.is_staff %] &rsaquo;
53
        [% IF op == 'view' %]
54
            <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=list&amp;category=[% STAFF %]">Staff lists</a>
55
        [% ELSE %]
56
            Public lists
57
        [% END %]
51
    [% ELSIF shelf AND shelf.is_public %] &rsaquo;
58
    [% ELSIF shelf AND shelf.is_public %] &rsaquo;
52
        [% IF op == 'view' %]
59
        [% IF op == 'view' %]
53
            <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=list&amp;category=[% PUBLIC %]">Public lists</a>
60
            <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=list&amp;category=[% PUBLIC %]">Public lists</a>
Lines 297-302 Link Here
297
                [% ELSE %]
304
                [% ELSE %]
298
                    <option value="1">Private</option>
305
                    <option value="1">Private</option>
299
                [% END %]
306
                [% END %]
307
308
                [% IF shelf.is_staff %]
309
                    <option value="3" selected="selected">Staff only</option>
310
                [% ELSE %]
311
                    <option value="3">Staff only</option>
312
                [% END %]
313
300
                [% IF shelf.is_public %]
314
                [% IF shelf.is_public %]
301
                    <option value="2" selected="selected">Public</option>
315
                    <option value="2" selected="selected">Public</option>
302
                [% ELSE %]
316
                [% ELSE %]
Lines 332-337 Link Here
332
        <ul>
346
        <ul>
333
            <li id="privateshelves_tab" class="active"><a href="#tab_content">Your lists</a></li>
347
            <li id="privateshelves_tab" class="active"><a href="#tab_content">Your lists</a></li>
334
            <li id="publicshelves_tab" class="active"><a href="#tab_content">Public lists</a></li>
348
            <li id="publicshelves_tab" class="active"><a href="#tab_content">Public lists</a></li>
349
            [% IF can_manage_lists %]
350
                <li id="staffshelves_tab" class="active"><a href="#tab_content">[% CAN_user_lists %] Staff lists</a></li>
351
            [% END %]
335
        </ul>
352
        </ul>
336
353
337
        <div id="tab_content">
354
        <div id="tab_content">
Lines 439-444 Link Here
439
            $(document).ready(function(){
456
            $(document).ready(function(){
440
                [% IF category == PUBLIC %]
457
                [% IF category == PUBLIC %]
441
                    var type = [% PUBLIC %];
458
                    var type = [% PUBLIC %];
459
                [% ELSIF category == STAFF %]
460
                    var type = [% STAFF %];
442
                [% ELSE %]
461
                [% ELSE %]
443
                    var type = [% PRIVATE %];
462
                    var type = [% PRIVATE %];
444
                [% END %]
463
                [% END %]
Lines 498-504 Link Here
498
                dtListResults.fnAddFilters("filter", 750);
517
                dtListResults.fnAddFilters("filter", 750);
499
518
500
                var tabs = $("#tabs").tabs({
519
                var tabs = $("#tabs").tabs({
501
                    [% IF category == PUBLIC %]
520
                    [% IF category == STAFF %]
521
                        active: 2,
522
                    [% ELSIF category == PUBLIC %]
502
                        active: 1,
523
                        active: 1,
503
                    [% ELSE %]
524
                    [% ELSE %]
504
                        active: 0,
525
                        active: 0,
Lines 511-516 Link Here
511
                        } else if ( active == 1 ) {
532
                        } else if ( active == 1 ) {
512
                            type = [% PUBLIC %];
533
                            type = [% PUBLIC %];
513
                            dtListResults.fnDraw();
534
                            dtListResults.fnDraw();
535
                        } else if ( active == 2 ) {
536
                            type = [% STAFF %];
537
                            dtListResults.fnDraw();
514
                        }
538
                        }
515
                    }
539
                    }
516
                });
540
                });
(-)a/virtualshelves/shelves.pl (-1 / +4 lines)
Lines 343-348 if ( $op eq 'view' ) { Link Here
343
    }
343
    }
344
}
344
}
345
345
346
my $permissions = C4::Auth::haspermission( $loggedinuser, { lists => '*' } );
347
my $can_manage_lists = $permissions && $permissions->{lists} == 1;
348
346
$template->param(
349
$template->param(
347
    op       => $op,
350
    op       => $op,
348
    referer  => $referer,
351
    referer  => $referer,
Lines 351-356 $template->param( Link Here
351
    category => $category,
354
    category => $category,
352
    print    => scalar $query->param('print') || 0,
355
    print    => scalar $query->param('print') || 0,
353
    csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' }) ],
356
    csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' }) ],
357
    can_manage_lists => $can_manage_lists,
354
);
358
);
355
359
356
output_html_with_http_headers $query, $cookie, $template->output;
360
output_html_with_http_headers $query, $cookie, $template->output;
357
- 

Return to bug 20718