-
Notifications
You must be signed in to change notification settings - Fork 2
/
cloudflare.install
55 lines (48 loc) · 1.43 KB
/
cloudflare.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
<?php
/**
* @file
* Install file for Cloudflare.
*/
/**
* Implements hook_enable().
*/
function cloudflare_enable() {
db_update('system')
->fields(array('weight' => -500))
->condition('type', 'module')
->condition('name', 'cloudflare')
->execute();
}
/**
* Implements hook_uninstall().
*/
function cloudflare_uninstall() {
config_clear('cloudflare.settings', 'cloudflare_api_email');
config_clear('cloudflare.settings', 'cloudflare_cf_connecting_ip');
state_del('cloudflare_api_key');
}
/**
* Migrate cloudflare variables to state storage.
*/
function cloudflare_update_1000() {
$config = config('cloudflare.settings');
$config->set('cloudflare_cf_connecting_ip', update_variable_get('cloudflare_cf_connecting_ip', '0'));
$config->set('cloudflare_api_email', update_variable_get('cloudflare_api_email', ''));
$config->save();
state_set('cloudflare_api_key', update_variable_get('cloudflare_api_key', ''));
update_variable_del('cloudflare_cf_connecting_ip');
update_variable_del('cloudflare_api_email');
update_variable_del('cloudflare_api_key');
}
/**
* Migrate cloudflare configuration from config.settings to state storage.
*/
function cloudflare_update_1001() {
$config = config('cloudflare.settings');
$config_api = $config->get('cloudflare_api_key');
if (!empty($config_api)) {
state_set('cloudflare_api_key', $config_api);
$config->clear('cloudflare_api_key');
$config->save();
}
}