-
Notifications
You must be signed in to change notification settings - Fork 3
/
sharethis.install
executable file
·115 lines (104 loc) · 4.54 KB
/
sharethis.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
<?php
/**
* @file
* This file holds the install information for the ShareThis Module.
*/
/**
* Implements hook_uninstall().
*/
function sharethis_uninstall() {
cache_clear_all('variables', 'cache');
}
/**
* Implements hook_requirements().
*/
function sharethis_requirements($phase) {
$requirements = array();
// Ensure translations don't break during installation.
$t = get_t();
// Report Backdrop version
if ($phase == 'runtime') {
$property = config_get('sharethis.settings', 'property');
if (!isset($property) || $property == '') {
$requirements['sharethis'] = array(
'title' => $t('ShareThis'),
'value' => $t('ShareThis has not been updated'),
'severity' => REQUIREMENT_WARNING,
'description' => $t('Check the <a href="@url">ShareThis module settings page</a> for instructions on how to update.', array('@url' => url('admin/config/services/sharethis'))),
);
}
}
return $requirements;
}
/**
* Implements hook_update_last_removed().
*/
function sharethis_update_last_removed() {
return 7001;
}
/**
* Update from variables to config.
*/
function sharethis_update_1000() {
$config = config('sharethis.settings');
$config->set('sharethis_location', update_variable_get('sharethis_location'));
$config->set('sharethis_comments', update_variable_get('sharethis_comments'));
$config->set('sharethis_weight', update_variable_get('sharethis_weight'));
$config->set('sharethis_late_load', update_variable_get('sharethis_late_load'));
$config->set('sharethis_twitter_suffix', update_variable_get('sharethis_twitter_suffix'));
$config->set('sharethis_twitter_handle', update_variable_get('sharethis_twitter_handle'));
$config->set('sharethis_twitter_recommends', update_variable_get('sharethis_twitter_recommends'));
$config->set('sharethis_option_onhover', update_variable_get('sharethis_option_onhover'));
$config->set('sharethis_option_neworzero', update_variable_get('sharethis_option_neworzero'));
$config->set('sharethis_option_shorten', update_variable_get('sharethis_option_shorten'));
$config->set('sharethis_button_option', update_variable_get('sharethis_button_option'));
$config->set('sharethis_publisherID', update_variable_get('sharethis_publisherID'));
$config->set('sharethis_service_option', update_variable_get('sharethis_service_option'));
$config->set('sharethis_option_extras', update_variable_get('sharethis_option_extras'));
$config->set('sharethis_widget_option', update_variable_get('sharethis_widget_option'));
$config->set('sharethis_option_onhover', update_variable_get('sharethis_option_onhover'));
$config->set('sharethis_option_neworzero', update_variable_get('sharethis_option_neworzero'));
$config->set('sharethis_cns', update_variable_get('sharethis_cns'));
$config->set('sharethis_node_types', update_variable_get('sharethis_node_types'));
$config->set('sharethis_option_shorten', update_variable_get('sharethis_option_shorten'));
$config->save();
// Delete variables.
update_variable_del('sharethis_location');
update_variable_del('sharethis_comments');
update_variable_del('sharethis_weight');
update_variable_del('sharethis_late_load');
update_variable_del('sharethis_twitter_suffix');
update_variable_del('sharethis_twitter_handle');
update_variable_del('sharethis_twitter_recommends');
update_variable_del('sharethis_option_onhover');
update_variable_del('sharethis_option_neworzero');
update_variable_del('sharethis_option_shorten');
update_variable_del('sharethis_button_option');
update_variable_del('sharethis_service_option');
update_variable_del('sharethis_option_extras');
update_variable_del('sharethis_widget_option');
update_variable_del('sharethis_option_onhover');
update_variable_del('sharethis_option_neworzero');
update_variable_del('sharethis_cns');
update_variable_del('sharethis_node_types');
update_variable_del('sharethis_option_shorten');
update_variable_del('sharethis_publisherID');
}
/**
* Remove ShareThis config values that are not used anymore.
*/
function sharethis_update_1001() {
$config = config('sharethis.settings');
// Retrieve the only config values used after the update.
$types = $config->get('sharethis_node_types');
$comments = $config->get('sharethis_comments');
// Delete all other config.
$config->delete();
// Create a new config file with the same name.
$config = config('sharethis.settings');
// Put useful settings info back into config, with better names.
$config->set('node_types', $types);
$config->set('comments', $comments);
// Save.
$config->save();
}