LP#1356477: add ability to unconditionally send email
authorGalen Charlton <gmc@esilibrary.com>
Mon, 8 Aug 2016 20:50:08 +0000 (16:50 -0400)
committerMike Rylander <mrylander@gmail.com>
Wed, 24 Aug 2016 21:58:21 +0000 (17:58 -0400)
This patch defines and uses an
open-ils.trigger.event.autocreate.ignore_opt_in method that does what
it says on the tin; the caller is reponsible for not abusing this.

This supports a use case in the webstaff checkout interface where staff
can choose to have the receipt be emailed, provided that the patron
record has an email address defined, even if the user setting to
email receipts by default is not set. (It is assumed that the staff
member would have gotten permission from the patron on the spot.)

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/CircNotify.pm
Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger.pm

index 4629e15..48fc6a8 100644 (file)
@@ -74,7 +74,7 @@ sub circ_batch_notify {
     );
 
     $multi->request(
-        'open-ils.trigger.event.autocreate',
+        'open-ils.trigger.event.autocreate.ignore_opt_in',
         $hook => $_ => $e->requestor->ws_ou
     ) for ( @$circs );
     $client->status( new OpenSRF::DomainObject::oilsContinueStatus );
index ed83cba..920175b 100644 (file)
@@ -72,7 +72,7 @@ sub create_active_events_for_object {
     for my $def ( @$defs ) {
         next if ($granularity && $def->granularity ne $granularity );
 
-        if ($def->usr_field && $def->opt_in_setting) {
+        if (!$self->{ignore_opt_in} && $def->usr_field && $def->opt_in_setting) {
             my $ufield = $def->usr_field;
             my $uid = $target->$ufield;
             $uid = $uid->id if (ref $uid); # fleshed user object, unflesh it
@@ -124,6 +124,14 @@ __PACKAGE__->register_method(
     stream   => 1,
     argc     => 3
 );
+__PACKAGE__->register_method(
+    api_name      => 'open-ils.trigger.event.autocreate.ignore_opt_in',
+    method        => 'create_active_events_for_object',
+    api_level     => 1,
+    stream        => 1,
+    argc          => 3,
+    ignore_opt_in => 1
+);
 
 sub create_event_for_object_and_def {
     my $self = shift;