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
11 # under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 3 of the License, or
13 # (at your option) any later version.
15 # Koha is distributed in the hope that it will be useful, but
16 # WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with Koha; if not, see <http://www.gnu.org/licenses>.
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
69 use Koha
::Virtualshelves
;
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.tt",
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->multi_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 HandleNewVirtualShelf
{
128 Koha
::Virtualshelf
->new(
130 shelfname
=> $newvirtualshelf,
131 category
=> $category,
132 sortfield
=> $sortfield,
133 owner
=> $loggedinuser,
137 if ( $@
or not $shelf ) {
143 for my $bib (@biblionumber){
144 $shelf->add_biblio( $bib, $loggedinuser );
146 #Reload the page where you came from
147 print $query->header;
148 print "<html><meta http-equiv=\"refresh\" content=\"0\" /><body onload=\"window.opener.location.reload(true);self.close();\"></body></html>";
151 sub HandleShelfNumber
{
152 my $shelf = Koha
::Virtualshelves
->find( $shelfnumber );
153 if($authorized = $shelf->can_biblios_be_added( $loggedinuser ) ) {
154 for my $bib (@biblionumber){
155 $shelf->add_biblio( $bib, $loggedinuser );
157 #Close this page and return
158 print $query->header;
159 print "<html><meta http-equiv=\"refresh\" content=\"0\" /><body onload=\"self.close();\"></body></html>";
166 sub HandleSelectedShelf
{
167 my $shelf = Koha
::Virtualshelves
->find( $shelfnumber );
168 if($authorized = $shelf->can_biblios_be_added( $loggedinuser ) ) {
169 #confirm adding to specific shelf
172 shelfnumber
=> $shelf->shelfnumber,
173 shelfname
=> $shelf->shelfname,
182 my $private_shelves = Koha
::Virtualshelves
->search(
185 owner
=> $loggedinuser,
187 { order_by
=> 'shelfname' }
189 my $shelves_shared_with_me = Koha
::Virtualshelves
->search(
192 'virtualshelfshares.borrowernumber' => $loggedinuser,
195 owner
=> $loggedinuser,
199 join => 'virtualshelfshares',
202 my $public_shelves= Koha
::Virtualshelves
->search(
207 owner
=> $loggedinuser,
210 { order_by
=> 'shelfname' }
213 private_shelves
=> $private_shelves,
214 private_shelves_shared_with_me
=> $shelves_shared_with_me,
215 public_shelves
=> $public_shelves,
221 for my $bib (@biblionumber) {
222 my $data = GetBiblioData
($bib);
224 { biblionumber
=> $bib,
225 title
=> $data->{'title'},
226 author
=> $data->{'author'},
230 multiple
=> (scalar(@biblios) > 1),
231 total
=> scalar @biblios,
232 biblios
=> \
@biblios,
238 newshelf
=> $newshelf||0,
239 authorized
=> $authorized,
242 output_html_with_http_headers
$query, $cookie, $template->output;