Révision be58a50c
Ajouté par Assos Assos il y a environ 7 ans
drupal7/sites/all/modules/recaptcha/recaptcha.install | ||
---|---|---|
2 | 2 |
|
3 | 3 |
/** |
4 | 4 |
* @file |
5 |
* Provides install, updated, and uninstall functions for recaptcha.
|
|
5 |
* Installation file for reCAPTCHA module.
|
|
6 | 6 |
*/ |
7 | 7 |
|
8 | 8 |
/** |
9 | 9 |
* Implements hook_uninstall(). |
10 | 10 |
*/ |
11 | 11 |
function recaptcha_uninstall() { |
12 |
// Delete all the recaptcha variables and then clear the variable cache. |
|
12 |
variable_del('recaptcha_site_key'); |
|
13 |
variable_del('recaptcha_secret_key'); |
|
14 |
variable_del('recaptcha_theme'); |
|
15 |
variable_del('recaptcha_type'); |
|
16 |
variable_del('recaptcha_size'); |
|
17 |
variable_del('recaptcha_tabindex'); |
|
18 |
variable_del('recaptcha_noscript'); |
|
19 |
} |
|
20 |
|
|
21 |
/** |
|
22 |
* Update variables from 7.x-1.x. |
|
23 |
*/ |
|
24 |
function recaptcha_update_7200() { |
|
25 |
// Migrate the public key to site key. |
|
26 |
// Upgrade from 6.x-2.x to 7.x-2.x |
|
27 |
$site_key = variable_get('recaptcha_site_key', ''); |
|
28 |
// Upgrade from 7.x-1.x to 7.x-2.x |
|
29 |
$public_key = variable_get('recaptcha_public_key', $site_key); |
|
30 |
variable_set('recaptcha_site_key', $public_key); |
|
31 |
variable_del('recaptcha_public_key'); |
|
32 |
|
|
33 |
// Upgrade from 6.x-2.x to 7.x-2.x |
|
34 |
$secret_key = variable_get('recaptcha_secret_key', ''); |
|
35 |
// Upgrade from 7.x-1.x to 7.x-2.x |
|
36 |
$private_key = variable_get('recaptcha_private_key', $secret_key); |
|
37 |
variable_set('recaptcha_secret_key', $private_key); |
|
38 |
variable_del('recaptcha_private_key'); |
|
39 |
|
|
40 |
// Migrate previous 1.x themes to 2.x as good as possible. |
|
41 |
$recaptcha_themes = array( |
|
42 |
'red' => 'light', |
|
43 |
'white' => 'light', |
|
44 |
'blackglass' => 'dark', |
|
45 |
'clean' => 'light', |
|
46 |
'custom' => 'light', |
|
47 |
); |
|
48 |
// Upgrade from 6.x-2.x to 7.x-2.x |
|
49 |
$recaptcha_themes += array( |
|
50 |
'light' => 'light', |
|
51 |
'dark' => 'dark', |
|
52 |
); |
|
53 |
$recaptcha_theme = variable_get('recaptcha_theme', 'light'); |
|
54 |
variable_set('recaptcha_theme', $recaptcha_themes[$recaptcha_theme]); |
|
55 |
|
|
56 |
// Delete obsolete variables. |
|
57 |
variable_del('recaptcha_ajax_api'); |
|
58 |
variable_del('recaptcha_nocookies'); |
|
59 |
variable_del('recaptcha_server_status_check_interval'); |
|
60 |
|
|
61 |
// Remove stale variables not cleaned up properly in previous releases. |
|
62 |
variable_del('recaptcha_api_server'); |
|
63 |
variable_del('recaptcha_api_secure_server'); |
|
64 |
variable_del('recaptcha_secure_connection'); |
|
65 |
variable_del('recaptcha_verify_server'); |
|
66 |
|
|
67 |
// Mailhide module is not available, delete obsolete variables: |
|
68 |
// - recaptcha_mailhide_public_key |
|
69 |
// - recaptcha_mailhide_public_key_* |
|
70 |
// - recaptcha_mailhide_private_key |
|
71 |
// - recaptcha_mailhide_private_key_* |
|
13 | 72 |
db_delete('variable') |
14 |
->condition('name', 'recaptcha_%', 'LIKE') |
|
73 |
->condition('name', 'recaptcha_mailhide_%', 'LIKE')
|
|
15 | 74 |
->execute(); |
16 | 75 |
cache_clear_all('variables', 'cache_bootstrap'); |
76 |
|
|
77 |
return t('Migrated settings. You may need to create a new site key and secret key if it does not work.'); |
|
17 | 78 |
} |
18 | 79 |
|
19 | 80 |
/** |
20 |
* Implements hook_update_N().
|
|
81 |
* Default empty tabindex to 0.
|
|
21 | 82 |
*/ |
83 |
function recaptcha_update_7201() { |
|
84 |
// Change an empty tabindex to value 0 for consistency with D8. |
|
85 |
$recaptcha_tabindex = variable_get('recaptcha_tabindex', ''); |
|
86 |
if ($recaptcha_tabindex == '') { |
|
87 |
variable_set('recaptcha_tabindex', 0); |
|
88 |
} |
|
89 |
|
|
90 |
return t('Empty tabindex has been upgraded to 0.'); |
|
91 |
} |
|
22 | 92 |
|
23 | 93 |
/** |
24 |
* Issue #2473329: Remove obsolete variables.
|
|
94 |
* Remove recaptcha_mailhide 7.x-1.x from system table.
|
|
25 | 95 |
*/ |
26 |
function recaptcha_update_7100() { |
|
27 |
$variables = array( |
|
28 |
'recaptcha_secure_connection', |
|
29 |
'recaptcha_api_server', |
|
30 |
'recaptcha_api_secure_server', |
|
31 |
'recaptcha_verify_server', |
|
32 |
); |
|
33 |
foreach ($variables as $variable) { |
|
34 |
variable_del($variable); |
|
35 |
} |
|
36 |
return t('Removed obsolete variables.'); |
|
96 |
function recaptcha_update_7202() { |
|
97 |
// #2487215: Drupal 7.50+ requires system table cleanup. |
|
98 |
db_delete('system') |
|
99 |
->condition('name', 'recaptcha_mailhide') |
|
100 |
->execute(); |
|
101 |
|
|
102 |
return t('Removed recaptcha_mailhide module from database.'); |
|
37 | 103 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules