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
13 # under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 3 of the License, or
15 # (at your option) any later version.
17 # Koha is distributed in the hope that it will be useful, but
18 # WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with Koha; if not, see <http://www.gnu.org/licenses>.
30 use C4
::VirtualShelves qw
/:DEFAULT GetAllShelves/;
35 our @biblionumber = $query->param('biblionumber');
36 our $selectedshelf = $query->param('selectedshelf');
37 our $newshelf = $query->param('newshelf');
38 our $shelfnumber = $query->param('shelfnumber');
39 our $newvirtualshelf = $query->param('newvirtualshelf');
40 our $category = $query->param('category');
45 our ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
47 template_name
=> "opac-addbybiblionumber.tt",
54 if( $newvirtualshelf) {
55 HandleNewVirtualShelf
();
57 ShowTemplate
(); #error message
62 ShowTemplate
(); #error message
64 elsif($selectedshelf) {
65 HandleSelectedShelf
();
66 LoadBib
() if $authorized;
71 LoadBib
() if $authorized;
76 sub AddBibliosToShelf
{
77 #splits incoming biblionumber(s) to array and adds each to shelf.
78 my ($shelfnumber,@biblionumber)=@_;
80 #multiple bibs might come in as '/' delimited string (from where, i don't see), or as array.
81 if (scalar(@biblionumber) == 1) {
82 @biblionumber = (split /\//,$biblionumber[0]);
84 for my $bib (@biblionumber) {
85 AddToShelf
($bib, $shelfnumber, $loggedinuser);
89 sub HandleNewVirtualShelf
{
90 if($authorized= ShelfPossibleAction
($loggedinuser, undef, $category==1?
'new_private': 'new_public')) {
91 $shelfnumber = AddShelf
( {
92 shelfname
=> $newvirtualshelf,
93 category
=> $category }, $loggedinuser);
94 if($shelfnumber == -1) {
99 AddBibliosToShelf
($shelfnumber, @biblionumber);
100 #Reload the page where you came from
101 print $query->header;
102 print "<html><meta http-equiv=\"refresh\" content=\"0\" /><body onload=\"window.opener.location.reload(true);self.close();\"></body></html>";
106 sub HandleShelfNumber
{
107 if($authorized= ShelfPossibleAction
($loggedinuser, $shelfnumber, 'add')) {
108 AddBibliosToShelf
($shelfnumber,@biblionumber);
109 #Close this page and return
110 print $query->header;
111 print "<html><meta http-equiv=\"refresh\" content=\"0\" /><body onload=\"self.close();\"></body></html>";
115 sub HandleSelectedShelf
{
116 if($authorized= ShelfPossibleAction
( $loggedinuser, $selectedshelf, 'add')){
117 #adding to specific shelf
118 my ($singleshelf, $singleshelfname)= GetShelf
($query->param('selectedshelf'));
121 shelfnumber
=> $singleshelf,
122 shelfname
=> $singleshelfname,
128 return unless $authorized= $loggedinuser>0;
129 my $privateshelves = GetAllShelves
(1,$loggedinuser,1);
130 if(@
{$privateshelves}){
132 privatevirtualshelves
=> $privateshelves,
136 my $publicshelves = GetAllShelves
(2,$loggedinuser,1);
137 if(@
{$publicshelves}){
139 publicvirtualshelves
=> $publicshelves,
146 #see comment in AddBibliosToShelf
147 if (scalar(@biblionumber) == 1) {
148 @biblionumber = (split /\//,$biblionumber[0]);
150 for my $bib (@biblionumber) {
151 my $data = GetBiblioData
( $bib );
153 { biblionumber
=> $bib,
154 title
=> $data->{'title'},
155 author
=> $data->{'author'},
159 multiple
=> (scalar(@biblios) > 1),
160 total
=> scalar @biblios,
161 biblios
=> \
@biblios,
167 newshelf
=> $newshelf||0,
168 authorized
=> $authorized,
170 OpacAllowPublicListCreation
=> C4
::Context
->preference('OpacAllowPublicListCreation'),
172 output_html_with_http_headers
$query, $cookie, $template->output;