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><meta http-equiv=\"refresh\" content=\"0;url=opac-shelves.pl?display=privateshelves\" /><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><meta http-equiv=\"refresh\" content=\"0;url=opac-shelves.pl?display=privateshelves\" /><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
101 #grab each type of shelf, open (type 3) should not be limited by user.
102 foreach my $shelftype (1,2,3) {
103 my ($shelflist) = GetRecentShelves
($shelftype, $limit, $shelftype == 3 ?
undef : $loggedinuser);
104 for my $shelf (@
{ $shelflist->[0] }) {
105 push(@shelvesloop, $shelf->{shelfnumber
});
106 $shelvesloop{$shelf->{shelfnumber
}} = $shelf->{shelfname
};
109 my $CGIvirtualshelves;
110 if ( @shelvesloop > 0 ) {
111 $CGIvirtualshelves = CGI
::scrolling_list
(
112 -name
=> 'shelfnumber',
113 -id
=> 'shelfnumber',
114 -values => \
@shelvesloop,
115 -labels
=> \
%shelvesloop,
122 CGIvirtualshelves
=> $CGIvirtualshelves,
128 for my $bib (@biblionumber) {
129 my $data = GetBiblioData
( $bib );
131 { biblionumber
=> $bib,
132 title
=> $data->{'title'},
133 author
=> $data->{'author'},
137 newshelf
=> $newshelf,
138 multiple
=> (scalar(@biblios) > 1),
139 total
=> scalar @biblios,
140 biblios
=> \
@biblios,
141 authorized
=> $authorized,
144 output_html_with_http_headers
$query, $cookie, $template->output;