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