start teachng /eg/opac/record/print how to print an entire list
authorGalen Charlton <gmc@equinoxinitiative.org>
Wed, 23 May 2018 17:39:48 +0000 (13:39 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Wed, 23 May 2018 17:39:48 +0000 (13:39 -0400)
If a new is_list CGI parameter has a truthy value, the page argument
is interpreted as the key of an anonymous cache entry containing a list
of one or more bibliographic records to print (rather than as the ID
of a single bib record).

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm

index 2e48ce3..f7d4882 100644 (file)
@@ -509,13 +509,35 @@ sub get_hold_copy_summary {
 sub load_print_record {
     my $self = shift;
 
-    my $rec_id = $self->ctx->{page_args}->[0] 
+    my $rec_or_list_id = $self->ctx->{page_args}->[0]
         or return Apache2::Const::HTTP_BAD_REQUEST;
 
-    $self->{ctx}->{bre_id} = $rec_id;
+    my $is_list = $self->cgi->param('is_list');
+    my $list;
+    if ($is_list) {
+
+        $list = $U->simplereq(
+            'open-ils.actor',
+            'open-ils.actor.anon_cache.get_value',
+            $rec_or_list_id, (ref $self)->ANON_CACHE_MYLIST);
+
+        if(!$list) {
+            $list = [];
+        }
+
+        {   # sanitize
+            no warnings qw/numeric/;
+            $list = [map { int $_ } @$list];
+            $list = [grep { $_ > 0} @$list];
+        };
+    } else {
+        $list = $rec_or_list_id;
+        $self->{ctx}->{bre_id} = $rec_or_list_id;
+    }
+
     $self->{ctx}->{printable_record} = $U->simplereq(
         'open-ils.search',
-        'open-ils.search.biblio.record.print', $rec_id);
+        'open-ils.search.biblio.record.print', $list);
 
     return Apache2::Const::OK;
 }