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 GetAllShelves 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",
62 authnotrequired
=>( C4
::Context
->preference("OpacPublic") ?
1 : 0 ),
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
100 my $privateshelves = GetAllShelves
(1,$loggedinuser);
101 if(@
{$privateshelves}){
103 privatevirtualshelves
=> $privateshelves,
107 my $publicshelves = GetAllShelves
(2,$loggedinuser);
108 if(@
{$publicshelves}){
110 publicvirtualshelves
=> $publicshelves,
117 for my $bib (@biblionumber) {
118 my $data = GetBiblioData
( $bib );
120 { biblionumber
=> $bib,
121 title
=> $data->{'title'},
122 author
=> $data->{'author'},
126 newshelf
=> $newshelf,
127 multiple
=> (scalar(@biblios) > 1),
128 total
=> scalar @biblios,
129 biblios
=> \
@biblios,
130 authorized
=> $authorized,
133 output_html_with_http_headers
$query, $cookie, $template->output;