]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/0968.data.new_user_created_notice.sql
LP#1643709: Stamping upgrade scripts
[working/Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / 0968.data.new_user_created_notice.sql
1 BEGIN;
2
3 INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0968', :eg_version); -- jstompro/gmcharlt
4
5 --create hook for actor.usr.create_date
6 INSERT INTO action_trigger.hook (key, core_type, description, passive)
7     VALUES ('au.created', 'au', 'A user was created', 't');
8         
9 --SQL to create event definition for new account creation notice
10 --Inactive, owned by top of org tree by default.  Modify to suit needs.
11
12 INSERT INTO action_trigger.event_definition (
13     active, owner, name, hook, 
14     validator, reactor, delay, delay_field,
15     max_delay, template
16 )  VALUES (
17     'f', '1', 'New User Created Welcome Notice', 'au.created',
18     'NOOP_True', 'SendEmail', '10 seconds', 'create_date',
19     '1 day',
20 $$
21 [%- USE date -%]
22 [%- user = target -%]
23 [%- lib = target.home_ou -%]
24 To: [%- params.recipient_email || user.email %]
25 From: [%- helpers.get_org_setting(target.home_ou.id, 'org.bounced_emails') || lib.email || params.sender_email || default_sender %]
26 Reply-To: [%- helpers.get_org_setting(target.home_ou.id, 'org.bounced_emails') || lib.email || params.sender_email || default_sender %]
27 Subject: New Library Account Sign-up - Welcome!
28 Auto-Submitted: auto-generated
29
30 Dear [% user.first_given_name %] [% user.family_name %],
31
32 Thank you for signing up for an account with the [% lib.name %] on [% user.create_date.substr(0, 10) %].
33
34 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.
35
36 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.
37
38 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.
39
40 Sincerely,
41 [% lib.name %]
42
43 Contact your library for more information:
44
45 [% lib.name %]
46 [%- SET addr = lib.mailing_address -%]
47 [%- IF !addr -%] [%- SET addr = lib.billing_address -%] [%- END %]
48 [% addr.street1 %] [% addr.street2 %]
49 [% addr.city %], [% addr.state %]
50 [% addr.post_code %]
51 [% lib.phone %]
52 [% lib.email %]
53
54 $$);
55         
56 --insert environment values
57 INSERT INTO action_trigger.environment (event_def, path) VALUES
58     (CURRVAL('action_trigger.event_definition_id_seq'), 'home_ou.mailing_address'),
59     (CURRVAL('action_trigger.event_definition_id_seq'), 'home_ou.billing_address');
60         
61 COMMIT;