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

(-)a/C4/Output.pm (-3 / +16 lines)
Lines 86-95 This function returns HTML, without any language dependency. Link Here
86
=cut
86
=cut
87
87
88
sub pagination_bar {
88
sub pagination_bar {
89
	my $base_url = (@_ ? shift : $ENV{SCRIPT_NAME} . $ENV{QUERY_STRING}) or return;
89
    my $base_url = (@_ ? shift : $ENV{SCRIPT_NAME} . $ENV{QUERY_STRING});
90
    return unless defined $base_url;
90
    my $nb_pages       = (@_) ? shift : 1;
91
    my $nb_pages       = (@_) ? shift : 1;
91
    my $current_page   = (@_) ? shift : undef;	# delay default until later
92
    my $current_page   = (@_) ? shift : undef;	# delay default until later
92
    my $startfrom_name = (@_) ? shift : 'page';
93
    my $startfrom_name = (@_) ? shift : 'page';
94
    my $additional_parameters = shift || {};
93
95
94
    # how many pages to show before and after the current page?
96
    # how many pages to show before and after the current page?
95
    my $pages_around = 2;
97
    my $pages_around = 2;
Lines 106-111 sub pagination_bar { Link Here
106
	$base_url =~ s/$delim$//;		# remove trailing delim
108
	$base_url =~ s/$delim$//;		# remove trailing delim
107
109
108
    my $url = $base_url . (($base_url =~ m/$delim/ or $base_url =~ m/\?/) ? '&' : '?' ) . $startfrom_name . '=';
110
    my $url = $base_url . (($base_url =~ m/$delim/ or $base_url =~ m/\?/) ? '&' : '?' ) . $startfrom_name . '=';
111
    my $url_suffix;
112
    while ( my ( $k, $v ) = each %$additional_parameters ) {
113
        $url_suffix .= '&' . $k . '=' . $v;
114
    }
109
    my $pagination_bar = '';
115
    my $pagination_bar = '';
110
116
111
    # navigation bar useful only if more than one page to display !
117
    # navigation bar useful only if more than one page to display !
Lines 117-123 sub pagination_bar { Link Here
117
                "\n" . ' '
123
                "\n" . ' '
118
              . '<a href="'
124
              . '<a href="'
119
              . $url
125
              . $url
120
              . '1" rel="start">'
126
              . '1'
127
              . $url_suffix
128
              . '"rel="start">'
121
              . '&lt;&lt;' . '</a>';
129
              . '&lt;&lt;' . '</a>';
122
        }
130
        }
123
        else {
131
        else {
Lines 134-139 sub pagination_bar { Link Here
134
              . '<a href="'
142
              . '<a href="'
135
              . $url
143
              . $url
136
              . $previous
144
              . $previous
145
              . $url_suffix
137
              . '" rel="prev">' . '&lt;' . '</a>';
146
              . '" rel="prev">' . '&lt;' . '</a>';
138
        }
147
        }
139
        else {
148
        else {
Lines 172-178 sub pagination_bar { Link Here
172
                        "\n" . '&nbsp;'
181
                        "\n" . '&nbsp;'
173
                      . '<a href="'
182
                      . '<a href="'
174
                      . $url
183
                      . $url
175
                      . $page_number . '">'
184
                      . $page_number
185
                      . $url_suffix
186
                      . '">'
176
                      . $page_number . '</a>';
187
                      . $page_number . '</a>';
177
                }
188
                }
178
                $last_displayed_page = $page_number;
189
                $last_displayed_page = $page_number;
Lines 187-192 sub pagination_bar { Link Here
187
              . '&nbsp;<a href="'
198
              . '&nbsp;<a href="'
188
              . $url
199
              . $url
189
              . $next
200
              . $next
201
              . $url_suffix
190
              . '" rel="next">' . '&gt;' . '</a>';
202
              . '" rel="next">' . '&gt;' . '</a>';
191
        }
203
        }
192
        else {
204
        else {
Lines 200-205 sub pagination_bar { Link Here
200
              . '&nbsp;<a href="'
212
              . '&nbsp;<a href="'
201
              . $url
213
              . $url
202
              . $nb_pages
214
              . $nb_pages
215
              . $url_suffix
203
              . '" rel="last">'
216
              . '" rel="last">'
204
              . '&gt;&gt;' . '</a>';
217
              . '&gt;&gt;' . '</a>';
205
        }
218
        }
(-)a/C4/Utils/DataTables/VirtualShelves.pm (-3 / +4 lines)
Lines 5-11 use C4::Branch qw/onlymine/; Link Here
5
use C4::Context;
5
use C4::Context;
6
use C4::Members qw/GetMemberIssuesAndFines/;
6
use C4::Members qw/GetMemberIssuesAndFines/;
7
use C4::Utils::DataTables;
7
use C4::Utils::DataTables;
8
use C4::VirtualShelves;
8
use Koha::Virtualshelves;
9
9
10
sub search {
10
sub search {
11
    my ( $params ) = @_;
11
    my ( $params ) = @_;
Lines 121-128 sub search { Link Here
121
    ( $iTotalRecords ) = $dbh->selectrow_array( $query, undef, @args );
121
    ( $iTotalRecords ) = $dbh->selectrow_array( $query, undef, @args );
122
122
123
    for my $shelf ( @$shelves ) {
123
    for my $shelf ( @$shelves ) {
124
        $shelf->{can_manage_shelf} = C4::VirtualShelves::ShelfPossibleAction( $loggedinuser, $shelf->{shelfnumber}, 'manage' );
124
        my $s = Koha::Virtualshelves->find( $shelf->{shelfnumber} );
125
        $shelf->{can_delete_shelf} = C4::VirtualShelves::ShelfPossibleAction( $loggedinuser, $shelf->{shelfnumber}, 'delete_shelf' );
125
        $shelf->{can_manage_shelf} = $s->can_be_managed( $loggedinuser );
126
        $shelf->{can_delete_shelf} = $s->can_be_deleted( $loggedinuser );
126
    }
127
    }
127
    return {
128
    return {
128
        iTotalRecords => $iTotalRecords,
129
        iTotalRecords => $iTotalRecords,
(-)a/C4/VirtualShelves/Page.pm (-19 lines)
Lines 68-74 sub shelfpage { Link Here
68
    loggedinuser => $loggedinuser,
68
    loggedinuser => $loggedinuser,
69
    OpacAllowPublicListCreation => C4::Context->preference('OpacAllowPublicListCreation'),
69
    OpacAllowPublicListCreation => C4::Context->preference('OpacAllowPublicListCreation'),
70
    );
70
    );
71
    my $edit;
72
    my $shelves;
71
    my $shelves;
73
    my @paramsloop;
72
    my @paramsloop;
74
    my $totitems;
73
    my $totitems;
Lines 209-215 sub shelfpage { Link Here
209
                my $shelf = Koha::Virtualshelves->find( $shelfnumber );
208
                my $shelf = Koha::Virtualshelves->find( $shelfnumber );
210
                my $member = GetMember( 'borrowernumber' => $shelf->owner );
209
                my $member = GetMember( 'borrowernumber' => $shelf->owner );
211
                my $ownername = defined($member) ? $member->{firstname} . " " . $member->{surname} : '';
210
                my $ownername = defined($member) ? $member->{firstname} . " " . $member->{surname} : '';
212
                $edit = 1;
213
                $template->param(
211
                $template->param(
214
                    edit                => 1,
212
                    edit                => 1,
215
                    display             => $displaymode,
213
                    display             => $displaymode,
Lines 231-239 sub shelfpage { Link Here
231
        #View a shelf
229
        #View a shelf
232
        if ( $shelfnumber = $query->param('viewshelf') ) {
230
        if ( $shelfnumber = $query->param('viewshelf') ) {
233
            my $shelf = Koha::Virtualshelves->find( $shelfnumber );
231
            my $shelf = Koha::Virtualshelves->find( $shelfnumber );
234
            $template->param(
235
                'DisplayMultiPlaceHold' => C4::Context->preference('DisplayMultiPlaceHold'),
236
            );
237
            if (C4::Context->preference('TagsEnabled')) {
232
            if (C4::Context->preference('TagsEnabled')) {
238
                $template->param(TagsEnabled => 1);
233
                $template->param(TagsEnabled => 1);
239
                    foreach (qw(TagsShowOnList TagsInputOnList)) {
234
                    foreach (qw(TagsShowOnList TagsInputOnList)) {
Lines 494-513 sub shelfpage { Link Here
494
        csv_profiles                                                       => GetCsvProfilesLoop('marc')
489
        csv_profiles                                                       => GetCsvProfilesLoop('marc')
495
    );
490
    );
496
491
497
    unless( $shelfnumber or $shelves or $edit ) {
498
        # Only used for intranet
499
        $template->param( op => 'list' );
500
    }
501
502
    if ($shelves or    # note: this part looks duplicative, but is intentional
503
        $edit
504
      ) {
505
        $template->param( seflag => 1 );
506
        #This hack is just another argument for refactoring this script one day
507
        #At this point you are adding or editing a list; if you add, then you add a private list (by default) with permissions as below; if you edit, do not pass these permissions, they must come from the database
508
        $template->param( allow_add => 0, allow_delete_own => 1, allow_delete_other => 0) unless $shelfnumber;
509
    }
510
511
#Next call updates the shelves for the Lists button.
492
#Next call updates the shelves for the Lists button.
512
#May not always be needed (when nothing changed), but doesn't take much.
493
#May not always be needed (when nothing changed), but doesn't take much.
513
    my ($total, $pubshelves, $barshelves) = C4::VirtualShelves::GetSomeShelfNames($loggedinuser, 'MASTHEAD');
494
    my ($total, $pubshelves, $barshelves) = C4::VirtualShelves::GetSomeShelfNames($loggedinuser, 'MASTHEAD');
(-)a/Koha/Virtualshelf.pm (+56 lines)
Lines 19-24 use Modern::Perl; Link Here
19
19
20
use Carp;
20
use Carp;
21
21
22
use C4::Auth;
23
24
use Koha::Borrowers;
22
use Koha::Database;
25
use Koha::Database;
23
use Koha::DateUtils qw( dt_from_string );
26
use Koha::DateUtils qw( dt_from_string );
24
use Koha::Exceptions;
27
use Koha::Exceptions;
Lines 201-206 sub remove_biblios { Link Here
201
    return $number_removed;
204
    return $number_removed;
202
}
205
}
203
206
207
sub can_be_viewed {
208
    my ( $self, $borrowernumber ) = @_;
209
    return 1 if $self->category == $PUBLIC;
210
    return 0 unless $borrowernumber;
211
    return 1 if $self->owner == $borrowernumber;
212
    return $self->get_shares->search(
213
        {
214
            borrowernumber => $borrowernumber,
215
        }
216
    )->count;
217
}
218
219
sub can_be_deleted {
220
    my ( $self, $borrowernumber ) = @_;
221
222
    return unless $borrowernumber;
223
    return 1 if $self->owner == $borrowernumber;
224
225
    my $patron = Koha::Borrowers->find( $borrowernumber );
226
227
    return 1 if $self->category == $PUBLIC and C4::Auth::haspermission( $patron->userid, { lists => 'delete_public_lists' } );
228
229
    return 0;
230
}
231
232
sub can_be_managed {
233
    my ( $self, $borrowernumber ) = @_;
234
    return 1
235
      if $borrowernumber and $self->owner == $borrowernumber;
236
    return 0;
237
}
238
239
sub can_biblios_be_added {
240
    my ( $self, $borrowernumber ) = @_;
241
242
    return 1
243
      if $borrowernumber
244
      and ( $self->owner == $borrowernumber
245
         or $self->allow_add );
246
    return 0;
247
}
248
249
sub can_biblios_be_removed {
250
    my ( $self, $borrowernumber ) = @_;
251
252
    return 1
253
      if $borrowernumber
254
      and (  $self->owner == $borrowernumber
255
          or $self->allow_delete_own
256
          or $self->allow_delete_other );
257
    return 0;
258
}
259
204
sub type {
260
sub type {
205
    return 'Virtualshelve';
261
    return 'Virtualshelve';
206
}
262
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/virtualshelves-toolbar.inc (-14 / +10 lines)
Lines 1-7 Link Here
1
<script type="text/javascript">
1
<script type="text/javascript">
2
//<![CDATA[
2
//<![CDATA[
3
3
4
[% IF ( viewshelf ) %]
4
[% IF op == 'view' %]
5
5
6
    function sendList(){
6
    function sendList(){
7
        open(CGIBIN+'virtualshelves/sendshelf.pl?shelfid=[% shelfnumber %]','win_form','scrollbars=no,resizable=no,height=300,width=450,top=50,left=100');
7
        open(CGIBIN+'virtualshelves/sendshelf.pl?shelfid=[% shelfnumber %]','win_form','scrollbars=no,resizable=no,height=300,width=450,top=50,left=100');
Lines 13-19 Link Here
13
            return false;
13
            return false;
14
        });
14
        });
15
        $("#deleteshelf").click(function(e){
15
        $("#deleteshelf").click(function(e){
16
            if(confirmDelete(_("Are you sure you want to delete this list?"))){
16
            if(confirm(_("Are you sure you want to delete this list?"))){
17
                return true;
17
                return true;
18
            } else {
18
            } else {
19
                e.preventDefault();
19
                e.preventDefault();
Lines 27-46 Link Here
27
</script>
27
</script>
28
28
29
<div id="toolbar" class="btn-toolbar">
29
<div id="toolbar" class="btn-toolbar">
30
    <div class="btn-group"><a id="newshelf" class="btn btn-small" href="/cgi-bin/koha/virtualshelves/shelves.pl?shelves=1"><i class="icon-plus"></i> New list</a></div>
30
    <div class="btn-group"><a id="newshelf" class="btn btn-small" href="/cgi-bin/koha/virtualshelves/shelves.pl?op=add_form&amp;referer=[% op %]"><i class="icon-plus"></i> New list</a></div>
31
31
32
    [% IF ( viewshelf ) %]
32
    [% IF op == 'view' %]
33
        [% IF ( manageshelf ) %]
33
        [% IF can_manage_shelf %]
34
        <div class="btn-group">
34
        <div class="btn-group">
35
            <button class="btn btn-small dropdown-toggle" data-toggle="dropdown"><i class="icon-pencil"></i> Edit <span class="caret"></span></button>
35
            <button class="btn btn-small dropdown-toggle" data-toggle="dropdown"><i class="icon-pencil"></i> Edit <span class="caret"></span></button>
36
                <ul class="dropdown-menu">
36
            <ul class="dropdown-menu">
37
                    <li><a href="/cgi-bin/koha/virtualshelves/shelves.pl?shelfnumber=[% shelfnumber %]&amp;op=modif&amp;display=viewshelf">Edit list</a></li>
37
                <li><a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=edit_form&amp;shelfnumber=[% shelf.shelfnumber %]&amp;referer=[% op %]">Edit list</a></li>
38
                    [% IF ( showprivateshelves ) %]
38
                <li><a id="deleteshelf" href="/cgi-bin/koha/virtualshelves/shelves.pl?op=delete&amp;shelfnumber=[% shelf.shelfnumber %]">Delete list</a></li>
39
                        <li><a id="deleteshelf" href="/cgi-bin/koha/virtualshelves/shelves.pl?display=privateshelves&amp;shelves=1&amp;DEL-[% shelfnumber %]=1">Delete list</a></li>
39
            </ul>
40
                    [% ELSE %]
41
                        <li><a id="deleteshelf" href="/cgi-bin/koha/virtualshelves/shelves.pl?shelves=1&amp;DEL-[% shelfnumber %]=1">Delete list</a></li>
42
                    [% END %]
43
                </ul>
44
        </div>
40
        </div>
45
        [% END %]
41
        [% END %]
46
42
Lines 56-61 Link Here
56
                </ul>
52
                </ul>
57
        </div>
53
        </div>
58
        <div class="btn-group"><a class="btn btn-small" href="#" id="sendlist"><i class="icon-envelope"></i> Send list</a></div>
54
        <div class="btn-group"><a class="btn btn-small" href="#" id="sendlist"><i class="icon-envelope"></i> Send list</a></div>
59
        <div class="btn-group"><a class="btn btn-small" id="printlist" target="_blank" href="/cgi-bin/koha/virtualshelves/shelves.pl?viewshelf=[% shelfnumber %]&amp;print=1"><i class="icon-print"></i> Print list</a></div>
55
        <div class="btn-group"><a class="btn btn-small" id="printlist" target="_blank" href="/cgi-bin/koha/virtualshelves/shelves.pl?op=view&amp;shelfnumber=[% shelf.shelfnumber %]&amp;print=1"><i class="icon-print"></i> Print list</a></div>
60
    [% END %]
56
    [% END %]
61
</div>
57
</div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-2 / +2 lines)
Lines 359-365 function verify_images() { Link Here
359
        [% IF ( GetShelves ) %]
359
        [% IF ( GetShelves ) %]
360
            <span class="results_summary"><span class="label">Lists that include this title: </span>
360
            <span class="results_summary"><span class="label">Lists that include this title: </span>
361
            [% FOREACH GetShelve IN GetShelves %]
361
            [% FOREACH GetShelve IN GetShelves %]
362
                <a href="/cgi-bin/koha/virtualshelves/shelves.pl?viewshelf=[% GetShelve.shelfnumber %]">[% GetShelve.shelfname %]</a>
362
                <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=view&amp;shelfnumber=[% GetShelve.shelfnumber %]">[% GetShelve.shelfname %]</a>
363
                [% IF ( loop.last ) %][% ELSE %]|[% END %]
363
                [% IF ( loop.last ) %][% ELSE %]|[% END %]
364
            [% END %]
364
            [% END %]
365
            </span>
365
            </span>
Lines 524-530 function verify_images() { Link Here
524
	        <li><strong>Lists that include this title: </strong>
524
	        <li><strong>Lists that include this title: </strong>
525
	        <ul>
525
	        <ul>
526
	        [% FOREACH GetShelve IN GetShelves %]
526
	        [% FOREACH GetShelve IN GetShelves %]
527
		        <li><a href="/cgi-bin/koha/virtualshelves/shelves.pl?viewshelf=[% GetShelve.shelfnumber %]">[% GetShelve.shelfname %]</a></li>
527
		        <li><a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=view&amp;shelfnumber=[% GetShelve.shelfnumber %]">[% GetShelve.shelfname %]</a></li>
528
	        [% END %]
528
	        [% END %]
529
	        </ul>
529
	        </ul>
530
	        </li>
530
	        </li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/downloadshelf.tt (+16 lines)
Lines 3-8 Link Here
3
[% INCLUDE 'doc-head-close.inc' %]
3
[% INCLUDE 'doc-head-close.inc' %]
4
</head>
4
</head>
5
<body id="lists_downloadshelf" class="lists" style="padding:1em;">
5
<body id="lists_downloadshelf" class="lists" style="padding:1em;">
6
7
[% FOR m IN messages %]
8
    <div class="dialog [% m.type %]">
9
        [% SWITCH m.code %]
10
        [% CASE 'unauthorized' %]
11
            You do not have permission to view this list.
12
        [% CASE 'does_not_exist' %]
13
            This list does not exist.
14
        [% CASE %]
15
            [% m.code %]
16
        [% END %]
17
    </div>
18
[% END %]
19
20
21
6
[% IF ( format ) %]
22
[% IF ( format ) %]
7
    <p>Your download should begin automatically.</p>
23
    <p>Your download should begin automatically.</p>
8
[% ELSE %]
24
[% ELSE %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt (-188 / +187 lines)
Lines 1-5 Link Here
1
[% USE Koha %]
2
[% USE KohaDates %]
3
[% SET PRIVATE = 1 %]
4
[% SET PUBLIC = 2 %]
1
[% INCLUDE 'doc-head-open.inc' %]
5
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; [% IF ( viewshelf ) %]Lists &rsaquo; Contents of [% shelfname | html %][% ELSE %]Lists[% END %][% IF ( shelves ) %] &rsaquo; Create new list[% END %][% IF ( edit ) %] &rsaquo; Edit list [% shelfname | html %][% END %]</title>
6
<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>
3
[% INCLUDE 'doc-head-close.inc' %]
7
[% INCLUDE 'doc-head-close.inc' %]
4
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
8
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
5
[% INCLUDE 'datatables.inc' %]
9
[% INCLUDE 'datatables.inc' %]
Lines 14-20 Link Here
14
</script>
18
</script>
15
[% END %]
19
[% END %]
16
20
17
[% IF ( viewshelf ) %]
21
[% IF op == 'view' %]
18
    <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
22
    <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
19
    <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.fixFloat.js"></script>
23
    <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.fixFloat.js"></script>
20
[% END %]
24
[% END %]
Lines 27-33 var MSG_CONFIRM_DELETE_LIST = _("Are you sure you want to remove this list?"); Link Here
27
31
28
[% IF op == 'list' %]
32
[% IF op == 'list' %]
29
$(document).ready(function(){
33
$(document).ready(function(){
30
    var type = 1;
34
    [% IF category == PUBLIC %]
35
        var type = [% PUBLIC %];
36
    [% ELSE %]
37
        var type = [% PRIVATE %];
38
    [% END %]
31
    var dtListResults = $("#listresultst").dataTable($.extend(true, {}, dataTablesDefaults, {
39
    var dtListResults = $("#listresultst").dataTable($.extend(true, {}, dataTablesDefaults, {
32
        'bServerSide': true,
40
        'bServerSide': true,
33
        'sAjaxSource': "/cgi-bin/koha/svc/virtualshelves/search",
41
        'sAjaxSource': "/cgi-bin/koha/svc/virtualshelves/search",
Lines 81-93 $(document).ready(function(){ Link Here
81
    dtListResults.fnAddFilters("filter", 750);
89
    dtListResults.fnAddFilters("filter", 750);
82
90
83
    var tabs = $("#tabs").tabs({
91
    var tabs = $("#tabs").tabs({
92
        [% IF category == PUBLIC %]
93
            active: 1,
94
        [% ELSE %]
95
            active: 0,
96
        [% END %]
84
        activate: function(e, ui) {
97
        activate: function(e, ui) {
85
            var active = tabs.tabs("option", "active" );
98
            var active = tabs.tabs("option", "active" );
86
            if ( active == 0 ) {
99
            if ( active == 0 ) {
87
                type = 1; // private
100
                type = [% PRIVATE %];
88
                dtListResults.fnDraw();
101
                dtListResults.fnDraw();
89
            } else if ( active == 1 ) {
102
            } else if ( active == 1 ) {
90
                type = 2; // public
103
                type = [% PUBLIC %];
91
                dtListResults.fnDraw();
104
                dtListResults.fnDraw();
92
            }
105
            }
93
        }
106
        }
Lines 95-101 $(document).ready(function(){ Link Here
95
});
108
});
96
[% END %]
109
[% END %]
97
110
98
[% IF ( viewshelf ) %]
111
[% IF op == 'view' %]
99
$(document).ready(function(){
112
$(document).ready(function(){
100
    [% IF ( itemsloop ) %]$('#searchheader').fixFloat();[% END %]
113
    [% IF ( itemsloop ) %]$('#searchheader').fixFloat();[% END %]
101
    $("span.clearall").html("<a id=\"CheckNone\" href=\"/cgi-bin/koha/shelves.pl\">"+_("Clear all")+"<\/a>");
114
    $("span.clearall").html("<a id=\"CheckNone\" href=\"/cgi-bin/koha/shelves.pl\">"+_("Clear all")+"<\/a>");
Lines 173-186 $(document).ready(function(){ Link Here
173
});
186
});
174
[% END %]
187
[% END %]
175
188
176
	function confirmDelete(message){
177
		if (window.confirm(message)) {
178
		    location.href="/cgi-bin/koha/virtualshelves/shelves.pl?[% IF ( showprivateshelves ) %]display=privateshelves&[% END %]shelves=1&DEL-[% shelfnumber %]=1&shelfoff=[% shelfoff %]";
179
		} else { 
180
			return false;
181
		}
182
	}
183
184
    /**
189
    /**
185
     * This function checks if the adequate number of records are checked for merging
190
     * This function checks if the adequate number of records are checked for merging
186
     */
191
     */
Lines 272-306 function placeHold () { Link Here
272
[% INCLUDE 'header.inc' %]
277
[% INCLUDE 'header.inc' %]
273
[% INCLUDE 'cat-search.inc' %]
278
[% INCLUDE 'cat-search.inc' %]
274
279
275
[% BLOCK list_permissions %]
280
<div id="breadcrumbs">
276
    <li>
281
    <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
277
        <label for="permissions">Permissions: </label>
282
    [% IF op != 'list' %]
278
        <select name="allow_add" id="allow_add">
283
        <a href="/cgi-bin/koha/virtualshelves/shelves.pl">Lists</a>
279
            [% IF allow_add %]<option value="0">Do not allow</option>[% ELSE %]<option value="0" selected="selected">Do not allow</option>[% END %]
284
    [% ELSE %]
280
            [% IF allow_add %]<option value="1" selected="selected">Allow</option>[% ELSE %]<option value="1">Allow</option>[% END %]
285
        Lists
281
        </select>
286
    [% END %]
282
        &nbsp;<span>anyone else to add entries.</span>
287
    [% IF shelf AND shelf.category == PRIVATE %] &rsaquo;
283
    </li>
288
        [% IF op == 'view' OR op == 'edit_form' %]
284
    <li>
289
            <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=list&amp;category=[% PRIVATE %]">Your lists</a>
285
        <label>&nbsp;</label>
290
        [% ELSE %]
286
        <select name="allow_delete_own" id="allow_delete_own">
291
            Your lists
287
            [% IF allow_delete_own %]<option value="0">Do not allow</option>[% ELSE %]<option value="0" selected="selected">Do not allow</option>[% END %]
292
        [% END %]
288
            [% IF allow_delete_own %]<option value="1" selected="selected">Allow</option>[% ELSE %]<option value="1">Allow</option>[% END %]
293
    [% ELSIF shelf AND shelf.category == PUBLIC %] &rsaquo;
289
        </select>
294
        [% IF op == 'view' %]
290
        &nbsp;<span>anyone to remove his own contributed entries.</span>
295
            <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=list&amp;category=[% PUBLIC %]">Public lists</a>
291
    </li>
296
        [% ELSE %]
292
    <li>
297
            Public lists
293
        <label>&nbsp;</label>
298
        [% END %]
294
        <select name="allow_delete_other" id="allow_delete_other">
299
    [% END %]
295
            [% IF allow_delete_other %]<option value="0">Do not allow</option>[% ELSE %]<option value="0" selected="selected">Do not allow</option>[% END %]
296
            [% IF allow_delete_other %]<option value="1" selected="selected">Allow</option>[% ELSE %]<option value="1">Allow</option>[% END %]
297
        </select>
298
        &nbsp;<span>anyone to remove other contributed entries.</span>
299
    </li>
300
[% END %]
301
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/virtualshelves/shelves.pl">Lists</a> [% IF ( category1 ) %] &rsaquo; [% IF ( viewshelf || edit ) %] <a href="/cgi-bin/koha/virtualshelves/shelves.pl?display=privateshelves">Your lists</a> [% ELSE %] Your lists [% END %] [% ELSIF ( category2 ) %] &rsaquo; [% IF ( viewshelf ) %] <a href="/cgi-bin/koha/virtualshelves/shelves.pl?display=publicshelves">Public lists</a> [% ELSE %] Public lists [% END %] [% ELSIF ( showprivateshelves ) %] &rsaquo; [% IF ( viewshelf || edit ) %] <a href="/cgi-bin/koha/virtualshelves/shelves.pl?display=privateshelves">Your lists</a> [% ELSE %] Your lists [% END %] [% ELSIF ( showpublicshelves ) %] &rsaquo; [% IF ( viewshelf || edit ) %] <a href="/cgi-bin/koha/virtualshelves/shelves.pl?display=publicshelves">Public lists</a> [% ELSE %] Public lists [% END %] [% END %]
302
300
303
[% IF ( viewshelf ) %]&rsaquo; Contents of <i>[% shelfname | html %]</i>[% END %][% IF ( shelves ) %] &rsaquo; Create new list[% END %][% IF ( edit ) %] &rsaquo; Edit list <i>[% shelfname | html %]</i>[% END %]</div>
301
[% IF op == 'view' %]&rsaquo; Contents of <i>[% shelf.shelfname | html %]</i>[% END %][% IF op == 'add_form' %] &rsaquo; Create new list[% END %][% IF op == 'edit_form' %] &rsaquo; Edit list <i>[% shelf.shelfname | html %]</i>[% END %]</div>
304
302
305
<div id="doc3" class="yui-t2">
303
<div id="doc3" class="yui-t2">
306
<div id="bd">
304
<div id="bd">
Lines 318-387 function placeHold () { Link Here
318
        [% CASE 'error_on_insert' %]
316
        [% CASE 'error_on_insert' %]
319
            An error occurred when inserting this list. Perhaps the name already exists.
317
            An error occurred when inserting this list. Perhaps the name already exists.
320
        [% CASE 'error_on_delete' %]
318
        [% CASE 'error_on_delete' %]
321
            An error occurred when deleteing this list. Check the logs.
319
            An error occurred when deleting this list. Check the logs.
320
        [% CASE 'error_on_add_biblio' %]
321
            The item has not been added to the list. Please check it's not in this list yet.
322
        [% CASE 'success_on_update' %]
322
        [% CASE 'success_on_update' %]
323
            List updated with success.
323
            List updated with success.
324
        [% CASE 'success_on_insert' %]
324
        [% CASE 'success_on_insert' %]
325
            List inserted with success.
325
            List inserted with success.
326
        [% CASE 'success_on_delete' %]
326
        [% CASE 'success_on_delete' %]
327
            List deleted with success.
327
            List deleted with success.
328
        [% CASE 'Koha::Exception::DuplicateObject' %]
328
        [% CASE 'success_on_add_biblio' %]
329
            The item has been added to the list.
330
        [% CASE 'success_on_remove_biblios' %]
331
            The item has been removed from the list.
332
        [% CASE 'does_not_exist' %]
333
            This list does not exist.
334
        [% CASE 'item_does_not_exist' %]
335
            This item does not exist.
336
        [% CASE 'unauthorized_on_view' %]
337
            You do not have permission to view this list.
338
        [% CASE 'unauthorized_on_update' %]
339
            You do not have permission to update this list.
340
        [% CASE 'unauthorized_on_delete' %]
341
            You do not have permission to delete this list.
342
        [% CASE 'unauthorized_on_add_biblio' %]
343
            You do not have permission to add a biblio to this list.
344
        [% CASE 'no_biblio_removed' %]
345
            No biblio has been removed.
346
        [% CASE 'Koha::Exceptions::Virtualshelves::DuplicateObject' %]
329
            An error occurred when inserting this list. The name already [% shelfname %] exists.
347
            An error occurred when inserting this list. The name already [% shelfname %] exists.
348
        [% CASE 'DBIx::Class::Exception' %]
349
            [% m.msg %]
330
        [% CASE %]
350
        [% CASE %]
331
            [% m.code %]
351
            [% m.code %]
332
        [% END %]
352
        [% END %]
333
    </div>
353
    </div>
334
[% END %]
354
[% END %]
335
355
336
[% IF ( paramsloop ) %]
356
[% IF op == 'view' %]
337
[% FOREACH paramsloo IN paramsloop %]
338
<div class="yui-ge">
339
    <div class="yui-u first">
340
		[% IF ( paramsloo.status ) %]<div class="dialog alert">[% paramsloo.string %]</div>[% END %]
341
		[% IF ( paramsloo.nobarcode ) %]<div class="dialog alert">ERROR: No barcode given.</div>[% END %] 
342
        [% IF ( paramsloo.noshelfnumber ) %]<div class="dialog alert">ERROR: No list number given.</div>[% END %]
343
		[% IF ( paramsloo.need_confirm ) %]
344
		<div class="dialog alert">The list <i>[% paramsloo.need_confirm %]</i> is not empty.
345
            [% IF ( paramsloo.single ) %]
346
                <br />It has <b>[% paramsloo.count %]</b> entry.
347
            [% ELSE %]
348
                <br />It has <b>[% paramsloo.count %]</b> entries.
349
            [% END %]
350
			<br />Use the "Confirm" button below to confirm deletion.
351
		</div>
352
		[% END %]
353
		[% IF ( paramsloo.nopermission ) %]
354
		<div class="dialog alert">ERROR: You do not have adequate permission for that action on list [% paramsloo.nopermission %].</div>
355
		[% END %]
356
		[% IF ( paramsloo.failgetitem ) %]
357
		<div class="dialog alert">ERROR: No item found with barcode [% paramsloo.failgetitem %].</div>
358
		[% END %] 
359
		[% IF ( paramsloo.duplicatebiblio ) %]
360
		<div class="dialog alert">A record matching barcode <b>[% paramsloo.duplicatebiblio %]</b> has already been added.</div>
361
		[% END %]
362
                [% IF ( paramsloo.nothingdeleted) %]
363
                      <div class="dialog message">Warning: You could not delete any of the selected items from this list.</div>
364
                [% END %]
365
                [% IF ( paramsloo.somedeleted) %]
366
                      <div class="dialog message">Warning: You could not delete all selected items from this list.</div>
367
                [% END %]
368
                [% IF ( paramsloo.modifyfailure) %]
369
                      <div class="dialog message">ERROR: List could not be modified.</div>
370
                [% END %]
371
	</div>
372
</div>
373
[% END %]
374
[% END %] 
375
376
[% IF ( viewshelf ) %]
377
   <div class="yui-g">
357
   <div class="yui-g">
378
    [% IF ( itemsloop ) %]
358
    [% IF itemsloop %]
379
359
380
    <h3>Contents of <i>[% shelfname | html %]</i></h3>
360
    <h3>Contents of <i>[% shelf.shelfname | html %]</i></h3>
381
    <div class="pages">[% pagination_bar %]</div>
361
    <div class="pages">[% pagination_bar %]</div>
382
    <form action="/cgi-bin/koha/virtualshelves/shelves.pl" id="listform" method="post" class="checkboxed">
362
    <form action="/cgi-bin/koha/virtualshelves/shelves.pl" id="listform" method="post" class="checkboxed">
383
        <input type="hidden" name="viewshelf" value="[% shelfnumber %]" />
363
        <input type="hidden" name="op" value="remove_biblios" />
384
        <input type="hidden" name="modifyshelfcontents" value="1" />
364
        <input type="hidden" name="referer" value="view" />
365
        <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber %]" />
385
366
386
[% IF direction == 'asc' %]
367
[% IF direction == 'asc' %]
387
    [% SET new_direction = 'desc' %]
368
    [% SET new_direction = 'desc' %]
Lines 391-406 function placeHold () { Link Here
391
[% END %]
372
[% END %]
392
373
393
<div id="searchheader" class="noprint">
374
<div id="searchheader" class="noprint">
394
    [% IF ( itemsloop ) %]
375
    [% IF itemsloop %]
395
        <div id="selection_ops"><span class="checkall"></span> |
376
        <div id="selection_ops"><span class="checkall"></span> |
396
        <span class="clearall"></span>
377
        <span class="clearall"></span>
397
378
398
        <span class="addto">| </span>
379
        <span class="addto">| </span>
399
        &nbsp;
380
        &nbsp;
400
        [% IF ( CAN_user_reserveforothers && DisplayMultiPlaceHold ) %]
381
        [% IF CAN_user_reserveforothers && Koha.Preference('DisplayMultiPlaceHold') %]
401
            <div class="btn-group"><button class="btn btn-mini placehold"><i class="icon-hold"></i> Place hold</button></div>
382
            <div class="btn-group"><button class="btn btn-mini placehold"><i class="icon-hold"></i> Place hold</button></div>
402
        [% END %]
383
        [% END %]
403
        [% IF ( allowremovingitems ) %]
384
        [% IF can_remove_biblios %]
404
            <div class="btn-group"><button type="submit" class="btn btn-mini list-remove"><i class="icon-remove-sign"></i> Remove selected</button></div>
385
            <div class="btn-group"><button type="submit" class="btn btn-mini list-remove"><i class="icon-remove-sign"></i> Remove selected</button></div>
405
        [% END %]
386
        [% END %]
406
        [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]<div class="btn-group"><button type="submit" class="btn btn-mini merge-items"><i class="icon-merge"></i> Merge selected</button></div>[% END %]
387
        [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]<div class="btn-group"><button type="submit" class="btn btn-mini merge-items"><i class="icon-merge"></i> Merge selected</button></div>[% END %]
Lines 414-429 function placeHold () { Link Here
414
395
415
                [% UNLESS ( item_level_itypes ) %]<th>Item type</th>[% END %]
396
                [% UNLESS ( item_level_itypes ) %]<th>Item type</th>[% END %]
416
                <th>
397
                <th>
417
                    <a href="/cgi-bin/koha/virtualshelves/shelves.pl?viewshelf=[% shelfnumber %]&amp;sort=title&amp;direction=[% IF sort != 'title' %]asc[% ELSE %][% new_direction %][% END %]">Title</a>
398
                    <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=view&amp;shelfnumber=[% shelf.shelfnumber %]&amp;sortfield=title&amp;direction=[% IF sortfield != 'title' %]asc[% ELSE %][% new_direction %][% END %]">Title</a>
418
                    [% IF sort == 'title' %]
399
                    [% IF sortfield == 'title' %]
419
                        <img src="[% interface %]/[% theme %]/img/[% direction %].gif" alt="[% direction %] sort" />
400
                        <img src="[% interface %]/[% theme %]/img/[% direction %].gif" alt="[% direction %] sort" />
420
                    [% ELSE %]
401
                    [% ELSE %]
421
                        <img src="[% interface %]/[% theme %]/img/ascdesc.gif" alt="" />
402
                        <img src="[% interface %]/[% theme %]/img/ascdesc.gif" alt="" />
422
                    [% END %]
403
                    [% END %]
423
                </th>
404
                </th>
424
                <th>
405
                <th>
425
                    <a href="/cgi-bin/koha/virtualshelves/shelves.pl?viewshelf=[% shelfnumber %]&amp;sort=author&amp;direction=[% IF sort != 'author' %]asc[% ELSE %][% new_direction %][% END %]">Author</a>
406
                    <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=view&amp;shelfnumber=[% shelf.shelfnumber %]&amp;sortfield=author&amp;direction=[% IF sortfield != 'author' %]asc[% ELSE %][% new_direction %][% END %]">Author</a>
426
                   [% IF sort == 'author' %]
407
                   [% IF sortfield == 'author' %]
427
                        <img src="[% interface %]/[% theme %]/img/[% direction %].gif" alt="[% direction %] sort" />
408
                        <img src="[% interface %]/[% theme %]/img/[% direction %].gif" alt="[% direction %] sort" />
428
                   [% ELSE %]
409
                   [% ELSE %]
429
                       <img src="[% interface %]/[% theme %]/img/ascdesc.gif" alt="" />
410
                       <img src="[% interface %]/[% theme %]/img/ascdesc.gif" alt="" />
Lines 431-460 function placeHold () { Link Here
431
                 </th>
412
                 </th>
432
                <th>Date added</th>
413
                <th>Date added</th>
433
                <th>
414
                <th>
434
                    <a href="/cgi-bin/koha/virtualshelves/shelves.pl?viewshelf=[% shelfnumber %]&amp;sort=itemcallnumber&amp;direction=[% IF sort != 'itemcallnumber' %]asc[% ELSE %][% new_direction %][% END %]">Call number</a>
415
                    <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=view&amp;shelfnumber=[% shelf.shelfnumber %]&amp;sortfield=itemcallnumber&amp;direction=[% IF sortfield != 'itemcallnumber' %]asc[% ELSE %][% new_direction %][% END %]">Call number</a>
435
                   [% IF sort == 'itemcallnumber' %]
416
                   [% IF sortfield == 'itemcallnumber' %]
436
                        <img src="[% interface %]/[% theme %]/img/[% direction %].gif" alt="[% direction %] sort" />
417
                        <img src="[% interface %]/[% theme %]/img/[% direction %].gif" alt="[% direction %] sort" />
437
                   [% ELSE %]
418
                   [% ELSE %]
438
                       <img src="[% interface %]/[% theme %]/img/ascdesc.gif" alt="" />
419
                       <img src="[% interface %]/[% theme %]/img/ascdesc.gif" alt="" />
439
                   [% END %]
420
                   [% END %]
440
                 </th>
421
                 </th>
441
            </tr>
422
            </tr>
442
		[% FOREACH itemsloo IN itemsloop %]
423
        [% FOREACH itemsloo IN itemsloop %]
443
			[% UNLESS ( loop.odd ) %]
424
            [% UNLESS ( loop.odd ) %]
444
			<tr class="highlight">
425
                <tr class="highlight">
445
			[% ELSE %]
426
            [% ELSE %]
446
			<tr>
427
                <tr>
447
			[% END %]
428
            [% END %]
448
			[% IF ( itemsloop ) %]
429
            [% IF itemsloop %]
449
			<td>
430
                <td>
450
				[% IF ( itemsloo.confirm ) %]
431
                    <input type="checkbox" class="selection" value="[% itemsloo.biblionumber %]" name="biblionumber" />
451
				<input type="hidden"   name="CONFIRM-[% itemsloo.confirm %]" />
432
                </td>
452
				<input type="checkbox" class="selection" value="[% itemsloo.biblionumber %]" name="REM-[% itemsloo.biblionumber %]" checked />
433
            [% END %]
453
				[% ELSE %]
454
				<input type="checkbox" class="selection" value="[% itemsloo.biblionumber %]" name="REM-[% itemsloo.biblionumber %]" />
455
				[% END %]
456
			</td>
457
			[% END %]
458
			[% UNLESS ( item_level_itypes ) %]<td>
434
			[% UNLESS ( item_level_itypes ) %]<td>
459
                [% UNLESS ( noItemTypeImages || !itemsloo.imageurl ) %]<img src="[% itemsloo.imageurl %]" alt="[% itemsloo.description %]" title="[% itemsloo.description %]" />[% END %][% itemsloo.description %]
435
                [% UNLESS ( noItemTypeImages || !itemsloo.imageurl ) %]<img src="[% itemsloo.imageurl %]" alt="[% itemsloo.description %]" title="[% itemsloo.description %]" />[% END %][% itemsloo.description %]
460
			</td>[% END %]
436
			</td>[% END %]
Lines 483-492 function placeHold () { Link Here
483
                            | <a href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=[% itemsloo.biblionumber %]">Edit items</a>
459
                            | <a href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=[% itemsloo.biblionumber %]">Edit items</a>
484
                        [% END %]
460
                        [% END %]
485
                    </p>
461
                    </p>
486
			</td>
462
            </td>
487
			<td>[% itemsloo.author %]</td>
463
            <td>[% itemsloo.author %]</td>
488
			<td>[% itemsloo.dateadded %]</td>
464
            <td>[% itemsloo.dateadded | $KohaDates%]</td>
489
			<td>
465
            <td>
490
                <ul>
466
                <ul>
491
                [% FOREACH result IN itemsloo.ITEM_RESULTS %]
467
                [% FOREACH result IN itemsloo.ITEM_RESULTS %]
492
                    <li>[% result.holdingbranch %] [% IF ( result.location_intranet ) %] ([% result.location_intranet %]) [% END %]
468
                    <li>[% result.holdingbranch %] [% IF ( result.location_intranet ) %] ([% result.location_intranet %]) [% END %]
Lines 505-592 function placeHold () { Link Here
505
481
506
	[% END %]
482
	[% END %]
507
   </div>
483
   </div>
508
[% END %]<!-- /viewshelf -->
484
[% END %]
509
485
510
[% IF ( debug ) %]
486
[% IF can_add_biblios %]
511
  [% IF ( edit ) %]<div>Edit is on ([% shelfname | html %])</div>[% END %]
487
<div class="yui-g">
512
  [% IF ( seflag ) %]<div>seflag is on ([% seflag %])</div>[% END %]
488
<form action="/cgi-bin/koha/virtualshelves/shelves.pl" method="post">
489
 <fieldset class="brief noprint">
490
    <legend>Add an item to <i>[% shelfname | html %]</i></legend>
491
        <ol>
492
            <li>
493
                <label for="barcode">Barcode:</label>
494
                <input name="barcode" type="text" id="barcode" size="14" />
495
                <input type="hidden" name="op" value="add_biblio" />
496
                <input type="hidden" name="referer" value="view" />
497
                <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber %]" />
498
                <input type="submit" value="Add" />
499
            </li>
500
        </ol>
501
 </fieldset>
502
</form>
503
</div>
513
[% END %]
504
[% END %]
514
505
515
[% IF ( seflag ) %]
506
[% IF op == 'add_form' OR op == 'edit_form' %]
516
<div class="yui-ge">
507
<div class="yui-ge">
517
    <div class="yui-u first">
508
    <div class="yui-u first">
518
    <form method="post" action="/cgi-bin/koha/virtualshelves/shelves.pl" class="validated">
509
    <form method="post" action="/cgi-bin/koha/virtualshelves/shelves.pl" class="validated">
519
        <fieldset class="rows">
510
        <fieldset class="rows">
520
511
521
    [% IF ( shelves ) %]
512
        [% IF op == 'add_form' %]
522
        <legend>Create a new list</legend>
513
            <legend>Create a new list</legend>
523
        <input type="hidden" name="shelves" value="1" />
514
            <input type="hidden" name="op" value="add" />
515
        [% ELSE %]
516
            <legend>Edit list <i>[% shelf.shelfname | html %]</i></legend>
517
            <input type="hidden" name="op" value="edit" />
518
        [% END %]
519
        <input type="hidden" name="referer" value="[% referer %]" />
520
        <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber %]" />
524
        <ol>
521
        <ol>
525
        <li><label class="required" for="addshelf">List name:</label><input id="addshelf" type="text" name="addshelf" size="25" required="required" class="required" />
522
            <li>
523
                <label for="shelfname" class="required">Name: </label><input type="text" id="shelfname" name="shelfname" size="25" value="[% shelf.shelfname |html %]" required="required" class="required" />
526
            <span class="required">Required</span>
524
            <span class="required">Required</span>
527
        </li>
525
            </li>
528
        <li><span class="label">Owner: </span><input type="hidden" name="owner" id="owner" value="[% loggedinuser %]" />[% loggedinusername %]</li>
526
            <li>
529
        <li><label for="sortfield" >Sort this list by: </label>
527
                <span class="label">Owner: </span>
530
        <select name="sortfield" id="sortfield">
528
                [% IF op == 'add_form' %]
531
            <option value="title">Title</option>
529
                    <input type="hidden" name="owner" id="owner" value="[% loggedinusernumber %]" />[% loggedinusername %]</li>
532
            <option value="author">Author</option>
530
                [% ELSE %]
533
            <option value="copyrightdate">Copyrightdate</option>
531
                    [% IF owner %]
534
            <option value="itemcallnumber">Call number</option>
532
                        <input type="hidden" id="owner" name="owner" value="[% owner.borrowernumber %]" />[% owner.firstname _ ' ' _ owner.surname %]
535
        </select></li>
533
                    [% ELSE %]
536
        <li><label for="category">Category: </label>
534
                        <input type="hidden" id="owner" name="owner" value="[% loggedinusernumber %]" />[% loggedinusername %]
537
            <select name="category" id="category">
535
                    [% END %]
538
                  <option value="1">Private</option>
536
                [% END %]
539
                  <option value="2">Public</option>
537
            </li>
540
                     </select></li>
538
            <li><label for="sortfield" >Sort this list by: </label>
541
            [% INCLUDE list_permissions %]
539
            <select name="sortfield">
542
        </ol>
540
            [% IF shelf.sortfield == "title" %]<option value="title" selected="selected">Title</option>[% ELSE %]<option value="title">Title</option>[% END %]
543
    [% END %]
541
            [% IF shelf.sortfield == "author" %]<option value="author" selected="selected">Author</option>[% ELSE %]<option value="author">Author</option>[% END %]
544
542
            [% IF shelf.sortfield == "copyrightdate" %]<option value="copyrightdate" selected="selected">Copyrightdate</option>[% ELSE %]<option value="copyrightdate">Copyrightdate</option>[% END %]
545
    [% IF ( edit ) %]
543
            [% IF shelf.sortfield == "itemcallnumber" %]<option value="itemcallnumber" selected="selected">Call number</option>[% ELSE %]<option value="itemcallnumber">Call number</option>[% END %]
546
        <legend>Edit list <i>[% shelfname | html %]</i></legend>
544
            </select></li>
547
        <input type="hidden" name="display" value="[% display %]" />
545
            <li><label for="category">Category: </label>
548
        <input type="hidden" name="op" value="modifsave" />
546
                <select id="category" name="category">
549
        [% IF ( showprivateshelves ) %]<input type="hidden" name="display" value="privateshelves" />[% END %]
547
                [% IF shelf.category == PRIVATE %]
550
        <input type="hidden" name="shelfnumber" value="[% shelfnumber %]" />
548
                    <option value="1" selected="selected">Private</option>
551
		<ol>
549
                [% ELSE %]
552
            <li><label for="shelfname" class="required">Name: </label><input type="text" id="shelfname" name="shelfname" size="25" value="[% shelfname |html %]" required="required" class="required" />
550
                    <option value="1">Private</option>
553
            <span class="required">Required</span>
551
                [% END %]
554
        </li>
552
                [% IF shelf.category == PUBLIC %]
555
		<li><label for="owner">Owner: </label><input type="hidden" id="owner" name="owner" value="[% IF ( owner ) %][% ownername %][% ELSE %][% loggedinusername %][% END %]" />[% IF ( owner ) %][% ownername %][% ELSE %][% loggedinusername %][% END %]</li>
553
                    <option value="2" selected="selected">Public</option>
556
		<li><label for="sortfield" >Sort this list by: </label>
554
                [% ELSE %]
557
		<select name="sortfield">
555
                    <option value="2">Public</option>
558
        [% IF ( sortfield == "title" ) %]<option value="title" selected="selected">Title</option>[% ELSE %]<option value="title">Title</option>[% END %]
556
                [% END %]
559
        [% IF ( sortfield == "author" ) %]<option value="author" selected="selected">Author</option>[% ELSE %]<option value="author">Author</option>[% END %]
557
                           </select></li>
560
        [% IF ( sortfield == "copyrightdate" ) %]<option value="copyrightdate" selected="selected">Copyrightdate</option>[% ELSE %]<option value="copyrightdate">Copyrightdate</option>[% END %]
561
        [% IF ( sortfield == "itemcallnumber" ) %]<option value="itemcallnumber" selected="selected">Call number</option>[% ELSE %]<option value="itemcallnumber">Call number</option>[% END %]
562
		</select></li>
563
		<li><label for="category">Category: </label>
564
			<select id="category" name="category">
565
			[% IF ( category1 ) %]
566
				<option value="1" selected="selected">Private</option>
567
			[% ELSE %]
568
				<option value="1">Private</option>
569
			[% END %]
570
			[% IF ( category2 ) %]
571
				<option value="2" selected="selected">Public</option>
572
			[% ELSE %]
573
				<option value="2">Public</option>
574
			[% END %]
575
                       </select></li>
576
            [% INCLUDE list_permissions %]
577
            </ol>
578
	[% END %]
579
558
580
		</fieldset>
559
            [% FOR permission IN ['allow_add', 'allow_delete_own', 'allow_delete_other'] %]
560
                <li>
561
                    [% IF loop.first %]
562
                        <label for="permissions">Permissions: </label>
563
                    [% ELSE %]
564
                        <label>&nbsp;</label>
565
                    [% END %]
566
                    <select name="[% permission %]" id="[% permission %]">
567
                        [% IF shelf.$permission %]<option value="0">Do not allow</option>[% ELSE %]<option value="0" selected="selected">Do not allow</option>[% END %]
568
                        [% IF shelf.$permission %]<option value="1" selected="selected">Allow</option>[% ELSE %]<option value="1">Allow</option>[% END %]
569
                    </select>
570
                    [% SWITCH permission %]
571
                        [% CASE 'allow_add' %]&nbsp;<span>anyone else to add entries.</span>
572
                        [% CASE 'allow_delete_own' %]&nbsp;<span>anyone to remove his own contributed entries.</span>
573
                        [% CASE 'allow_delete_other' %]&nbsp;<span>anyone to remove other contributed entries.</span>
574
                    [% END %]
575
                </li>
576
            [% END %]
577
        </ol>
578
    </fieldset>
581
579
582
    <fieldset class="action"><input type="submit" value="Save" class="submit" />
580
    <fieldset class="action">
583
        [% IF ( showprivateshelves ) %]
581
        <input type="submit" value="Save" class="submit" />
584
            <a href="/cgi-bin/koha/virtualshelves/shelves.pl?display=privateshelves" class="cancel">Cancel</a>
582
        [% IF referer == 'view' %]
585
        [% ELSE %]
583
           <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=view&amp;shelfnumber=[% shelf.shelfnumber %]" class="cancel">Cancel</a>
586
            [% IF ( display == "viewshelf" ) %]
584
       [% ELSE %]
587
               <a href="/cgi-bin/koha/virtualshelves/shelves.pl?viewshelf=[% shelfnumber %]" class="cancel">Cancel</a>
585
            [% IF category == PUBLIC %]
586
                <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=list&amp;category=[% PUBLIC %]" class="cancel">Cancel</a>
588
            [% ELSE %]
587
            [% ELSE %]
589
                <a href="/cgi-bin/koha/virtualshelves/shelves.pl" class="cancel">Cancel</a>
588
                <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=list&amp;category=[% PRIVATE %]" class="cancel">Cancel</a>
590
            [% END %]
589
            [% END %]
591
        [% END %]
590
        [% END %]
592
    </fieldset>
591
    </fieldset>
Lines 601-607 function placeHold () { Link Here
601
        </div>
600
        </div>
602
    </div>
601
    </div>
603
</div>
602
</div>
604
[% END %]<!-- /seflag -->
603
[% END %]
605
604
606
[% IF op == 'list' %]
605
[% IF op == 'list' %]
607
    <h2>Lists</h2>
606
    <h2>Lists</h2>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/tables/shelves_results.tt (-9 / +6 lines)
Lines 10-16 Link Here
10
                "dt_type":
10
                "dt_type":
11
                    "[% data.type %]",
11
                    "[% data.type %]",
12
                "dt_shelfname":
12
                "dt_shelfname":
13
                    "<a href='/cgi-bin/koha/virtualshelves/shelves.pl?viewshelf=[% data.shelfnumber %]'>[% data.shelfname | html%]</a>",
13
                    "<a href='/cgi-bin/koha/virtualshelves/shelves.pl?op=view&shelfnumber=[% data.shelfnumber %]'>[% data.shelfname | html%]</a>",
14
                "dt_count":
14
                "dt_count":
15
                    "[% data.count %] item(s)",
15
                    "[% data.count %] item(s)",
16
                "dt_owner":
16
                "dt_owner":
Lines 34-40 Link Here
34
    [%~ IF can_manage_shelf ~%]
34
    [%~ IF can_manage_shelf ~%]
35
        [%~ action_block =                '<form action="shelves.pl" method="get">' ~%]
35
        [%~ action_block =                '<form action="shelves.pl" method="get">' ~%]
36
        [%~ action_block = action_block _ '<input type="hidden" name="shelfnumber" value="' _ shelfnumber  _ '" />' ~%]
36
        [%~ action_block = action_block _ '<input type="hidden" name="shelfnumber" value="' _ shelfnumber  _ '" />' ~%]
37
        [%~ action_block = action_block _ '<input type="hidden" name="op" value="modif" />' ~%]
37
        [%~ action_block = action_block _ '<input type="hidden" name="op" value="edit_form" />' ~%]
38
        [%~ action_block = action_block _ '<input type="hidden" name="category" value="' _ type _ '" />' ~%]
38
        [%~ action_block = action_block _ '<input type="submit" class="editshelf" value="Edit" />' ~%]
39
        [%~ action_block = action_block _ '<input type="submit" class="editshelf" value="Edit" />' ~%]
39
        [%~ action_block = action_block _ '</form>' ~%]
40
        [%~ action_block = action_block _ '</form>' ~%]
40
    [%~ END ~%]
41
    [%~ END ~%]
Lines 42-54 Link Here
42
        [%~ action_block = action_block _ '<form action="shelves.pl" method="post">' ~%]
43
        [%~ action_block = action_block _ '<form action="shelves.pl" method="post">' ~%]
43
        [%~ action_block = action_block _ '<input type="hidden" name="shelfoff" value="' _ shelfoff _ '" />' ~%]
44
        [%~ action_block = action_block _ '<input type="hidden" name="shelfoff" value="' _ shelfoff _ '" />' ~%]
44
        [%~ action_block = action_block _ '<input type="hidden" name="shelves" value="1" />' ~%]
45
        [%~ action_block = action_block _ '<input type="hidden" name="shelves" value="1" />' ~%]
45
        [%~ action_block = action_block _ '<input type="hidden" name="DEL-' _ shelfnumber _ '" value="1" />' ~%]
46
        [%~ action_block = action_block _ '<input type="hidden" name="op" value="delete" />' ~%]
46
        [%~ action_block = action_block _ '<input type="hidden" name="CONFIRM-' _ shelfnumber _ '" value="1" />' ~%]
47
        [%~ action_block = action_block _ '<input type="hidden" name="shelfnumber" value="' _ shelfnumber  _ '" />' ~%]
47
        [%~ IF type == 1 ~%]
48
        [%~ action_block = action_block _ '<input type="hidden" name="category" value="' _ type _ '" />' ~%]
48
            [%~ action_block = action_block _ '<input type="hidden" name="display" value="privateshelves" />' ~%]
49
        [%~ ELSE ~%]
50
            [%~ action_block = action_block _ '<input type="hidden" name="display" value="publicshelves" />' ~%]
51
        [%~ END ~%]
52
        [%~ action_block = action_block _ '<input type="submit" class="deleteshelf" onclick="return confirmDelete(MSG_CONFIRM_DELETE_LIST)" value="Delete" />' ~%]
49
        [%~ action_block = action_block _ '<input type="submit" class="deleteshelf" onclick="return confirmDelete(MSG_CONFIRM_DELETE_LIST)" value="Delete" />' ~%]
53
        [%~ action_block = action_block _ '</form>' ~%]
50
        [%~ action_block = action_block _ '</form>' ~%]
54
    [%~ END ~%]
51
    [%~ END ~%]
(-)a/t/db_dependent/Virtualshelves.t (-1 / +106 lines)
Lines 1-7 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
use Test::More tests => 3;
4
use Test::More tests => 4;
5
use DateTime::Duration;
5
use DateTime::Duration;
6
6
7
use C4::Context;
7
use C4::Context;
Lines 236-238 subtest 'Shelf content' => sub { Link Here
236
    $number_of_contents = Koha::Virtualshelfcontents->search->count;
236
    $number_of_contents = Koha::Virtualshelfcontents->search->count;
237
    is( $number_of_contents, 1, 'The biblio should have been deleted to the shelf by the patron 2, even if it is not his own content (allow_delete_other=1)' );
237
    is( $number_of_contents, 1, 'The biblio should have been deleted to the shelf by the patron 2, even if it is not his own content (allow_delete_other=1)' );
238
};
238
};
239
240
subtest 'Shelf permissions' => sub {
241
242
    plan tests => 40;
243
    my $patron1 = $builder->build( { source => 'Borrower', value => { flags => '2096766' } } ); # 2096766 is everything checked but not superlibrarian
244
    my $patron2 = $builder->build( { source => 'Borrower', value => { flags => '1048190' } } ); # 1048190 is everything checked but not superlibrarian and delete_public_lists
245
    my $biblio1 = $builder->build( { source => 'Biblio', } );
246
    my $biblio2 = $builder->build( { source => 'Biblio', } );
247
    my $biblio3 = $builder->build( { source => 'Biblio', } );
248
    my $biblio4 = $builder->build( { source => 'Biblio', } );
249
250
251
    my $public_shelf = Koha::Virtualshelf->new(
252
        {   shelfname    => "my first shelf",
253
            owner        => $patron1->{borrowernumber},
254
            category     => 2,
255
            allow_add          => 0,
256
            allow_delete_own   => 0,
257
            allow_delete_other => 0,
258
        }
259
    )->store;
260
261
    is( $public_shelf->can_be_viewed( $patron1->{borrowernumber} ), 1, 'The owner should be able to view his public list' );
262
    is( $public_shelf->can_be_viewed( $patron2->{borrowernumber} ), 1, 'Public list should be viewed by someone else' );
263
264
    is( $public_shelf->can_be_deleted( $patron1->{borrowernumber} ), 1, 'The owner should be able to delete his list' );
265
    is( $public_shelf->can_be_deleted( $patron2->{borrowernumber} ), 0, 'Public list should not be deleted by someone else' );
266
267
    is( $public_shelf->can_be_managed( $patron1->{borrowernumber} ), 1, 'The owner should be able to manage his list' );
268
    is( $public_shelf->can_be_managed( $patron2->{borrowernumber} ), 0, 'Public list should not be managed by someone else' );
269
270
    is( $public_shelf->can_biblios_be_added( $patron1->{borrowernumber} ), 1, 'The owner should be able to add biblios to his list' );
271
    is( $public_shelf->can_biblios_be_added( $patron2->{borrowernumber} ), 0, 'Public list should not be modified (add) by someone else' );
272
273
    is( $public_shelf->can_biblios_be_removed( $patron1->{borrowernumber} ), 1, 'The owner should be able to remove biblios to his list' );
274
    is( $public_shelf->can_biblios_be_removed( $patron2->{borrowernumber} ), 0, 'Public list should not be modified (remove) by someone else' );
275
276
277
    $public_shelf->allow_add(1);
278
    $public_shelf->allow_delete_own(1);
279
    $public_shelf->allow_delete_other(1);
280
    $public_shelf->store;
281
282
    is( $public_shelf->can_be_viewed( $patron1->{borrowernumber} ), 1, 'The owner should be able to view his public list' );
283
    is( $public_shelf->can_be_viewed( $patron2->{borrowernumber} ), 1, 'Public list should be viewed by someone else' );
284
285
    is( $public_shelf->can_be_deleted( $patron1->{borrowernumber} ), 1, 'The owner should be able to delete his list' );
286
    is( $public_shelf->can_be_deleted( $patron2->{borrowernumber} ), 0, 'Public list should not be deleted by someone else' );
287
288
    is( $public_shelf->can_be_managed( $patron1->{borrowernumber} ), 1, 'The owner should be able to manage his list' );
289
    is( $public_shelf->can_be_managed( $patron2->{borrowernumber} ), 0, 'Public list should not be managed by someone else' );
290
291
    is( $public_shelf->can_biblios_be_added( $patron1->{borrowernumber} ), 1, 'The owner should be able to add biblios to his list' );
292
    is( $public_shelf->can_biblios_be_added( $patron2->{borrowernumber} ), 1, 'Public list should not be modified (add) by someone else' );
293
294
    is( $public_shelf->can_biblios_be_removed( $patron1->{borrowernumber} ), 1, 'The owner should be able to remove biblios to his list' );
295
    is( $public_shelf->can_biblios_be_removed( $patron2->{borrowernumber} ), 1, 'Public list should not be modified (remove) by someone else' );
296
297
298
    my $private_shelf = Koha::Virtualshelf->new(
299
        {   shelfname    => "my first shelf",
300
            owner        => $patron1->{borrowernumber},
301
            category     => 1,
302
            allow_add          => 0,
303
            allow_delete_own   => 0,
304
            allow_delete_other => 0,
305
        }
306
    )->store;
307
308
    is( $private_shelf->can_be_viewed( $patron1->{borrowernumber} ), 1, 'The owner should be able to view his list' );
309
    is( $private_shelf->can_be_viewed( $patron2->{borrowernumber} ), 0, 'Private list should not be viewed by someone else' );
310
311
    is( $private_shelf->can_be_deleted( $patron1->{borrowernumber} ), 1, 'The owner should be able to delete his list' );
312
    is( $private_shelf->can_be_deleted( $patron2->{borrowernumber} ), 0, 'Private list should not be deleted by someone else' );
313
314
    is( $private_shelf->can_be_managed( $patron1->{borrowernumber} ), 1, 'The owner should be able to manage his list' );
315
    is( $private_shelf->can_be_managed( $patron2->{borrowernumber} ), 0, 'Private list should not be managed by someone else' );
316
317
    is( $private_shelf->can_biblios_be_added( $patron1->{borrowernumber} ), 1, 'The owner should be able to add biblios to his list' );
318
    is( $private_shelf->can_biblios_be_added( $patron2->{borrowernumber} ), 0, 'Private list should not be modified (add) by someone else' );
319
320
    is( $private_shelf->can_biblios_be_removed( $patron1->{borrowernumber} ), 1, 'The owner should be able to remove biblios to his list' );
321
    is( $private_shelf->can_biblios_be_removed( $patron2->{borrowernumber} ), 0, 'Private list should not be modified (remove) by someone else' );
322
323
324
    $private_shelf->allow_add(1);
325
    $private_shelf->allow_delete_own(1);
326
    $private_shelf->allow_delete_other(1);
327
    $private_shelf->store;
328
329
    is( $private_shelf->can_be_viewed( $patron1->{borrowernumber} ), 1, 'The owner should be able to view his list' );
330
    is( $private_shelf->can_be_viewed( $patron2->{borrowernumber} ), 0, 'Private list should not be viewed by someone else' );
331
332
    is( $private_shelf->can_be_deleted( $patron1->{borrowernumber} ), 1, 'The owner should be able to delete his list' );
333
    is( $private_shelf->can_be_deleted( $patron2->{borrowernumber} ), 0, 'Private list should not be deleted by someone else' );
334
335
    is( $private_shelf->can_be_managed( $patron1->{borrowernumber} ), 1, 'The owner should be able to manage his list' );
336
    is( $private_shelf->can_be_managed( $patron2->{borrowernumber} ), 0, 'Private list should not be managed by someone else' );
337
338
    is( $private_shelf->can_biblios_be_added( $patron1->{borrowernumber} ), 1, 'The owner should be able to add biblios to his list' );
339
    is( $private_shelf->can_biblios_be_added( $patron2->{borrowernumber} ), 1, 'Private list could be modified (add) by someone else # individual check done later' );
340
341
    is( $private_shelf->can_biblios_be_removed( $patron1->{borrowernumber} ), 1, 'The owner should be able to remove biblios to his list' );
342
    is( $private_shelf->can_biblios_be_removed( $patron2->{borrowernumber} ), 1, 'Private list could be modified (remove) by someone else # individual check done later' );
343
};
(-)a/virtualshelves/addbybiblionumber.pl (-3 / +4 lines)
Lines 155-161 sub HandleNewVirtualShelf { Link Here
155
}
155
}
156
156
157
sub HandleShelfNumber {
157
sub HandleShelfNumber {
158
    if($authorized= ShelfPossibleAction($loggedinuser, $shelfnumber, 'add')) {
158
    my $shelf = Koha::Virtualshelves->find( $shelfnumber );
159
    if($authorized = $shelf->can_biblios_be_added( $loggedinuser ) ) {
159
    AddBibliosToShelf($shelfnumber, @biblionumber);
160
    AddBibliosToShelf($shelfnumber, @biblionumber);
160
    #Close this page and return
161
    #Close this page and return
161
    print $query->header;
162
    print $query->header;
Lines 167-175 sub HandleShelfNumber { Link Here
167
}
168
}
168
169
169
sub HandleSelectedShelf {
170
sub HandleSelectedShelf {
170
    if($authorized= ShelfPossibleAction( $loggedinuser, $shelfnumber, 'add')){
171
    my $shelf = Koha::Virtualshelves->find( $shelfnumber );
172
    if($authorized = $shelf->can_biblios_be_added( $loggedinuser ) ) {
171
        #confirm adding to specific shelf
173
        #confirm adding to specific shelf
172
        my $shelf = Koha::Virtualshelves->find( $shelfnumber );
173
        $template->param(
174
        $template->param(
174
        singleshelf               => 1,
175
        singleshelf               => 1,
175
        shelfnumber               => $shelf->shelfnumber,
176
        shelfnumber               => $shelf->shelfnumber,
(-)a/virtualshelves/downloadshelf.pl (-27 / +42 lines)
Lines 31-40 use C4::VirtualShelves; Link Here
31
use C4::Record;
31
use C4::Record;
32
use C4::Ris;
32
use C4::Ris;
33
use C4::Csv;
33
use C4::Csv;
34
35
use Koha::Virtualshelves;
36
34
use utf8;
37
use utf8;
35
my $query = new CGI;
38
my $query = new CGI;
36
39
37
my ( $template, $borrowernumber, $cookie ) = get_template_and_user (
40
my ( $template, $loggedinuser, $cookie ) = get_template_and_user (
38
    {
41
    {
39
        template_name   => "virtualshelves/downloadshelf.tt",
42
        template_name   => "virtualshelves/downloadshelf.tt",
40
        query           => $query,
43
        query           => $query,
Lines 47-52 my ( $template, $borrowernumber, $cookie ) = get_template_and_user ( Link Here
47
my $shelfid = $query->param('shelfid');
50
my $shelfid = $query->param('shelfid');
48
my $format  = $query->param('format');
51
my $format  = $query->param('format');
49
my $dbh     = C4::Context->dbh;
52
my $dbh     = C4::Context->dbh;
53
my @messages;
50
54
51
if ($shelfid && $format) {
55
if ($shelfid && $format) {
52
56
Lines 54-94 if ($shelfid && $format) { Link Here
54
    my $marcflavour         = C4::Context->preference('marcflavour');
58
    my $marcflavour         = C4::Context->preference('marcflavour');
55
    my $output='';
59
    my $output='';
56
60
57
    # CSV 
61
    my $shelf = Koha::Virtualshelves->find($shelfid);
58
    if ($format =~ /^\d+$/) {
62
    if ( $shelf ) {
59
	my @biblios;
63
        if ( $shelf->can_be_viewed( $loggedinuser ) ) {
60
	foreach (@$items) {
64
61
	    push @biblios, $_->{biblionumber};
65
            # CSV 
62
	}
66
            if ($format =~ /^\d+$/) {
63
	$output = marc2csv(\@biblios, $format);
67
                my @biblios;
64
    }
68
                foreach (@$items) {
65
    else { #Other formats
69
                    push @biblios, $_->{biblionumber};
66
        foreach my $biblio (@$items) {
70
                }
67
            my $biblionumber = $biblio->{biblionumber};
71
                $output = marc2csv(\@biblios, $format);
68
            my $record = GetMarcBiblio($biblionumber, 1);
69
            if ($format eq 'iso2709') {
70
                $output .= $record->as_usmarc();
71
            }
72
            elsif ($format eq 'ris') {
73
                $output .= marc2ris($record);
74
            }
72
            }
75
            elsif ($format eq 'bibtex') {
73
            else { #Other formats
76
                $output .= marc2bibtex($record, $biblionumber);
74
                foreach my $biblio (@$items) {
75
                    my $biblionumber = $biblio->{biblionumber};
76
                    my $record = GetMarcBiblio($biblionumber, 1);
77
                    if ($format eq 'iso2709') {
78
                        $output .= $record->as_usmarc();
79
                    }
80
                    elsif ($format eq 'ris') {
81
                        $output .= marc2ris($record);
82
                    }
83
                    elsif ($format eq 'bibtex') {
84
                        $output .= marc2bibtex($record, $biblionumber);
85
                    }
86
                }
77
            }
87
            }
88
            print $query->header(
89
            -type => 'application/octet-stream',
90
            -'Content-Transfer-Encoding' => 'binary',
91
            -attachment=>"shelf.$format");
92
            print $output;
93
            exit;
94
        } else {
95
            push @messages, { type => 'error', code => 'unauthorized' };
78
        }
96
        }
97
    } else {
98
        push @messages, { type => 'error', code => 'does_not_exist' };
79
    }
99
    }
80
100
81
    # If it was a CSV export we change the format after the export so the file extension is fine
101
    # If it was a CSV export we change the format after the export so the file extension is fine
82
    $format = "csv" if ($format =~ m/^\d+$/);
102
    $format = "csv" if ($format =~ m/^\d+$/);
83
    
84
    print $query->header(
85
	-type => 'application/octet-stream',
86
	-'Content-Transfer-Encoding' => 'binary',
87
	-attachment=>"shelf.$format");
88
    print $output;
89
}
103
}
90
else {
104
else {
91
    $template->param(csv_profiles => GetCsvProfilesLoop('marc'));
105
    $template->param(csv_profiles => GetCsvProfilesLoop('marc'));
92
    $template->param(shelfid => $shelfid); 
106
    $template->param(shelfid => $shelfid); 
93
    output_html_with_http_headers $query, $cookie, $template->output;
94
}
107
}
108
$template->param( messages => \@messages );
109
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/virtualshelves/shelves.pl (-10 / +249 lines)
Lines 1-7 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
#
3
# Copyright 2015 Koha Team
4
# Copyright 2000-2002 Katipo Communications
5
#
4
#
6
# This file is part of Koha.
5
# This file is part of Koha.
7
#
6
#
Lines 18-39 Link Here
18
# You should have received a copy of the GNU General Public License
17
# You should have received a copy of the GNU General Public License
19
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
20
19
21
use strict;
20
use Modern::Perl;
22
use warnings;
23
use CGI qw ( -utf8 );
21
use CGI qw ( -utf8 );
24
use C4::VirtualShelves::Page;
22
use C4::VirtualShelves;
25
use C4::Auth;
23
use C4::Auth;
24
use C4::Biblio;
25
use C4::Csv;
26
use C4::Koha;
27
use C4::Items;
28
use C4::Members;
29
use C4::Output;
30
use C4::XSLT;
31
use Koha::Virtualshelves;
26
32
27
my $query = new CGI;
33
my $query = new CGI;
28
34
29
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
35
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
30
    {
36
    {   template_name   => "virtualshelves/shelves.tt",
31
        template_name   => "virtualshelves/shelves.tt",
32
        query           => $query,
37
        query           => $query,
33
        type            => "intranet",
38
        type            => "intranet",
34
        authnotrequired => 0,
39
        authnotrequired => 0,
35
        flagsrequired   => { catalogue => 1 },
40
        flagsrequired   => { catalogue => 1 },
36
    }
41
    }
37
);
42
);
38
$template->param( print => $query->param('print') );
43
39
shelfpage('intranet', $query, $template, $loggedinuser, $cookie);
44
my $op       = $query->param('op')       || 'list';
45
my $referer  = $query->param('referer')  || $op;
46
my $category = $query->param('category') || 1;
47
my ( $shelf, $shelfnumber, @messages );
48
49
if ( $op eq 'add_form' ) {
50
    # Nothing to do
51
} elsif ( $op eq 'edit_form' ) {
52
    $shelfnumber = $query->param('shelfnumber');
53
    $shelf       = Koha::Virtualshelves->find($shelfnumber);
54
55
    if ( $shelf ) {
56
        $category = $shelf->category;
57
        my $patron = GetMember( 'borrowernumber' => $shelf->owner );
58
        $template->param( owner => $patron, );
59
        unless ( $shelf->can_be_managed( $loggedinuser ) ) {
60
            push @messages, { type => 'error', code => 'unauthorized_on_update' };
61
            $op = 'list';
62
        }
63
    } else {
64
        push @messages, { type => 'error', code => 'does_not_exist' };
65
    }
66
} elsif ( $op eq 'add' ) {
67
    eval {
68
        $shelf = Koha::Virtualshelf->new(
69
            {   shelfname          => $query->param('shelfname'),
70
                sortfield          => $query->param('sortfield'),
71
                category           => $query->param('category'),
72
                allow_add          => $query->param('allow_add'),
73
                allow_delete_own   => $query->param('allow_delete_own'),
74
                allow_delete_other => $query->param('allow_delete_other'),
75
                owner              => $query->param('owner'),
76
            }
77
        );
78
        $shelf->store;
79
        $shelfnumber = $shelf->shelfnumber;
80
    };
81
    if ($@) {
82
        push @messages, { type => 'error', code => ref($@), msg => $@ };
83
    } elsif ( not $shelf ) {
84
        push @messages, { type => 'error', code => 'error_on_insert' };
85
    } else {
86
        push @messages, { type => 'message', code => 'success_on_insert' };
87
        $op = 'view';
88
    }
89
} elsif ( $op eq 'edit' ) {
90
    $shelfnumber = $query->param('shelfnumber');
91
    $shelf       = Koha::Virtualshelves->find($shelfnumber);
92
93
    if ( $shelf ) {
94
        $op = $referer;
95
        if ( $shelf->can_be_managed( $loggedinuser ) ) {
96
            $shelf->shelfname( $query->param('shelfname') );
97
            $shelf->sortfield( $query->param('sortfield') );
98
            $shelf->allow_add( $query->param('allow_add') );
99
            $shelf->allow_delete_own( $query->param('allow_delete_own') );
100
            $shelf->allow_delete_other( $query->param('allow_delete_other') );
101
            $shelf->category( $query->param('category') );
102
            eval { $shelf->store };
103
104
            if ($@) {
105
                push @messages, { type => 'error', code => 'error_on_update' };
106
                $op = 'edit_form';
107
            } else {
108
                push @messages, { type => 'message', code => 'success_on_update' };
109
            }
110
        } else {
111
            push @messages, { type => 'error', code => 'unauthorized_on_update' };
112
        }
113
    } else {
114
        push @messages, { type => 'error', code => 'does_not_exist' };
115
    }
116
} elsif ( $op eq 'delete' ) {
117
    $shelfnumber = $query->param('shelfnumber');
118
    $shelf       = Koha::Virtualshelves->find($shelfnumber);
119
    if ($shelf) {
120
        if ( $shelf->can_be_deleted( $loggedinuser ) ) {
121
            eval { $shelf->delete; };
122
            if ($@) {
123
                push @messages, { type => 'error', code => ref($@), msg => $@ };
124
            } else {
125
                push @messages, { type => 'message', code => 'success_on_delete' };
126
            }
127
        } else {
128
            push @messages, { type => 'error', code => 'unauthorized_on_delete' };
129
        }
130
    } else {
131
        push @messages, { type => 'error', code => 'does_not_exist' };
132
    }
133
    $op = 'list';
134
} elsif ( $op eq 'add_biblio' ) {
135
    $shelfnumber = $query->param('shelfnumber');
136
    $shelf = Koha::Virtualshelves->find($shelfnumber);
137
    if ($shelf) {
138
        if( my $barcode = $query->param('barcode') ) {
139
            my $item = GetItem( 0, $barcode);
140
            if (defined $item && $item->{itemnumber}) {
141
                my $biblio = GetBiblioFromItemNumber( $item->{itemnumber} );
142
                if ( $shelf->can_biblios_be_added( $loggedinuser ) ) {
143
                    my $added = eval { $shelf->add_biblio( $biblio->{biblionumber}, $loggedinuser ); };
144
                    if ($@) {
145
                        push @messages, { type => 'error', code => ref($@), msg => $@ };
146
                    } elsif ( $added ) {
147
                        push @messages, { type => 'message', code => 'success_on_add_biblio' };
148
                    } else {
149
                        push @messages, { type => 'message', code => 'error_on_add_biblio' };
150
                    }
151
                } else {
152
                    push @messages, { type => 'error', code => 'unauthorized_on_add_biblio' };
153
                }
154
            } else {
155
                push @messages, { type => 'error', code => 'item_does_not_exist' };
156
            }
157
        }
158
    } else {
159
        push @messages, { type => 'error', code => 'does_not_exist' };
160
    }
161
    $op = $referer;
162
} elsif ( $op eq 'remove_biblios' ) {
163
    $shelfnumber = $query->param('shelfnumber');
164
    $shelf = Koha::Virtualshelves->find($shelfnumber);
165
    my @biblionumbers = $query->param('biblionumber');
166
    if ($shelf) {
167
        if ( $shelf->can_biblios_be_removed( $loggedinuser ) ) {
168
            my $number_of_biblios_removed = eval {
169
                $shelf->remove_biblios(
170
                    {
171
                        biblionumbers => \@biblionumbers,
172
                        borrowernumber => $loggedinuser,
173
                    }
174
                );
175
            };
176
            if ($@) {
177
                push @messages, { type => 'error', code => ref($@), msg => $@ };
178
            } elsif ( $number_of_biblios_removed ) {
179
                push @messages, { type => 'message', code => 'success_on_remove_biblios' };
180
            } else {
181
                push @messages, { type => 'error', code => 'no_biblio_removed' };
182
            }
183
        } else {
184
            push @messages, { type => 'error', code => 'unauthorized_on_remove_biblios' };
185
        }
186
    } else {
187
        push @messages, { type => 'error', code => 'does_not_exist' };
188
    }
189
    $op = $referer;
190
}
191
192
if ( $op eq 'view' ) {
193
    $shelfnumber ||= $query->param('shelfnumber');
194
    $shelf = Koha::Virtualshelves->find($shelfnumber);
195
    if ( $shelf ) {
196
        if ( $shelf->can_be_viewed( $loggedinuser ) ) {
197
            my $sortfield = $query->param('sortfield') || $shelf->sortfield;    # Passed in sorting overrides default sorting
198
            my $direction = $query->param('direction') || 'asc';
199
            my ( $shelflimit, $shelfoffset, $itemoff );
200
            unless ( $query->param('print') ) {
201
                $shelflimit = C4::Context->preference('numSearchResults') || 20;
202
                $itemoff = ( $query->param('itemoff') ? $query->param('itemoff') : 1 );
203
                $shelfoffset = ( $itemoff - 1 ) * $shelflimit;    # Sets the offset to begin retrieving items at
204
            }
205
            my ( $items, $totitems ) = GetShelfContents( $shelfnumber, $shelflimit, $shelfoffset, $sortfield, $direction );
206
207
            my $borrower = GetMember( borrowernumber => $loggedinuser );
208
209
            for my $this_item (@$items) {
210
                my $biblionumber = $this_item->{biblionumber};
211
                my $record       = GetMarcBiblio($biblionumber);
212
213
                if ( C4::Context->preference("XSLTResultsDisplay") ) {
214
                    $this_item->{XSLTBloc} = XSLTParse4Display( $biblionumber, $record, "XSLTResultsDisplay" );
215
                }
216
217
                my $marcflavour = C4::Context->preference("marcflavour");
218
                $this_item->{'imageurl'}        = getitemtypeinfo( $this_item->{'itemtype'}, 'intranet' )->{'imageurl'};
219
                $this_item->{'coins'}           = GetCOinSBiblio($record);
220
                $this_item->{'subtitle'}        = GetRecordValue( 'subtitle', $record, GetFrameworkCode( $this_item->{'biblionumber'} ) );
221
                $this_item->{'normalized_upc'}  = GetNormalizedUPC( $record, $marcflavour );
222
                $this_item->{'normalized_ean'}  = GetNormalizedEAN( $record, $marcflavour );
223
                $this_item->{'normalized_oclc'} = GetNormalizedOCLCNumber( $record, $marcflavour );
224
                $this_item->{'normalized_isbn'} = GetNormalizedISBN( undef, $record, $marcflavour );
225
226
                unless ( defined $this_item->{size} ) {
227
228
                    #TT has problems with size
229
                    $this_item->{size} = q||;
230
                }
231
232
                # Getting items infos for location display
233
                my @items_infos = &GetItemsLocationInfo( $this_item->{'biblionumber'} );
234
                $this_item->{'ITEM_RESULTS'} = \@items_infos;
235
            }
236
237
            # Build drop-down list for 'Add To:' menu...
238
            my ( $totalref, $pubshelves, $barshelves ) = C4::VirtualShelves::GetSomeShelfNames( $loggedinuser, 'COMBO', 1 );
239
            $template->param(
240
                addbarshelves      => $totalref->{bartotal},
241
                addbarshelvesloop  => $barshelves,
242
                addpubshelves      => $totalref->{pubtotal},
243
                addpubshelvesloop  => $pubshelves,
244
                can_manage_shelf   => $shelf->can_be_managed($loggedinuser),
245
                can_remove_shelf   => $shelf->can_be_deleted($loggedinuser),
246
                can_remove_biblios => $shelf->can_biblios_be_removed($loggedinuser),
247
                can_add_biblios    => $shelf->can_biblios_be_added($loggedinuser),
248
                sortfield          => $sortfield,
249
                itemsloop          => $items,
250
                sortfield          => $sortfield,
251
                direction          => $direction,
252
            );
253
            if ($shelflimit) {
254
                $template->param(
255
                    pagination_bar => pagination_bar(
256
                        q||, ( int( $totitems / $shelflimit ) ) + ( ( $totitems % $shelflimit ) > 0 ? 1 : 0 ),
257
                        $itemoff, "itemoff", { op => 'view', shelfnumber => $shelf->shelfnumber, sortfield => $sortfield, direction => $direction, }
258
                    ),
259
                );
260
            }
261
        } else {
262
            push @messages, { type => 'error', code => 'unauthorized_on_view' };
263
        }
264
    } else {
265
        push @messages, { type => 'error', code => 'does_not_exist' };
266
    }
267
}
268
269
$template->param(
270
    op       => $op,
271
    referer  => $referer,
272
    shelf    => $shelf,
273
    messages => \@messages,
274
    category => $category,
275
    print    => $query->param('print') || 0,
276
    csv_profiles => GetCsvProfilesLoop('marc'),
277
);
278
279
output_html_with_http_headers $query, $cookie, $template->output;
40
- 

Return to bug 14544