This repository has been archived by the owner on Oct 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpbs_passport.install
222 lines (193 loc) · 6.68 KB
/
pbs_passport.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<?php
/**
* @file
* Install, update, and uninstall functions for PBS Passport.
*/
/**
* Implements hook_schema().
*/
function pbs_passport_schema() {
$schema['pbs_passport_user'] = array(
'description' => 'PBS Passport user data.',
'fields' => array(
'uid' => array(
'description' => 'Drupal UID',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'pid' => array(
'description' => 'PBS PID',
'type' => 'varchar',
'length' => '64',
'not null' => FALSE,
),
'membership_id' => array(
'description' => 'MVault ID',
'type' => 'varchar',
'length' => '36',
'not null' => FALSE,
),
'email' => array(
'description' => 'User email address',
'type' => 'varchar',
'length' => '255',
'not null' => FALSE,
),
'first_name' => array(
'description' => 'User first name',
'type' => 'varchar',
'length' => '255',
'not null' => FALSE,
),
'last_name' => array(
'description' => 'User last name',
'type' => 'varchar',
'length' => '255',
'not null' => FALSE,
),
'vppa_accepted' => array(
'description' => 'User VPPA accepted status',
'type' => 'int',
'size' => 'tiny',
'not null' => FALSE,
),
'membership_type' => array(
'description' => 'MVault membership',
'type' => 'varchar',
'length' => '255',
'not null' => FALSE,
),
'passport_state' => array(
'description' => 'Overall Passport state indicator.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
),
'passport_activated' => array(
'description' => 'Passport activated status',
'type' => 'int',
'size' => 'tiny',
'not null' => FALSE,
),
'passport_start_date' => array(
'description' => 'Passport start date',
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
),
'passport_expire_date' => array(
'description' => 'Passport expire date',
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
),
'passport_grace_date' => array(
'description' => 'Passport grace period expire date',
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
),
'login_provider' => array(
'description' => 'The authentication service used by this account',
'type' => 'varchar',
'length' => '50',
'not null' => FALSE,
),
'thumbnail_url' => array(
'description' => 'URL for a user thumbnail fron the login provider.',
'type' => 'varchar',
'length' => '255',
'not null' => FALSE,
),
),
'primary key' => array('uid'),
'indexes' => array(
'membership_id' => array('membership_id'),
'pid' => array('pid'),
),
);
return $schema;
}
/**
* Implements hook_install().
*/
function pbs_passport_install() {
// Establish default module variables.
$defaults = array();
$defaults['pbs_passport_lookup_email_'
. PBS_PASSPORT_MEMBERSHIP_ACTIVATED] = <<<EOD
Good news! Your [pbs_passport:station:short_common_name] Passport membership is already activated!
Account details -
Email address: [pbs_passport:membership:email]
First name: [pbs_passport:membership:first_name]
Last name: [pbs_passport:membership:last_name]
Activation date: [pbs_passport:membership:activation_date]
Expiration date: [pbs_passport:membership:expire_date]
Login provider: [pbs_passport:membership:login_provider]
[pbs_passport:station:full_common_name]
[pbs_passport:station:tag_line]
EOD;
$defaults['pbs_passport_lookup_email_'
. PBS_PASSPORT_MEMBERSHIP_NOT_ACTIVATED] = <<<EOD
Your [pbs_passport:station:short_common_name] Passport membership is available, but has not been activated. The membership must be activated before it can be used to access [pbs_passport:station:short_common_name] Passport content. Your activation URL and token are provided below:
URL: [pbs_passport:membership:activation_url]
Token: [pbs_passport:membership:token]
Account details -
Email address: [pbs_passport:membership:email]
First name: [pbs_passport:membership:first_name]
Last name: [pbs_passport:membership:last_name]
[pbs_passport:station:full_common_name]
[pbs_passport:station:tag_line]
EOD;
$defaults['pbs_passport_lookup_email_'
. PBS_PASSPORT_MEMBERSHIP_GRACE_PERIOD] = <<<EOD
Your [pbs_passport:station:short_common_name] Passport membership is activated, but expired. The account is currently in a grace period that will expire [pbs_passport:membership:grace_period].
Donate before the grace period expires to keep your access to [pbs_passport:station:short_common_name] Passport content -
[pbs_passport:station:donate_url]
Account details -
Email address: [pbs_passport:membership:email]
First name: [pbs_passport:membership:first_name]
Last name: [pbs_passport:membership:last_name]
Activation date: [pbs_passport:membership:activation_date]
Expiration date: [pbs_passport:membership:expire_date]
Login provider: [pbs_passport:membership:login_provider]
[pbs_passport:station:full_common_name]
[pbs_passport:station:tag_line]
EOD;
$defaults['pbs_passport_lookup_email_'
. PBS_PASSPORT_MEMBERSHIP_EXPIRED] = <<<EOD
Your [pbs_passport:station:short_common_name] Passport membership has expired as of [pbs_passport:membership:expire_date]. Donate now to regain access to [pbs_passport:station:short_common_name] Passport content -
[pbs_passport:station:donate_url]
Account details -
Email address: [pbs_passport:membership:email]
First name: [pbs_passport:membership:first_name]
Last name: [pbs_passport:membership:last_name]
[pbs_passport:station:full_common_name]
[pbs_passport:station:tag_line]
EOD;
$defaults['pbs_passport_lookup_email_'
. PBS_PASSPORT_MEMBERSHIP_UNKNOWN] = <<<EOD
Please contact us for details about your [pbs_passport:station:short_common_name] Passport membership.
Email: [pbs_passport:station:email]
Phone: [pbs_passport:station:telephone]
Website: [pbs_passport:station:website_url]
[pbs_passport:station:full_common_name]
[pbs_passport:station:tag_line]
EOD;
foreach ($defaults as $variable => $default) {
if (variable_get($variable) === NULL) {
variable_set($variable, $default);
}
}
}
/**
* Add default variable for restricted roles login denied message.
*/
function pbs_passport_update_7100() {
$default = variable_get(
'pbs_passport_restricted_roles_message',
t('Login denied due to site configuration. Contact administrator for assistance.')
);
variable_set('pbs_passport_restricted_roles_message', $default);
}