Bug 13986: Printing a list only prints the results of the page you are viewing
[koha.git] / C4 / VirtualShelves / Page.pm
1 package C4::VirtualShelves::Page;
2
3 #
4 # Copyright 2000-2002 Katipo Communications
5 #
6 # This file is part of Koha.
7 #
8 # Koha is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # Koha is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20
21 # perldoc at the end of the file, per convention.
22
23 use strict;
24 use warnings;
25
26 use CGI qw ( -utf8 );
27 use Exporter;
28 use Data::Dumper;
29
30 use C4::VirtualShelves qw/:DEFAULT ShelvesMax/;
31 use C4::Biblio;
32 use C4::Items;
33 use C4::Reserves;
34 use C4::Koha;
35 use C4::Auth qw/get_session/;
36 use C4::Members;
37 use C4::Output;
38 use C4::Dates qw/format_date/;
39 use C4::Tags qw(get_tags);
40 use C4::Csv;
41 use C4::XSLT;
42
43 use constant VIRTUALSHELVES_COUNT => 20;
44
45 use vars qw($debug @EXPORT @ISA $VERSION);
46
47 BEGIN {
48     $VERSION = 3.07.00.049;
49     @ISA     = qw(Exporter);
50     @EXPORT  = qw(&shelfpage);
51     $debug   = $ENV{DEBUG} || 0;
52 }
53
54 our %pages = (
55     intranet => { redirect => '/cgi-bin/koha/virtualshelves/shelves.pl', },
56     opac     => { redirect => '/cgi-bin/koha/opac-shelves.pl', },
57 );
58
59 sub shelfpage {
60     my ( $type, $query, $template, $loggedinuser, $cookie ) = @_;
61     ( $pages{$type} ) or $type = 'opac';
62     $query            or die "No query";
63     $template         or die "No template";
64     $template->param(
65     loggedinuser => $loggedinuser,
66     OpacAllowPublicListCreation => C4::Context->preference('OpacAllowPublicListCreation'),
67     );
68     my $edit;
69     my $shelves;
70     my @paramsloop;
71     my $totitems;
72     my $shelfoff    = ( $query->param('shelfoff') ? $query->param('shelfoff') : 1 );
73     $template->{VARS}->{'shelfoff'} = $shelfoff;
74     my $itemoff     = ( $query->param('itemoff')  ? $query->param('itemoff')  : 1 );
75     my $displaymode = ( $query->param('display')  ? $query->param('display')  : 'publicshelves' );
76     my ( $shelflimit, $shelfoffset, $shelveslimit, $shelvesoffset );
77     my $marcflavour = C4::Context->preference("marcflavour");
78
79     unless ( $query->param('print') ) {
80         $shelflimit = ( $type eq 'opac' ? C4::Context->preference('OPACnumSearchResults') : C4::Context->preference('numSearchResults') );
81         $shelflimit = $shelflimit || ShelvesMax('MGRPAGE');
82         $shelflimit = undef if $query->param('rss');
83         $shelfoffset   = ( $itemoff - 1 ) * $shelflimit;     # Sets the offset to begin retrieving items at
84         $shelveslimit  = $shelflimit;                        # Limits number of shelves returned for a given query (row_count)
85         $shelvesoffset = ( $shelfoff - 1 ) * $shelflimit;    # Sets the offset to begin retrieving shelves at (offset)
86     }
87
88     # getting the Shelves list
89     my $category = ( ( $displaymode eq 'privateshelves' ) ? 1 : 2 );
90     my $shelflist = GetShelves( $category, $shelveslimit, $shelvesoffset, $loggedinuser );
91     my $totshelves = C4::VirtualShelves::GetShelfCount( $loggedinuser, $category );
92
93     my $op = $query->param('op');
94
95     # the format of this is unindented for ease of diff comparison to the old script
96     # Note: do not mistake the assignment statements below for comparisons!
97     if ( $query->param('modifyshelfcontents') ) {
98         my ( $shelfnumber, $barcode, $item, $biblio );
99         if ( $shelfnumber = $query->param('viewshelf') ) {
100             #add to shelf
101             if($barcode = $query->param('addbarcode') ) {
102                 if(ShelfPossibleAction( $loggedinuser, $shelfnumber, 'add')) {
103                     $item = GetItem( 0, $barcode);
104                     if (defined $item && $item->{'itemnumber'}) {
105                         $biblio = GetBiblioFromItemNumber( $item->{'itemnumber'} );
106                         AddToShelf( $biblio->{'biblionumber'}, $shelfnumber, $loggedinuser)
107                           or push @paramsloop, { duplicatebiblio => $barcode };
108                     }
109                     else {
110                         push @paramsloop, { failgetitem => $barcode };
111                     }
112                 }
113                 else {
114                     push @paramsloop, { nopermission => $shelfnumber };
115                 }
116             }
117             elsif(grep { /REM-(\d+)/ } $query->param) {
118             #remove item(s) from shelf
119                 if(ShelfPossibleAction($loggedinuser, $shelfnumber, 'delete')) {
120                 #This is just a general okay; DelFromShelf checks further
121                     my @bib;
122                     foreach($query->param) {
123                         /REM-(\d+)/ or next;
124                         push @bib, $1; #$1 is biblionumber
125                     }
126                     my $t= DelFromShelf(\@bib, $shelfnumber, $loggedinuser);
127                     if($t==0) {
128                         push @paramsloop, {nothingdeleted => $shelfnumber};
129                     }
130                     elsif($t<@bib) {
131                         push @paramsloop, {somedeleted => $shelfnumber};
132                     }
133                 }
134                 else {
135                     push @paramsloop, { nopermission => $shelfnumber };
136                 }
137             }
138         }
139         else {
140             push @paramsloop, { noshelfnumber => 1 };
141         }
142     }
143
144     my $showadd = 1;
145
146     # set the default tab, etc. (for OPAC)
147     my $shelf_type = ( $query->param('display') ? $query->param('display') : 'publicshelves' );
148     if ( defined $shelf_type ) {
149         if ( $shelf_type eq 'privateshelves' ) {
150             $template->param( showprivateshelves => 1 );
151         } elsif ( $shelf_type eq 'publicshelves' ) {
152             $template->param( showpublicshelves => 1 );
153             $showadd = 0;
154         } else {
155             $debug and warn "Invalid 'display' param ($shelf_type)";
156         }
157     } elsif ( $loggedinuser == -1 ) {
158         $template->param( showpublicshelves => 1 );
159     } else {
160         $template->param( showprivateshelves => 1 );
161     }
162
163     my ( $okmanage, $okview );
164     my $shelfnumber = $query->param('shelfnumber') || $query->param('viewshelf');
165     if ($shelfnumber) {
166         $okmanage = ShelfPossibleAction( $loggedinuser, $shelfnumber, 'manage' );
167         $okview   = ShelfPossibleAction( $loggedinuser, $shelfnumber, 'view' );
168     }
169
170     my $delflag = 0;
171
172   SWITCH: {
173         if ($op) {
174         #Saving modified shelf
175             if ( $op eq 'modifsave' ) {
176                 unless ($okmanage) {
177                         push @paramsloop, { nopermission => $shelfnumber };
178                         last SWITCH;
179                 }
180                 my $shelf = {
181                     shelfname          => $query->param('shelfname'),
182                     sortfield          => $query->param('sortfield'),
183                     allow_add          => $query->param('allow_add'),
184                     allow_delete_own   => $query->param('allow_delete_own'),
185                     allow_delete_other => $query->param('allow_delete_other'),
186                 };
187                 if($query->param('category')) { #optional
188                     $shelf->{category}= $query->param('category');
189                 }
190                 unless(ModShelf($shelfnumber, $shelf )) {
191                   push @paramsloop, {modifyfailure => $shelf->{shelfname}};
192                   last SWITCH;
193                 }
194
195                 if($displaymode eq "viewshelf"){
196                     print $query->redirect( $pages{$type}->{redirect} . "?viewshelf=$shelfnumber" );
197                 } elsif($displaymode eq "publicshelves"){
198                     print $query->redirect( $pages{$type}->{redirect} );
199                 } else {
200                     print $query->redirect( $pages{$type}->{redirect} . "?display=privateshelves" );
201                 }
202                 exit;
203             }
204         #Editing a shelf
205         elsif ( $op eq 'modif' ) {
206                 my ( $shelfnumber2, $shelfname, $owner, $category, $sortfield, $allow_add, $allow_delete_own, $allow_delete_other) = GetShelf($shelfnumber);
207                 my $member = GetMember( 'borrowernumber' => $owner );
208                 my $ownername = defined($member) ? $member->{firstname} . " " . $member->{surname} : '';
209                 $edit = 1;
210                 $template->param(
211                     edit                => 1,
212                     display             => $displaymode,
213                     shelfnumber         => $shelfnumber2,
214                     shelfname           => $shelfname,
215                     owner               => $owner,
216                     ownername           => $ownername,
217                     "category$category" => 1,
218                     category            => $category,
219                     sortfield           => $sortfield,
220                     allow_add           => $allow_add,
221                     allow_delete_own    => $allow_delete_own,
222                     allow_delete_other  => $allow_delete_other,
223                 );
224             }
225             last SWITCH;
226         }
227
228         #View a shelf
229         if ( $shelfnumber = $query->param('viewshelf') ) {
230             # explicitly fetch this shelf
231             my ($shelfnumber2,$shelfname,$owner,$category,$sorton) = GetShelf($shelfnumber);
232
233             $template->param(
234                 'DisplayMultiPlaceHold' => C4::Context->preference('DisplayMultiPlaceHold'),
235             );
236             if (C4::Context->preference('TagsEnabled')) {
237                 $template->param(TagsEnabled => 1);
238                     foreach (qw(TagsShowOnList TagsInputOnList)) {
239                     C4::Context->preference($_) and $template->param($_ => 1);
240                 }
241             }
242             #check that the user can view the shelf
243             if ( ShelfPossibleAction( $loggedinuser, $shelfnumber, 'view' ) ) {
244                 my $items;
245                 my $tag_quantity;
246                 my $sortfield = ( $sorton ? $sorton : 'title' );
247                 $sortfield = $query->param('sort') || $sortfield; ## Passed in sorting overrides default sorting
248                 my $direction = $query->param('direction') || 'asc';
249                 $template->param(
250                     sort      => $sortfield,
251                     direction => $direction,
252                 );
253                 ( $items, $totitems ) = GetShelfContents( $shelfnumber, $shelflimit, $shelfoffset, $sortfield, $direction );
254
255                 # get biblionumbers stored in the cart
256                 # Note that it's not use at the intranet
257                 my @cart_list;
258                 my $cart_cookie = ( $type eq 'opac' ? "bib_list" : "intranet_bib_list" );
259                 if($query->cookie($cart_cookie)){
260                     my $cart_list = $query->cookie($cart_cookie);
261                     @cart_list = split(/\//, $cart_list);
262                 }
263
264                 my $borrower = GetMember( 'borrowernumber' => $loggedinuser );
265
266                 for my $this_item (@$items) {
267                     my $biblionumber = $this_item->{'biblionumber'};
268                     my $record = GetMarcBiblio($biblionumber);
269                     if (C4::Context->preference("OPACXSLTResultsDisplay") && $type eq 'opac') {
270                         $this_item->{XSLTBloc} = XSLTParse4Display($biblionumber, $record, "OPACXSLTResultsDisplay");
271                     } elsif (C4::Context->preference("XSLTResultsDisplay") && $type eq 'intranet') {
272                         $this_item->{XSLTBloc} = XSLTParse4Display($biblionumber, $record, "XSLTResultsDisplay");
273                     }
274
275                     # the virtualshelfcontents table does not store these columns nor are they retrieved from the items
276                     # and itemtypes tables, so I'm commenting them out for now to quiet the log -crn
277                     #$this_item->{imageurl} = $imgdir."/".$itemtypes->{ $this_item->{itemtype}  }->{'imageurl'};
278                     #$this_item->{'description'} = $itemtypes->{ $this_item->{itemtype} }->{'description'};
279                     $this_item->{'dateadded'} = format_date( $this_item->{'dateadded'} );
280                     $this_item->{'imageurl'}  = getitemtypeinfo( $this_item->{'itemtype'}, $type )->{'imageurl'};
281                     $this_item->{'coins'}     = GetCOinSBiblio( $record );
282                     $this_item->{'subtitle'} = GetRecordValue('subtitle', $record, GetFrameworkCode($this_item->{'biblionumber'}));
283                     $this_item->{'normalized_upc'}  = GetNormalizedUPC(       $record,$marcflavour);
284                     $this_item->{'normalized_ean'}  = GetNormalizedEAN(       $record,$marcflavour);
285                     $this_item->{'normalized_oclc'} = GetNormalizedOCLCNumber($record,$marcflavour);
286                     $this_item->{'normalized_isbn'} = GetNormalizedISBN(undef,$record,$marcflavour);
287                     if(!defined($this_item->{'size'})) { $this_item->{'size'} = "" }; #TT has problems with size
288                     # Getting items infos for location display
289                     my @items_infos = &GetItemsLocationInfo( $this_item->{'biblionumber'});
290                     $this_item->{'itemsissued'} = CountItemsIssued( $this_item->{'biblionumber'} );
291                     $this_item->{'ITEM_RESULTS'} = \@items_infos;
292                     if ( grep {$_ eq $biblionumber} @cart_list) {
293                         $this_item->{'incart'} = 1;
294                     }
295
296                     if (C4::Context->preference('TagsEnabled') and $tag_quantity = C4::Context->preference('TagsShowOnList')) {
297                         $this_item->{'TagLoop'} = get_tags({
298                             biblionumber=>$this_item->{'biblionumber'}, approved=>1, 'sort'=>'-weight',
299                             limit=>$tag_quantity
300                             });
301                     }
302
303                     $this_item->{'allow_onshelf_holds'} = C4::Reserves::OnShelfHoldsAllowed($this_item, $borrower);
304                 }
305                 if($type eq 'intranet'){
306                     # Build drop-down list for 'Add To:' menu...
307                     my ($totalref, $pubshelves, $barshelves)=
308                     C4::VirtualShelves::GetSomeShelfNames($loggedinuser,'COMBO',1);
309                     $template->param(
310                         addbarshelves     => $totalref->{bartotal},
311                         addbarshelvesloop => $barshelves,
312                         addpubshelves     => $totalref->{pubtotal},
313                         addpubshelvesloop => $pubshelves,
314                     );
315                 }
316                 push @paramsloop, { display => 'privateshelves' } if $category == 1;
317                 $showadd = 1;
318                 my $i = 0;
319                 my $manageshelf = ShelfPossibleAction( $loggedinuser, $shelfnumber, 'manage' );
320                 my $can_delete_shelf = ShelfPossibleAction( $loggedinuser, $shelfnumber, 'delete_shelf' );
321                 $template->param(
322                     shelfname           => $shelfname,
323                     shelfnumber         => $shelfnumber,
324                     viewshelf           => $shelfnumber,
325                     sortfield           => $sortfield,
326                     manageshelf         => $manageshelf,
327                     allowremovingitems  => ShelfPossibleAction( $loggedinuser, $shelfnumber, 'delete'),
328                     allowaddingitem     => ShelfPossibleAction( $loggedinuser, $shelfnumber, 'add'),
329                     allowdeletingshelf  => $can_delete_shelf,
330                     "category$category" => 1,
331                     category            => $category,
332                     itemsloop           => $items,
333                     showprivateshelves  => $category==1,
334                 );
335             } else {
336                 push @paramsloop, { nopermission => $shelfnumber };
337             }
338             last SWITCH;
339         }
340
341         if ( $query->param('shelves') ) {
342             my $stay = 1;
343
344         #Add a shelf
345             if ( my $newshelf = $query->param('addshelf') ) {
346
347                 # note: a user can always add a new shelf (except database administrator account)
348                 my $shelfnumber = AddShelf( {
349                     shelfname => $newshelf,
350                     sortfield => $query->param('sortfield'),
351                     category => $query->param('category'),
352                     allow_add => $query->param('allow_add'),
353                     allow_delete_own => $query->param('allow_delete_own'),
354                     allow_delete_other => $query->param('allow_delete_other'),
355                     },
356                     $query->param('owner') );
357                 $stay = 1;
358                 if( !$shelfnumber ) {
359                     push @paramsloop, { addshelf_failed => 1 };
360                 } elsif ( $shelfnumber == -1 ) {    #shelf already exists.
361                     $showadd = 1;
362                     push @paramsloop, { already => $newshelf };
363                     $template->param( shelfnumber => $shelfnumber );
364                 } else {
365                     print $query->redirect( $pages{$type}->{redirect} . "?viewshelf=$shelfnumber" );
366                     exit;
367                 }
368             }
369
370         #Deleting a shelf (asking for confirmation if it has entries)
371             foreach ( $query->param() ) {
372                 /(DEL|REMSHR)-(\d+)/ or next;
373                 $delflag = 1;
374                 my $number = $2;
375                 unless ( defined $shelflist->{$number} ) {
376                     push( @paramsloop, { unrecognized => $number } );
377                     last;
378                 }
379                 #remove a share
380                 if(/REMSHR/) {
381                     RemoveShare($loggedinuser, $number);
382                     delete $shelflist->{$number} if exists $shelflist->{$number};
383                     $stay=0;
384                     next;
385                 }
386
387                 my $can_manage = ShelfPossibleAction( $loggedinuser, $number, 'manage' );
388                 my $can_delete = ShelfPossibleAction( $loggedinuser, $number, 'delete_shelf' );
389                 unless ( $can_manage or $can_delete ) {
390                     push( @paramsloop, { nopermission => $shelfnumber } );
391                     last;
392                 }
393                 my $contents;
394                 ( $contents, $totshelves ) = GetShelfContents( $number, $shelveslimit, $shelvesoffset );
395                 if ( $totshelves > 0 ) {
396                     unless ( scalar grep { /^CONFIRM-$number$/ } $query->param() ) {
397                         if ( defined $shelflist->{$number} ) {
398                             push( @paramsloop, { need_confirm => $shelflist->{$number}->{shelfname}, count => $totshelves, single => ($totshelves eq 1 ? 1:0) } );
399                             $shelflist->{$number}->{confirm} = $number;
400                         }
401                         $stay = 0;
402                         next;
403                     }
404                 }
405                 my $name;
406                 if ( defined $shelflist->{$number} ) {
407                     $name = $shelflist->{$number}->{'shelfname'};
408                     delete $shelflist->{$number};
409                 }
410                 unless ( DelShelf($number) ) {
411                     push( @paramsloop, { delete_fail => $name } );
412                     last;
413                 }
414                 push( @paramsloop, { delete_ok => $name } );
415
416                 $stay = 0;
417             }
418             $showadd = 1;
419             if ($stay){
420                 $template->param( shelves => 1 );
421                 $shelves = 1;
422             }
423             last SWITCH;
424         }
425     } # end of SWITCH block
426
427     (@paramsloop) and $template->param( paramsloop => \@paramsloop );
428     $showadd      and $template->param( showadd    => 1 );
429     my @shelvesloop;
430     my @shelveslooppriv;
431     my $numberCanManage = 0;
432
433     # rebuild shelflist in case a shelf has been added
434     $shelflist = GetShelves( $category, $shelveslimit, $shelvesoffset, $loggedinuser ) unless $delflag;
435     $totshelves = C4::VirtualShelves::GetShelfCount( $loggedinuser, $category ) unless $delflag;
436     foreach my $element ( sort { lc( $shelflist->{$a}->{'shelfname'} ) cmp lc( $shelflist->{$b}->{'shelfname'} ) } keys %$shelflist ) {
437         my %line;
438         $shelflist->{$element}->{shelf} = $element;
439         my $category  = $shelflist->{$element}->{'category'};
440         my $owner     = $shelflist->{$element}->{'owner'}||0;
441         my $canmanage = ShelfPossibleAction( $loggedinuser, $element, 'manage' );
442         my $candelete = ShelfPossibleAction( $loggedinuser, $element, 'delete_shelf' );
443         $shelflist->{$element}->{"viewcategory$category"} = 1;
444         $shelflist->{$element}->{manageshelf} = $canmanage;
445         $shelflist->{$element}->{allowdeletingshelf} = $candelete;
446         if($canmanage || ($loggedinuser && $owner==$loggedinuser)) {
447             $shelflist->{$element}->{'mine'} = 1;
448         }
449         my $member = GetMember( 'borrowernumber' => $owner );
450         $shelflist->{$element}->{ownername} = defined($member) ? $member->{firstname} . " " . $member->{surname} : '';
451         $numberCanManage++ if $canmanage;    # possibly outmoded
452         if ( $shelflist->{$element}->{'category'} eq '1' ) {
453             $shelflist->{$element}->{shares} = IsSharedList($element);
454             push( @shelveslooppriv, $shelflist->{$element} );
455         } else {
456             push( @shelvesloop, $shelflist->{$element} );
457         }
458     }
459
460     my $url = $type eq 'opac' ? "/cgi-bin/koha/opac-shelves.pl" : "/cgi-bin/koha/virtualshelves/shelves.pl";
461     my %qhash = ();
462     foreach (qw(display viewshelf sortfield sort direction)) {
463         $qhash{$_} = $query->param($_) if $query->param($_);
464     }
465     ( scalar keys %qhash ) and $url .= '?' . join '&', map { "$_=$qhash{$_}" } keys %qhash;
466     if ( $shelflimit ) {
467         if ( $shelfnumber && $totitems ) {
468             $template->param(  pagination_bar => pagination_bar( $url, ( int( $totitems / $shelflimit ) ) + ( ( $totitems % $shelflimit ) > 0 ? 1 : 0 ), $itemoff, "itemoff" )  );
469         } elsif ( $totshelves ) {
470             $template->param(
471                  pagination_bar => pagination_bar( $url, ( int( $totshelves / $shelveslimit ) ) + ( ( $totshelves % $shelveslimit ) > 0 ? 1 : 0 ), $shelfoff, "shelfoff" )  );
472         }
473     }
474
475     $template->param(
476         shelveslooppriv                                                    => \@shelveslooppriv,
477         shelvesloop                                                        => \@shelvesloop,
478         shelvesloopall                                                     => [ ( @shelvesloop, @shelveslooppriv ) ],
479         numberCanManage                                                    => $numberCanManage,
480         "BiblioDefaultView" . C4::Context->preference("BiblioDefaultView") => 1,
481         csv_profiles                                                       => GetCsvProfilesLoop('marc')
482     );
483
484     unless( $shelfnumber or $shelves or $edit ) {
485         # Only used for intranet
486         $template->param( op => 'list' );
487     }
488
489     if ($shelves or    # note: this part looks duplicative, but is intentional
490         $edit
491       ) {
492         $template->param( seflag => 1 );
493         #This hack is just another argument for refactoring this script one day
494         #At this point you are adding or editing a list; if you add, then you add a private list (by default) with permissions as below; if you edit, do not pass these permissions, they must come from the database
495         $template->param( allow_add => 0, allow_delete_own => 1, allow_delete_other => 0) unless $shelfnumber;
496     }
497
498 #Next call updates the shelves for the Lists button.
499 #May not always be needed (when nothing changed), but doesn't take much.
500     my ($total, $pubshelves, $barshelves) = C4::VirtualShelves::GetSomeShelfNames($loggedinuser, 'MASTHEAD');
501     $template->param(
502             barshelves     => $total->{bartotal},
503             barshelvesloop => $barshelves,
504             pubshelves     => $total->{pubtotal},
505             pubshelvesloop => $pubshelves,
506     );
507
508     output_html_with_http_headers $query, $cookie, $template->output;
509 }
510
511 1;
512 __END__
513
514 =head1 NAME
515
516 VirtualShelves/Page.pm
517
518 =head1 DESCRIPTION
519
520 Module used for both OPAC and intranet pages.
521
522 =head1 CGI PARAMETERS
523
524 =over 4
525
526 =item C<modifyshelfcontents>
527
528 If this script has to modify the shelf content.
529
530 =item C<shelfnumber>
531
532 To know on which shelf to work.
533
534 =item C<addbarcode>
535
536 =item C<op>
537
538  Op can be:
539     * modif: show the template allowing modification of the shelves;
540     * modifsave: save changes from modif mode.
541
542 =item C<viewshelf>
543
544 Load template with 'viewshelves param' displaying the shelf's information.
545
546 =item C<shelves>
547
548 If the param shelves == 1, then add or delete a shelf.
549
550 =item C<addshelf>
551
552 If the param shelves == 1, then addshelf is the name of the shelf to add.
553
554 =back
555
556 =cut