From bd88e5ff17d017442f5a3d90c3efe9e80a9d06ed Mon Sep 17 00:00:00 2001 From: Josh Stompro Date: Wed, 29 Apr 2015 14:22:03 -0500 Subject: [PATCH] LP#1392396 - New patron welcome email action/trigger event def 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 Conflicts: Open-ILS/src/sql/Pg/950.data.seed-values.sql Signed-off-by: Galen Charlton --- .../action_trigger_filters.json.example | 7 +++ Open-ILS/src/sql/Pg/950.data.seed-values.sql | 59 ++++++++++++++++++- .../upgrade/XXXX.new_user_created_notice.sql | 59 +++++++++++++++++++ 3 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX.new_user_created_notice.sql diff --git a/Open-ILS/examples/action_trigger_filters.json.example b/Open-ILS/examples/action_trigger_filters.json.example index a721cb1d4d..380df1baf7 100644 --- a/Open-ILS/examples/action_trigger_filters.json.example +++ b/Open-ILS/examples/action_trigger_filters.json.example @@ -33,5 +33,12 @@ "cancel_time": null, "capture_time": null } + }, + "create" : { + "context_org":"home_ou", + "filter": { + "active":"t", + "deleted":"f" + } } } diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index 1f515c30ea..f72c0804e4 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -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 index 0000000000..373aa5c7ab --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.new_user_created_notice.sql @@ -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; -- 2.43.2