-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinvite.install
175 lines (165 loc) · 4.83 KB
/
invite.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
<?php
/**
* Implements hook_schema().
*/
function invite_schema() {
$schema = array();
$schema['invite'] = array(
'description' => 'The base table for invites.',
'fields' => array(
'iid' => array(
'description' => 'The primary identifier for the invite.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'reg_code' => array(
'description' => 'Stores the issued registration code and acts as primary identifier for a invite.',
'type' => 'varchar',
'length' => 10,
'not null' => TRUE,
'default' => '',
),
'type' => array(
'description' => 'The type (bundle) of this invite.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'uid' => array(
'description' => 'ID of Drupal user creator.',
'type' => 'int',
'not null' => TRUE,
),
'invitee' => array(
'description' => 'Drupal uid of the invitee upon registration.',
'type' => 'int',
'not null' => TRUE,
),
'created' => array(
'description' => 'The Unix timestamp when the invite was created.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'expiry' => array(
'description' => 'The Unix timestamp when the invite will expire.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'joined' => array(
'description' => 'Will be filled with the time the invite was accepted upon registration.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'canceled' => array(
'description' => 'The Unix timestamp when the invite has been withdrawn.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'data' => array(
'description' => 'Stores auxiliary data.',
'type' => 'text',
'not null' => TRUE,
),
),
'primary key' => array('iid'),
'indexes' => array(
'invitee' => array('invitee'),
),
'foreign keys' => array(
'user' => array(
'table' => 'users',
'columns' => array('uid' => 'uid'),
),
),
);
$schema['invite_type'] = array(
'description' => 'Stores information about all defined invite types.',
'fields' => array(
'id' => array(
'type' => 'serial',
'not null' => TRUE,
'description' => 'Primary Key: Unique invite type ID.',
),
'type' => array(
'description' => 'The machine-readable name of this type.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
),
'label' => array(
'description' => 'The human-readable name of this type.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'invite_sending_controller' => array(
'description' => 'Invite sending_controller.',
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
),
'description' => array(
'description' => 'A brief description of this type.',
'type' => 'text',
'not null' => TRUE,
'size' => 'medium',
'translatable' => TRUE,
),
'data' => array(
'description' => 'Stores auxiliary data.',
'type' => 'text',
'not null' => TRUE,
),
) + entity_exportable_schema_fields(),
'primary key' => array('id'),
'unique keys' => array(
'type' => array('type'),
),
);
return $schema;
}
/**
* Implements hook_install().
*/
function invite_install() {
// Set default expiry time 30 days
variable_set('invite_default_expiry_time', 30);
}
/**
* Implements hook_install().
*/
function invite_uninstall() {
// Set default expiry time 30 days
variable_del('invite_default_expiry_time');
$variables = db_select('variable')
->fields('v')
->condition('name', 'invite_type_%', 'LIKE')
->execute();
foreach ($variables as $variable) {
variable_del($variable->name);
}
}
/**
* Implements update from 2.x version to 4.x
*/
function invite_update_7400() {
$schema = invite_schema();
db_rename_table('invite', 'invite_2x');
db_rename_table('invite_notifications', 'invite_notifications_2x');
// Create tables.
db_create_table('invite_type', $schema['invite_type']);
db_create_table('invite', $schema['invite']);
// We unable move the data because invite_by_email should be installed.
// So all data transfer will be moved
variable_set('invite_version_updated', TRUE);
variable_set('invite_default_expiry_time', 30);
drupal_set_message(t('Invite was successfully installed. You could migrate !link.', array('!link' => l('old invites', 'admin/config/people/invite/migrate'))));
}