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 my @biblionumber = HandleBiblioPars
();
73 my $shelfnumber = $query->param('shelfnumber');
74 my $newvirtualshelf = $query->param('newvirtualshelf');
75 my $newshelf = $query->param('newshelf');
76 my $category = $query->param('category');
77 my $sortfield = $query->param('sortfield');
78 my $confirmed = $query->param('confirmed') || 0;
82 my ( $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, $singlecategory)= GetShelf
($shelfnumber);
167 shelfnumber
=> $singleshelf,
168 shelfname
=> $singleshelfname,
169 "category$singlecategory" => 1
178 my $privateshelves = GetAllShelves
(1,$loggedinuser,1);
179 my $publicshelves = GetAllShelves
(2,$loggedinuser,1);
181 privatevirtualshelves
=> $privateshelves,
182 publicvirtualshelves
=> $publicshelves,
188 for my $bib (@biblionumber) {
189 my $data = GetBiblioData
($bib);
191 { biblionumber
=> $bib,
192 title
=> $data->{'title'},
193 author
=> $data->{'author'},
197 multiple
=> (scalar(@biblios) > 1),
198 total
=> scalar @biblios,
199 biblios
=> \
@biblios,
205 newshelf
=> $newshelf||0,
206 authorized
=> $authorized,
209 output_html_with_http_headers
$query, $cookie, $template->output;