3 #script to provide virtual shelf management
6 # Copyright 2000-2002 Katipo Communications
8 # This file is part of Koha.
10 # Koha is free software; you can redistribute it and/or modify it under the
11 # terms of the GNU General Public License as published by the Free Software
12 # Foundation; either version 2 of the License, or (at your option) any later
15 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
16 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License along
20 # with Koha; if not, write to the Free Software Foundation, Inc.,
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 This script allow to add a virtual in a virtual shelf from a biblionumber.
42 the shelfnumber where to add the virtual.
46 if this parameter exists, then it must be equals to the name of the shelf
51 if this script has to add a shelf, it add one with this category.
55 if this parameter exists, then we create a new shelf
67 use C4
::VirtualShelves qw
/:DEFAULT GetAllShelves/;
72 our @biblionumber = HandleBiblioPars
();
73 our $shelfnumber = $query->param('shelfnumber');
74 our $newvirtualshelf = $query->param('newvirtualshelf');
75 our $newshelf = $query->param('newshelf');
76 our $category = $query->param('category');
77 our $sortfield = $query->param('sortfield');
78 my $confirmed = $query->param('confirmed') || 0;
82 our ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
84 template_name
=> "virtualshelves/addbybiblionumber.tmpl",
88 flagsrequired
=> { catalogue
=> 1 },
92 if( $newvirtualshelf) {
93 HandleNewVirtualShelf
();
95 ShowTemplate
(); #error message
97 elsif($shelfnumber && $confirmed) {
100 ShowTemplate
(); #error message
102 elsif($shelfnumber) { #still needs confirmation
103 HandleSelectedShelf
();
104 LoadBib
() if $authorized;
114 sub HandleBiblioPars
{
115 my @bib= $query->param('biblionumber');
116 if(@bib==0 && $query->param('biblionumbers')) {
117 my $str= $query->param('biblionumbers');
118 @bib= split '/', $str;
120 elsif(@bib==1 && $bib[0]=~/\//) {
121 @bib= split '/', $bib[0];
126 sub AddBibliosToShelf
{
127 my ($shelfnumber, @biblionumber)=@_;
128 for my $bib (@biblionumber){
129 AddToShelf
($bib, $shelfnumber, $loggedinuser);
133 sub HandleNewVirtualShelf
{
134 $shelfnumber = AddShelf
( {
135 shelfname
=> $newvirtualshelf,
136 sortfield
=> $sortfield,
137 category
=> $category }, $loggedinuser);
138 if($shelfnumber == -1) {
140 $errcode=1; #add failed
143 AddBibliosToShelf
($shelfnumber, @biblionumber);
144 #Reload the page where you came from
145 print $query->header;
146 print "<html><meta http-equiv=\"refresh\" content=\"0\" /><body onload=\"window.opener.location.reload(true);self.close();\"></body></html>";
149 sub HandleShelfNumber
{
150 if($authorized= ShelfPossibleAction
($loggedinuser, $shelfnumber, 'add')) {
151 AddBibliosToShelf
($shelfnumber, @biblionumber);
152 #Close this page and return
153 print $query->header;
154 print "<html><meta http-equiv=\"refresh\" content=\"0\" /><body onload=\"self.close();\"></body></html>";
161 sub HandleSelectedShelf
{
162 if($authorized= ShelfPossibleAction
( $loggedinuser, $shelfnumber, 'add')){
163 #confirm adding to specific shelf
164 my ($singleshelf, $singleshelfname)= GetShelf
($shelfnumber);
167 shelfnumber
=> $singleshelf,
168 shelfname
=> $singleshelfname,
177 my $privateshelves = GetAllShelves
(1,$loggedinuser,1);
178 my $publicshelves = GetAllShelves
(2,$loggedinuser,1);
180 privatevirtualshelves
=> $privateshelves,
181 publicvirtualshelves
=> $publicshelves,
187 for my $bib (@biblionumber) {
188 my $data = GetBiblioData
($bib);
190 { biblionumber
=> $bib,
191 title
=> $data->{'title'},
192 author
=> $data->{'author'},
196 multiple
=> (scalar(@biblios) > 1),
197 total
=> scalar @biblios,
198 biblios
=> \
@biblios,
204 newshelf
=> $newshelf||0,
205 authorized
=> $authorized,
208 output_html_with_http_headers
$query, $cookie, $template->output;