3 #script to provide virtualshelf management
4 # WARNING: This file uses 4-character tabs!
8 # Copyright 2000-2002 Katipo Communications
10 # This file is part of Koha.
12 # Koha is free software; you can redistribute it and/or modify it under the
13 # terms of the GNU General Public License as published by the Free Software
14 # Foundation; either version 2 of the License, or (at your option) any later
17 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
18 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
19 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License along with
22 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
23 # Suite 330, Boston, MA 02111-1307 USA
28 use C4::VirtualShelves qw/:DEFAULT GetRecentShelves RefreshShelvesSummary/;
31 use C4::Auth qw/get_session/;
34 #splits incoming biblionumber(s) to array and adds each to shelf.
35 sub AddBibliosToShelf {
36 my ($shelfnumber,@biblionumber)=@_;
38 # multiple bibs might come in as '/' delimited string (from where, i don't see), or as array.
39 if (scalar(@biblionumber) == 1) {
40 @biblionumber = (split /\//,$biblionumber[0]);
42 for my $bib (@biblionumber){
43 AddToShelfFromBiblio($bib, $shelfnumber);
48 my @biblionumber = $query->param('biblionumber');
49 my $selectedshelf = $query->param('selectedshelf');
50 my $newshelf = $query->param('newshelf');
51 my $shelfnumber = $query->param('shelfnumber');
52 my $newvirtualshelf = $query->param('newvirtualshelf');
53 my $category = $query->param('category');
55 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
57 template_name => "opac-addbybiblionumber.tmpl",
64 if ($newvirtualshelf) {
65 $shelfnumber = AddShelf( $newvirtualshelf, $loggedinuser, $category );
66 AddBibliosToShelf($shelfnumber, @biblionumber);
67 RefreshShelvesSummary($query->cookie("CGISESSID"),$loggedinuser,($loggedinuser == -1 ? 20 : 10));
69 print "<html><body onload=\"window.opener.location.reload(true);self.close();\"></body></html>";
73 # verify user is authorized to perform the action on the shelf...
76 $authorized = 0 unless ShelfPossibleAction( $loggedinuser, $selectedshelf );
79 if ($shelfnumber && ($shelfnumber != -1)) {
80 AddBibliosToShelf($shelfnumber,@biblionumber);
81 RefreshShelvesSummary($query->cookie("CGISESSID"),$loggedinuser,($loggedinuser == -1 ? 20 : 10));
83 print "<html><body onload=\"window.opener.location.reload(true);self.close();\"></body></html>";
88 # adding to specific shelf
89 my ( $singleshelf, $singleshelfname, $singlecategory ) = GetShelf( $query->param('selectedshelf') );
92 shelfnumber => $singleshelf,
93 shelfname => $singleshelfname,
94 "category$singlecategory" => 1
97 # offer choice of shelves
98 # first private shelves...
100 my ($shelflist) = GetRecentShelves(1, $limit, $loggedinuser);
103 for my $shelf ( @{ $shelflist->[0] } ) {
104 push( @shelvesloop, $shelf->{shelfnumber} );
105 $shelvesloop{$shelf->{shelfnumber}} = $shelf->{shelfname};
107 # then open shelves...
108 my ($shelflist) = GetRecentShelves(3, $limit, undef);
109 for my $shelf ( @{ $shelflist->[0] } ) {
110 push( @shelvesloop, $shelf->{shelfnumber} );
111 $shelvesloop{$shelf->{shelfnumber}} = $shelf->{shelfname};
113 my $CGIvirtualshelves;
114 if ( @shelvesloop > 0 ) {
115 $CGIvirtualshelves = CGI::scrolling_list (
116 -name => 'shelfnumber',
117 -id => 'shelfnumber',
118 -values => \@shelvesloop,
119 -labels => \%shelvesloop,
126 CGIvirtualshelves => $CGIvirtualshelves,
132 for my $bib (@biblionumber) {
133 my $data = GetBiblioData( $bib );
135 { biblionumber => $bib,
136 title => $data->{'title'},
137 author => $data->{'author'},
141 newshelf => $newshelf,
142 multiple => (scalar(@biblios) > 1),
143 total => scalar @biblios,
144 biblios => \@biblios,
145 authorized => $authorized,
148 output_html_with_http_headers $query, $cookie, $template->output;