[open-ils-commits] r12144 - trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Feb 10 17:44:55 EST 2009


Author: erickson
Date: 2009-02-10 17:44:51 -0500 (Tue, 10 Feb 2009)
New Revision: 12144

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm
Log:
initial support for adding entries to a patron's items-checked-out list

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm	2009-02-10 21:24:39 UTC (rev 12143)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm	2009-02-10 22:44:51 UTC (rev 12144)
@@ -2359,5 +2359,42 @@
 }
 
 
+sub append_reading_list {
+    my $self = shift;
+    my $e = $self->editor;
+    return undef unless $self->patron and $self->title;
 
+    my $bkt = $e->search_container_biblio_record_entry_bucket(
+        {owner => $self->patron->id, btype => 'reading_list'})->[0];
 
+    my $pos = 1;
+
+    if($bkt) {
+        # find the next position
+        my $last_item = $e->search_container_biblio_record_entry_bucket_item(
+            {bucket => $bkt->id}, {order_by => {'cbrebi' => 'pos desc'}, limit => 1})->[0];
+        $pos = $last_item->pos + 1 if $last_item;
+
+    } else {
+        $bkt = Fieldmapper::container::biblio_record_entry_bucket->new;
+        $bkt->owner($self->patron->id);
+        $bkt->name('');
+        $bkt->btype('reading_list');
+        $bkt->pub('f');
+        $e->create_container_biblio_record_entry_bucket($bkt) or return $e->die_event;
+
+    }
+
+    my $item = Fieldmapper::container::biblio_record_entry_bucket_item->new;
+    $item->bucket($bkt->id);
+    $item->target_biblio_record_entry($self->title->id);
+    $item->pos($pos);
+
+    $e->create_container_biblio_record_entry_bucket_item($item)
+        or return $e->die_event;
+
+    return undef;
+}
+
+
+



More information about the open-ils-commits mailing list