-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser_import.install
188 lines (179 loc) · 5.56 KB
/
user_import.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
<?php
/**
* @file
* Import and update users from a comma separated file (csv).
*/
/**
* Implements hook_schema().
*/
function user_import_schema() {
$schema['user_import'] = array(
'description' => t("Settings for each import, and import setting templates."),
'fields' => array(
'import_id' => array(
'description' => t("ID key of import or template."),
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'disp-width' => '10',
),
'name' => array(
'description' => t("Label of import template, only used if this is an import template."),
'type' => 'varchar',
'length' => '25',
'not null' => TRUE,
'default' => '',
),
'auto_import_directory' => array(
'description' => t("Name of directory associated with an import template."),
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
'default' => '',
),
'filename' => array(
'description' => t("Name of file being used as source of data for import."),
'type' => 'varchar',
'length' => '50',
'not null' => TRUE,
'default' => '',
),
'oldfilename' => array(
'description' => t("Original name of file being used as source of data for import."),
'type' => 'varchar',
'length' => '50',
'not null' => TRUE,
'default' => '',
),
'filepath' => array(
'description' => t("Path to file being used as source of data for import."),
'type' => 'text',
'size' => 'small',
'not null' => TRUE,
),
'started' => array(
'description' => t("Datestamp of when import was started."),
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'disp-width' => '11',
),
'pointer' => array(
'description' => t("Pointer to where test/import last finished."),
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'disp-width' => '10',
),
'processed' => array(
'description' => t("Number of users processed by import."),
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'disp-width' => '10',
),
'valid' => array(
'description' => t("Number of users processed without errors."),
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'disp-width' => '10',
),
'field_match' => array(
'description' => t("Settings for how data matches to Backdrop fields."),
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
'serialize' => TRUE,
),
'roles' => array(
'description' => t("Roles to give imported users."),
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
'serialize' => TRUE,
),
'options' => array(
'description' => t("Store of all other options for import. Most of the other settings in this table will be moved into here in future."),
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
'serialize' => TRUE,
),
'setting' => array(
'description' => t("Status of import, or whether it is an import template."),
'type' => 'varchar',
'length' => '10',
'not null' => TRUE,
'default' => '',
),
),
'primary key' => array('import_id'),
);
$schema['user_import_errors'] = array(
'description' => t("Record of errors encountered during an import."),
'fields' => array(
'import_id' => array(
'description' => t("ID key of import or template."),
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'disp-width' => '10',
),
'data' => array(
'description' => t("Data (matched to fields) for user that failed to import due to error."),
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
'serialize' => TRUE,
),
'errors' => array(
'description' => t("Error(s) encountered for user that failed to import."),
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
'serialize' => TRUE,
),
),
'indexes' => array(
'import_id' => array('import_id'),
),
);
return $schema;
}
/**
* Implements hook_install().
*/
function user_import_install() {
// Add a new mail system for HTML emails.
$mailconfig = config_set('system.mail', 'user_import', 'UserImportMailSystem');
}
/**
* Implements hook_uninstall().
*/
function user_import_uninstall() {
config_clear('system.mail', 'user_import');
}
/**
* Implements hook_update_last_removed().
*/
function user_import_update_last_removed() {
return 7201;
}
/**
* Implements hook_update_N().
*/
function user_import_update_1000() {
$config = config('user_import.settings');
$config->set('auto_imports_enabled', update_variable_get('user_import_auto_imports_enabled', 0));
$config->set('user_import_max', update_variable_get('user_import_max', '250'));
$config->set('line_max', update_variable_get('user_import_line_max', '1000'));
$config->set('default_settings', update_variable_get('user_import_settings', 0));
update_variable_del('user_import_profile_date_format');
update_variable_del('user_import_auto_imports_enabled');
update_variable_del('user_import_selectable_files');
update_variable_del('user_import_max');
update_variable_del('user_import_line_max');
update_variable_del('user_import_settings');
update_variable_del('user_import_og_template');
}