1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
be58a50c
|
Assos Assos
|
* Installation file for reCAPTCHA module.
|
6 |
85ad3d82
|
Assos Assos
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* Implements hook_uninstall().
|
10 |
|
|
*/
|
11 |
|
|
function recaptcha_uninstall() {
|
12 |
be58a50c
|
Assos Assos
|
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_*
|
72 |
85ad3d82
|
Assos Assos
|
db_delete('variable')
|
73 |
be58a50c
|
Assos Assos
|
->condition('name', 'recaptcha_mailhide_%', 'LIKE')
|
74 |
85ad3d82
|
Assos Assos
|
->execute();
|
75 |
4f315dab
|
Assos Assos
|
cache_clear_all('variables', 'cache_bootstrap');
|
76 |
be58a50c
|
Assos Assos
|
|
77 |
|
|
return t('Migrated settings. You may need to create a new site key and secret key if it does not work.');
|
78 |
85ad3d82
|
Assos Assos
|
}
|
79 |
f76f30e1
|
Assos Assos
|
|
80 |
|
|
/**
|
81 |
be58a50c
|
Assos Assos
|
* Default empty tabindex to 0.
|
82 |
f76f30e1
|
Assos Assos
|
*/
|
83 |
be58a50c
|
Assos Assos
|
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 |
|
|
}
|
92 |
4f315dab
|
Assos Assos
|
|
93 |
|
|
/**
|
94 |
be58a50c
|
Assos Assos
|
* Remove recaptcha_mailhide 7.x-1.x from system table.
|
95 |
4f315dab
|
Assos Assos
|
*/
|
96 |
be58a50c
|
Assos Assos
|
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.');
|
103 |
4f315dab
|
Assos Assos
|
} |