fixing permissions on scripts
[koha.git] / virtualshelves / addbybiblionumber.pl
1 #!/usr/bin/perl
2
3 #script to provide virtual shelf management
4 #
5 #
6 # Copyright 2000-2002 Katipo Communications
7 #
8 # This file is part of Koha.
9 #
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
13 # version.
14 #
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.
18 #
19 # You should have received a copy of the GNU General Public License along with
20 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
21 # Suite 330, Boston, MA  02111-1307 USA
22
23 # $Id$
24
25 =head1 NAME
26
27     addbybiblionumber.pl
28
29 =head1 DESCRIPTION
30
31     This script allow to add a virtual in a virtual shelf from a biblionumber.
32
33 =head1 CGI PARAMETERS
34
35 =over 4
36
37 =item biblionumber
38
39     The biblionumber
40
41 =item shelfnumber
42
43     the shelfnumber where to add the virtual.
44
45 =item newvirtualshelf
46
47     if this parameter exists, then it must be equals to the name of the shelf
48     to add.
49
50 =item category
51
52     if this script has to add a shelf, it add one with this category.
53
54 =back
55
56 =cut
57
58 use strict;
59 use C4::Biblio;
60 use CGI;
61 use C4::Output;
62 use C4::VirtualShelves;
63 use C4::Circulation;
64 use C4::Auth;
65
66 #use it only to debug !
67 use CGI::Carp qw/fatalsToBrowser/;
68 use warnings;
69
70 my $query           = new CGI;
71 my $biblionumber    = $query->param('biblionumber');
72 my $shelfnumber     = $query->param('shelfnumber');
73 my $newvirtualshelf = $query->param('newvirtualshelf');
74 my $category        = $query->param('category');
75
76 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
77     {
78         template_name   => "virtualshelves/addbybiblionumber.tmpl",
79         query           => $query,
80         type            => "intranet",
81         authnotrequired => 0,
82         flagsrequired   => { catalogue => 1 },
83     }
84 );
85
86 $shelfnumber = AddShelf( $newvirtualshelf, $loggedinuser, $category )
87   if $newvirtualshelf;
88 if ( $shelfnumber || ( $shelfnumber == -1 ) ) {    # the shelf already exist.
89     &AddToShelfFromBiblio( $biblionumber, $shelfnumber );
90     print
91 "Content-Type: text/html\n\n<html><body onload=\"window.close()\"></body></html>";
92     exit;
93 }
94 else {    # this shelf doesn't already exist.
95     my ( $bibliocount, @biblios ) = GetBiblio($biblionumber);
96
97     my ($shelflist) = GetShelves( $loggedinuser, 3 );
98     my @shelvesloop;
99     my %shelvesloop;
100     foreach my $element ( sort keys %$shelflist ) {
101         push( @shelvesloop, $element );
102         $shelvesloop{$element} = $shelflist->{$element}->{'shelfname'};
103     }
104
105     my $CGIvirtualshelves = CGI::scrolling_list(
106         -name     => 'shelfnumber',
107         -values   => \@shelvesloop,
108         -labels   => \%shelvesloop,
109         -size     => 1,
110         -tabindex => '',
111         -multiple => 0
112     );
113
114     $template->param(
115         biblionumber      => $biblionumber,
116         title             => $biblios[0]->{'title'},
117         author            => $biblios[0]->{'author'},
118         CGIvirtualshelves => $CGIvirtualshelves,
119         intranetcolorstylesheet =>
120           C4::Context->preference("intranetcolorstylesheet"),
121         intranetstylesheet => C4::Context->preference("intranetstylesheet"),
122         IntranetNav        => C4::Context->preference("IntranetNav"),
123     );
124
125     output_html_with_http_headers $query, $cookie, $template->output;
126 }
127
128 # $Log$
129 # Revision 1.8  2007/04/24 13:54:29  hdl
130 # functions that were in C4::Interface::CGI::Output are now in C4::Output.
131 # So this implies quite a change for files.
132 # Sorry about conflicts which will be caused.
133 # directory Interface::CGI should now be dropped.
134 # I noticed that many scripts (reports ones, but also some circ/stats.pl or opac-topissues) still use Date::Manip.
135 #
136 # Revision 1.7  2007/04/04 16:46:22  tipaul
137 # HUGE COMMIT : code cleaning circulation.
138 #
139 # some stuff to do, i'll write a mail on koha-devel NOW !
140 #
141 # Revision 1.6  2007/03/09 14:32:26  tipaul
142 # rel_3_0 moved to HEAD
143 #
144 # Revision 1.4.2.6  2006/12/18 16:35:17  toins
145 # removing use HTML::Template from *.pl.
146 #
147 # Revision 1.4.2.5  2006/12/05 11:35:29  toins
148 # Biblio.pm cleaned.
149 # additionalauthors, bibliosubject, bibliosubtitle tables are now unused.
150 # Some functions renamed according to the coding guidelines.
151 #
152 # Revision 1.4.2.4  2006/11/30 18:23:51  toins
153 # theses scripts don't need to use C4::Search.
154 #
155 # Revision 1.4.2.3  2006/10/30 09:48:19  tipaul
156 # samll bugfix to create a virtualshelf correctly
157 #
158 # Revision 1.4.2.2  2006/08/30 16:13:54  toins
159 # correct an error in the "if condition".
160 #
161 # Revision 1.4.2.1  2006/08/30 15:59:14  toins
162 # Code cleaned according to coding guide lines.
163 #
164 # Revision 1.4  2006/07/04 14:36:51  toins
165 # Head & rel_2_2 merged
166 #
167 # Revision 1.3.2.4  2006/06/20 16:21:42  oleonard
168 # Adding "tabindex=''" to CGI:scrolling_lists to prevent incorrect tabbing. See Bug 1098
169 #
170 # Revision 1.3.2.3  2006/02/05 21:59:21  kados
171 # Adds script support for IntranetNav ... see mail to koha-devel for
172 # details
173 #
174 # Revision 1.3.2.2  2006/02/05 21:45:25  kados
175 # Adds support for intranetstylesheet system pref in Koha scripts
176 #
177
178 # Local Variables:
179 # tab-width: 4
180 # End: