]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/XXXX.schema.patron-self-reg.sql
Trivial changes
[working/Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / XXXX.schema.patron-self-reg.sql
1
2 BEGIN;
3
4 -- Track the requesting user
5 ALTER TABLE staging.user_stage
6     ADD COLUMN requesting_usr INTEGER 
7         REFERENCES actor.usr(id) ON DELETE SET NULL;
8
9 -- add county column to staged address tables and 
10 -- drop state requirement to match actor.usr_address
11 ALTER TABLE staging.mailing_address_stage 
12     ADD COLUMN county TEXT,
13     ALTER COLUMN state DROP DEFAULT,
14     ALTER COLUMN state DROP NOT NULL;
15
16 ALTER TABLE staging.billing_address_stage 
17     ADD COLUMN county TEXT,
18     ALTER COLUMN state DROP DEFAULT,
19     ALTER COLUMN state DROP NOT NULL;
20
21 -- stored procedure for deleting expired pending patrons
22 CREATE OR REPLACE FUNCTION staging.purge_pending_users() RETURNS VOID AS $$
23 DECLARE
24     org_id INT;
25     intvl TEXT;
26 BEGIN
27     FOR org_id IN SELECT DISTINCT(home_ou) FROM staging.user_stage LOOP
28
29         SELECT INTO intvl value FROM 
30             actor.org_unit_ancestor_setting(
31                 'opac.pending_user_expire_interval', org_id);
32
33         CONTINUE WHEN intvl IS NULL OR intvl ILIKE 'null';
34
35         -- de-JSON-ify the string
36         SELECT INTO intvl TRIM(BOTH '"' FROM intvl);
37
38         DELETE FROM staging.user_stage 
39             WHERE home_ou = org_id AND row_date + intvl::INTERVAL < NOW();
40
41     END LOOP;
42 END;
43 $$ LANGUAGE PLPGSQL;
44
45
46 INSERT INTO config.org_unit_setting_type
47     (name, grp, datatype, label, description)
48 VALUES (
49     'opac.allow_pending_user',
50     'opac',
51     'bool',
52     oils_i18n_gettext(
53         'opac.allow_pending_user',
54         'Allow Patron Self-Registration',
55         'coust',
56         'label'
57     ),
58     oils_i18n_gettext(
59         'opac.allow_pending_user',
60         'Allow patrons to self-register, creating pending user accounts',
61         'coust',
62         'description'
63     )
64 ), (
65     'opac.pending_user_expire_interval',
66     'opac',
67     'interval',
68     oils_i18n_gettext(
69         'opac.pending_user_expire_interval',
70         'Patron Self-Reg. Expire Interval',
71         'coust',
72         'label'
73     ),
74     oils_i18n_gettext(
75         'opac.pending_user_expire_interval',
76         'If set, this is the amount of time a pending user account will ' ||
77         'be allowed to sit in the database.  After this time, the pending ' ||
78         'user information will be purged',
79         'coust',
80         'description'
81     )
82 ), (
83     'ui.patron.edit.aua.county.show',
84     'gui',
85     'bool',
86     oils_i18n_gettext(
87         'ui.patron.edit.aua.county.require',
88         'Show county field on patron registration',
89         'coust',
90         'label'
91     ),
92     oils_i18n_gettext(
93         'ui.patron.edit.aua.county.require',
94         'The county field will be shown on the patron registration screen',
95         'coust',
96         'description'
97     )
98 );
99
100 COMMIT;