forked from backdrop-contrib/key
-
Notifications
You must be signed in to change notification settings - Fork 0
/
key.install
50 lines (45 loc) · 1.47 KB
/
key.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
<?php
/**
* @file
* Install, uninstall, and update functions for the Key module.
*/
/**
* Convert key config to CMI.
*/
function key_update_1000() {
if (db_table_exists('key_config')) {
$key_config = db_select('key_config', 'kc')
->fields('kc')
->execute()
->fetchAllAssoc('id');
foreach($key_config as $key) {
$config = config('key.key.' . $key->id);
if ($config->isNew()) {
$config->set('id', $key->id);
$config->set('label', $key->label);
$config->set('description', $key->description);
$config->set('key_type', $key->key_type);
$config->set('key_type_settings', unserialize($key->key_type_settings));
$config->set('key_provider', $key->key_provider);
$config->set('key_provider_settings', unserialize($key->key_provider_settings));
$config->set('key_input', $key->key_input);
$config->set('key_input_settings', unserialize($key->key_input_settings));
$config->save();
}
}
db_drop_table('key_config');
}
}
/**
* Use textarea for authentication keys stored in config.
*/
function key_update_1002() {
$config_names = config_get_names_with_prefix('key.key.');
foreach ($config_names as $name) {
$config = config($name);
if ($config->get('key_type') == 'authentication' && $config->get('key_provider') == 'config' && $config->get('key_input') == 'text_field') {
$config->set('key_input', 'textarea_field');
$config->save();
}
}
}