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
22 # with Koha; if not, write to the Free Software Foundation, Inc.,
23 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 use C4
::VirtualShelves qw
/:DEFAULT GetRecentShelves RefreshShelvesSummary/;
33 use C4
::Auth qw
/get_session/;
36 #splits incoming biblionumber(s) to array and adds each to shelf.
37 sub AddBibliosToShelf
{
38 my ($shelfnumber,@biblionumber)=@_;
40 # multiple bibs might come in as '/' delimited string (from where, i don't see), or as array.
41 if (scalar(@biblionumber) == 1) {
42 @biblionumber = (split /\//,$biblionumber[0]);
44 for my $bib (@biblionumber){
45 AddToShelf
($bib, $shelfnumber);
50 my @biblionumber = $query->param('biblionumber');
51 my $selectedshelf = $query->param('selectedshelf');
52 my $newshelf = $query->param('newshelf');
53 my $shelfnumber = $query->param('shelfnumber');
54 my $newvirtualshelf = $query->param('newvirtualshelf');
55 my $category = $query->param('category');
57 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
59 template_name
=> "opac-addbybiblionumber.tmpl",
66 if ($newvirtualshelf) {
67 $shelfnumber = AddShelf
( $newvirtualshelf, $loggedinuser, $category );
68 AddBibliosToShelf
($shelfnumber, @biblionumber);
69 RefreshShelvesSummary
($query->cookie("CGISESSID"),$loggedinuser,($loggedinuser == -1 ?
20 : 10));
71 print "<html><meta http-equiv=\"refresh\" content=\"0;url=opac-shelves.pl?display=privateshelves\" /><body onload=\"window.opener.location.reload(true);self.close();\"></body></html>";
75 # verify user is authorized to perform the action on the shelf...
78 $authorized = 0 unless ShelfPossibleAction
( $loggedinuser, $selectedshelf );
81 if ($shelfnumber && ($shelfnumber != -1)) {
82 AddBibliosToShelf
($shelfnumber,@biblionumber);
83 RefreshShelvesSummary
($query->cookie("CGISESSID"),$loggedinuser,($loggedinuser == -1 ?
20 : 10));
85 print "<html><meta http-equiv=\"refresh\" content=\"0;url=opac-shelves.pl?display=privateshelves\" /><body onload=\"self.close();\"></body></html>";
90 # adding to specific shelf
91 my ( $singleshelf, $singleshelfname, $singlecategory ) = GetShelf
( $query->param('selectedshelf') );
94 shelfnumber
=> $singleshelf,
95 shelfname
=> $singleshelfname,
96 "category$singlecategory" => 1
99 # offer choice of shelves
103 #grab each type of shelf, open (type 3) should not be limited by user.
104 foreach my $shelftype (1,2,3) {
105 my ($shelflist) = GetRecentShelves
($shelftype, $limit, $shelftype == 3 ?
undef : $loggedinuser);
106 for my $shelf (@
{ $shelflist->[0] }) {
107 push(@shelvesloop, $shelf->{shelfnumber
});
108 $shelvesloop{$shelf->{shelfnumber
}} = $shelf->{shelfname
};
111 my $CGIvirtualshelves;
112 if ( @shelvesloop > 0 ) {
113 $CGIvirtualshelves = CGI
::scrolling_list
(
114 -name
=> 'shelfnumber',
115 -id
=> 'shelfnumber',
116 -values => \
@shelvesloop,
117 -labels
=> \
%shelvesloop,
124 CGIvirtualshelves
=> $CGIvirtualshelves,
130 for my $bib (@biblionumber) {
131 my $data = GetBiblioData
( $bib );
133 { biblionumber
=> $bib,
134 title
=> $data->{'title'},
135 author
=> $data->{'author'},
139 newshelf
=> $newshelf,
140 multiple
=> (scalar(@biblios) > 1),
141 total
=> scalar @biblios,
142 biblios
=> \
@biblios,
143 authorized
=> $authorized,
146 output_html_with_http_headers
$query, $cookie, $template->output;