LP#1392396 - New patron welcome email action/trigger event def
authorJosh Stompro <stomproj@larl.org>
Wed, 29 Apr 2015 19:22:03 +0000 (14:22 -0500)
committerGalen Charlton <gmc@esilibrary.com>
Thu, 3 Mar 2016 01:23:27 +0000 (20:23 -0500)
This adds a new event definition to new installs for sending an email
to new users soon after their accounts are created.

An update script is also included to add this event to existing installs.

Signed-off-by: Josh Stompro <stomproj@larl.org>

Conflicts:
Open-ILS/src/sql/Pg/950.data.seed-values.sql

Signed-off-by: Galen Charlton <gmc@esilibrary.com>

Open-ILS/examples/action_trigger_filters.json.example
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.new_user_created_notice.sql [new file with mode: 0644]

index a721cb1..380df1b 100644 (file)
             "cancel_time": null,
             "capture_time": null
         }
+    },
+    "create" : {
+        "context_org":"home_ou",
+        "filter": {
+            "active":"t",
+            "deleted":"f"
+        }
     }
 }
index 1f515c3..f72c080 100644 (file)
@@ -15814,7 +15814,64 @@ INSERT INTO action_trigger.environment (event_def, path) VALUES
     (currval('action_trigger.event_definition_id_seq'), 'home_ou.mailing_address'),
     (currval('action_trigger.event_definition_id_seq'), 'home_ou.billing_address');
 
-    
+--Start new patron welcome email notice/action -----------
+--create hook for actor.usr.create_date
+INSERT INTO action_trigger.hook (key, core_type, description, passive)
+    VALUES ('create', 'au', 'Account is created', 't');
+       
+--SQL to create event definition for new account creation notice
+--Inactive, owned by top of org tree by default.  Modify to suit needs.
+
+INSERT INTO action_trigger.event_definition (
+    active, owner, name, hook, 
+    validator, reactor, delay, delay_field,
+    max_delay, template
+)  VALUES (
+    'f', '1', 'New User Created Welcome Notice', 'create',
+    'NOOP_True', 'SendEmail', '10 seconds', 'create_date',
+    '1 day',
+$$
+[%- USE date -%]
+[%- user = target -%]
+[%- lib = target.home_ou -%]
+To: [%- params.recipient_email || user.email %]
+From: [%- helpers.get_org_setting(target.home_ou.id, 'org.bounced_emails') || lib.email || params.sender_email || default_sender %]
+Reply-To: [%- helpers.get_org_setting(target.home_ou.id, 'org.bounced_emails') || lib.email || params.sender_email || default_sender %]
+Subject: New Library Account Sign-up - Welcome!
+Auto-Submitted: auto-generated
+
+Dear [% user.first_given_name %] [% user.family_name %],
+
+Thank you for signing up for an account with the [% lib.name %] on [% user.create_date.substr(0, 10) %].
+
+This email is your confirmation that your account is set up and ready as well as testing to see that we have your correct email address.
+
+If you did not sign up for an account at the library and have received this email in error, please reply and let us know.
+
+You can access your account online at http://catalog/eg/opac/login. From that site you can search the catalog, request materials, renew materials, leave comments, leave suggestions for titles you would like the library to purchase and update your account information.
+
+Sincerely,
+[% lib.name %]
+
+Contact your library for more information:
+
+[% lib.name %]
+[%- SET addr = lib.mailing_address -%]
+[%- IF !addr -%] [%- SET addr = lib.billing_address -%] [%- END %]
+[% addr.street1 %] [% addr.street2 %]
+[% addr.city %], [% addr.state %]
+[% addr.post_code %]
+[% lib.phone %]
+[% lib.email %]
+
+$$);
+       
+--insert environment values
+INSERT INTO action_trigger.environment (event_def, path) VALUES
+    (CURRVAL('action_trigger.event_definition_id_seq'), 'home_ou.mailing_address'),
+    (CURRVAL('action_trigger.event_definition_id_seq'), 'home_ou.billing_address');
+-- End new patron welcome message notice -----------
+
 -- OUS's for patron self-reg
 INSERT INTO config.org_unit_setting_type
     (name, grp, datatype, label, description)
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.new_user_created_notice.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.new_user_created_notice.sql
new file mode 100644 (file)
index 0000000..373aa5c
--- /dev/null
@@ -0,0 +1,59 @@
+BEGIN;
+
+--create hook for actor.usr.create_date
+INSERT INTO action_trigger.hook (key, core_type, description, passive)
+    VALUES ('create', 'au', 'Account is created', 't');
+       
+--SQL to create event definition for new account creation notice
+--Inactive, owned by top of org tree by default.  Modify to suit needs.
+
+INSERT INTO action_trigger.event_definition (
+    active, owner, name, hook, 
+    validator, reactor, delay, delay_field,
+    max_delay, template
+)  VALUES (
+    'f', '1', 'New User Created Welcome Notice', 'create',
+    'NOOP_True', 'SendEmail', '10 seconds', 'create_date',
+    '1 day',
+$$
+[%- USE date -%]
+[%- user = target -%]
+[%- lib = target.home_ou -%]
+To: [%- params.recipient_email || user.email %]
+From: [%- helpers.get_org_setting(target.home_ou.id, 'org.bounced_emails') || lib.email || params.sender_email || default_sender %]
+Reply-To: [%- helpers.get_org_setting(target.home_ou.id, 'org.bounced_emails') || lib.email || params.sender_email || default_sender %]
+Subject: New Library Account Sign-up - Welcome!
+Auto-Submitted: auto-generated
+
+Dear [% user.first_given_name %] [% user.family_name %],
+
+Thank you for signing up for an account with the [% lib.name %] on [% user.create_date.substr(0, 10) %].
+
+This email is your confirmation that your account is set up and ready as well as testing to see that we have your correct email address.
+
+If you did not sign up for an account at the library and have received this email in error, please reply and let us know.
+
+You can access your account online at http://catalog/eg/opac/login. From that site you can search the catalog, request materials, renew materials, leave comments, leave suggestions for titles you would like the library to purchase and update your account information.
+
+Sincerely,
+[% lib.name %]
+
+Contact your library for more information:
+
+[% lib.name %]
+[%- SET addr = lib.mailing_address -%]
+[%- IF !addr -%] [%- SET addr = lib.billing_address -%] [%- END %]
+[% addr.street1 %] [% addr.street2 %]
+[% addr.city %], [% addr.state %]
+[% addr.post_code %]
+[% lib.phone %]
+[% lib.email %]
+
+$$);
+       
+--insert environment values
+INSERT INTO action_trigger.environment (event_def, path) VALUES
+    (CURRVAL('action_trigger.event_definition_id_seq'), 'home_ou.mailing_address'),
+    (CURRVAL('action_trigger.event_definition_id_seq'), 'home_ou.billing_address');
+       
+COMMIT;