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

(-)a/C4/Utils/DataTables/VirtualShelves.pm (-1 / +20 lines)
Lines 15-26 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
23
24
    if ( $type == 3 ) {
25
        my $permissions =
26
          C4::Auth::haspermission( C4::Context->userenv->{id}, { lists => '*' } );
27
28
        unless (
29
            $permissions
30
            && (   $permissions->{superlibrarian} == 1
31
                || $permissions->{lists} == 1 )
32
          )
33
        {
34
            return {
35
                iTotalRecords        => 0,
36
                iTotalDisplayRecords => 0,
37
                shelves              => [],
38
            };
39
        }
40
    }
41
24
    my ($iTotalRecords, $iTotalDisplayRecords);
42
    my ($iTotalRecords, $iTotalDisplayRecords);
25
43
26
    my $dbh = C4::Context->dbh;
44
    my $dbh = C4::Context->dbh;
Lines 125-130 sub search { Link Here
125
        $shelf->{can_delete_shelf} = $s->can_be_deleted( $loggedinuser );
143
        $shelf->{can_delete_shelf} = $s->can_be_deleted( $loggedinuser );
126
        $shelf->{is_shared} = $s->is_shared;
144
        $shelf->{is_shared} = $s->is_shared;
127
    }
145
    }
146
128
    return {
147
    return {
129
        iTotalRecords => $iTotalRecords,
148
        iTotalRecords => $iTotalRecords,
130
        iTotalDisplayRecords => $iTotalDisplayRecords,
149
        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 3-9 Link Here
3
[% USE Koha %]
3
[% USE Koha %]
4
[% USE KohaDates %]
4
[% USE KohaDates %]
5
[% SET PRIVATE = 1 %]
5
[% SET PRIVATE = 1 %]
6
[% SET PUBLIC = 2 %]
6
[% SET PUBLIC  = 2 %]
7
[% SET STAFF   = 3 %]
7
[% SET footerjs = 1 %]
8
[% SET footerjs = 1 %]
8
[% INCLUDE 'doc-head-open.inc' %]
9
[% INCLUDE 'doc-head-open.inc' %]
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>
10
<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 49-54 Link Here
49
        [% ELSE %]
50
        [% ELSE %]
50
            Your lists
51
            Your lists
51
        [% END %]
52
        [% END %]
53
    [% ELSIF shelf AND shelf.is_staff %] &rsaquo;
54
        [% IF op == 'view' %]
55
            <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=list&amp;category=[% STAFF %]">Staff lists</a>
56
        [% ELSE %]
57
            Public lists
58
        [% END %]
52
    [% ELSIF shelf AND shelf.is_public %] &rsaquo;
59
    [% ELSIF shelf AND shelf.is_public %] &rsaquo;
53
        [% IF op == 'view' %]
60
        [% IF op == 'view' %]
54
            <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=list&amp;category=[% PUBLIC | html %]">Public lists</a>
61
            <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=list&amp;category=[% PUBLIC | html %]">Public lists</a>
Lines 306-311 Link Here
306
                [% ELSE %]
313
                [% ELSE %]
307
                    <option value="1">Private</option>
314
                    <option value="1">Private</option>
308
                [% END %]
315
                [% END %]
316
317
                [% IF shelf.is_staff %]
318
                    <option value="3" selected="selected">Staff only</option>
319
                [% ELSE %]
320
                    <option value="3">Staff only</option>
321
                [% END %]
322
309
                [% IF shelf.is_public %]
323
                [% IF shelf.is_public %]
310
                    <option value="2" selected="selected">Public</option>
324
                    <option value="2" selected="selected">Public</option>
311
                [% ELSE %]
325
                [% ELSE %]
Lines 341-346 Link Here
341
        <ul>
355
        <ul>
342
            <li id="privateshelves_tab" class="active"><a href="#tab_content">Your lists</a></li>
356
            <li id="privateshelves_tab" class="active"><a href="#tab_content">Your lists</a></li>
343
            <li id="publicshelves_tab" class="active"><a href="#tab_content">Public lists</a></li>
357
            <li id="publicshelves_tab" class="active"><a href="#tab_content">Public lists</a></li>
358
            [% IF can_manage_lists %]
359
                <li id="staffshelves_tab" class="active"><a href="#tab_content">[% CAN_user_lists %] Staff lists</a></li>
360
            [% END %]
344
        </ul>
361
        </ul>
345
362
346
        <div id="tab_content">
363
        <div id="tab_content">
Lines 449-454 Link Here
449
            $(document).ready(function(){
466
            $(document).ready(function(){
450
                [% IF category == PUBLIC %]
467
                [% IF category == PUBLIC %]
451
                    var type = [% PUBLIC | html %];
468
                    var type = [% PUBLIC | html %];
469
                [% ELSIF category == STAFF %]
470
                    var type = [% STAFF %];
452
                [% ELSE %]
471
                [% ELSE %]
453
                    var type = [% PRIVATE | html %];
472
                    var type = [% PRIVATE | html %];
454
                [% END %]
473
                [% END %]
Lines 508-514 Link Here
508
                dtListResults.fnAddFilters("filter", 750);
527
                dtListResults.fnAddFilters("filter", 750);
509
528
510
                var tabs = $("#tabs").tabs({
529
                var tabs = $("#tabs").tabs({
511
                    [% IF category == PUBLIC %]
530
                    [% IF category == STAFF %]
531
                        active: 2,
532
                    [% ELSIF category == PUBLIC %]
512
                        active: 1,
533
                        active: 1,
513
                    [% ELSE %]
534
                    [% ELSE %]
514
                        active: 0,
535
                        active: 0,
Lines 521-526 Link Here
521
                        } else if ( active == 1 ) {
542
                        } else if ( active == 1 ) {
522
                            type = [% PUBLIC | html %];
543
                            type = [% PUBLIC | html %];
523
                            dtListResults.fnDraw();
544
                            dtListResults.fnDraw();
545
                        } else if ( active == 2 ) {
546
                            type = [% STAFF %];
547
                            dtListResults.fnDraw();
524
                        }
548
                        }
525
                    }
549
                    }
526
                });
550
                });
(-)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( C4::Context->userenv->{id}, { lists => '*' } );
347
my $can_manage_lists = $permissions && ( $permissions->{superlibrarian} == 1 || $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