Révision be58a50c
Ajouté par Assos Assos il y a environ 7 ans
drupal7/sites/all/modules/recaptcha/recaptcha.admin.inc | ||
---|---|---|
2 | 2 |
|
3 | 3 |
/** |
4 | 4 |
* @file |
5 |
* Provides the reCAPTCHA administration settings.
|
|
5 |
* Provides the Google No CAPTCHA administration settings.
|
|
6 | 6 |
*/ |
7 | 7 |
|
8 | 8 |
/** |
9 |
* Form callback; administrative settings for reCaptcha.
|
|
9 |
* Form callback; administrative settings for Google No CAPTCHA.
|
|
10 | 10 |
*/ |
11 | 11 |
function recaptcha_admin_settings() { |
12 |
// Load the recaptcha library. Error if library does not load. |
|
13 |
if (!_recaptcha_load_library()) { |
|
14 |
drupal_set_message(t('Error loading recaptchalib.'), 'error'); |
|
15 |
return FALSE; |
|
16 |
} |
|
17 |
|
|
18 |
$form = array(); |
|
19 |
$form['recaptcha_public_key'] = array( |
|
12 |
$form['recaptcha_general_settings'] = array( |
|
13 |
'#type' => 'fieldset', |
|
14 |
'#title' => t('General settings'), |
|
15 |
); |
|
16 |
$form['recaptcha_general_settings']['recaptcha_site_key'] = array( |
|
20 | 17 |
'#type' => 'textfield', |
21 |
'#title' => t('Public Key'),
|
|
22 |
'#default_value' => variable_get('recaptcha_public_key', ''),
|
|
18 |
'#title' => t('Site key'),
|
|
19 |
'#default_value' => variable_get('recaptcha_site_key', ''),
|
|
23 | 20 |
'#maxlength' => 40, |
24 |
'#description' => t('The public key given to you when you <a href="@url" target="_blank">register for reCAPTCHA</a>.', array('@url' => url(recaptcha_get_signup_url($_SERVER['SERVER_NAME'], variable_get('site_name', ''))))),
|
|
21 |
'#description' => t('The site key given to you when you <a href="@url">register for reCAPTCHA</a>.', array('@url' => 'http://www.google.com/recaptcha/admin')),
|
|
25 | 22 |
'#required' => TRUE, |
26 | 23 |
); |
27 |
$form['recaptcha_private_key'] = array(
|
|
24 |
$form['recaptcha_general_settings']['recaptcha_secret_key'] = array(
|
|
28 | 25 |
'#type' => 'textfield', |
29 |
'#title' => t('Private Key'),
|
|
30 |
'#default_value' => variable_get('recaptcha_private_key', ''),
|
|
26 |
'#title' => t('Secret key'),
|
|
27 |
'#default_value' => variable_get('recaptcha_secret_key', ''),
|
|
31 | 28 |
'#maxlength' => 40, |
32 |
'#description' => t('The private key given to you when you <a href="@url" target="_blank">register for reCAPTCHA</a>.', array('@url' => url(recaptcha_get_signup_url($_SERVER['SERVER_NAME'], variable_get('site_name', ''))))),
|
|
29 |
'#description' => t('The secret key given to you when you <a href="@url">register for reCAPTCHA</a>.', array('@url' => 'http://www.google.com/recaptcha/admin')),
|
|
33 | 30 |
'#required' => TRUE, |
34 | 31 |
); |
35 |
$form['recaptcha_server_status_check_interval'] = array( |
|
36 |
'#type' => 'textfield', |
|
37 |
'#title' => t('Captcha server check interval'), |
|
38 |
'#default_value' => variable_get('recaptcha_server_status_check_interval', 5), |
|
39 |
'#description' => t('Number of minutes to cache reCAPTCHA server status.'), |
|
40 |
'#size' => 10, |
|
41 |
); |
|
42 |
$form['recaptcha_ajax_api'] = array( |
|
43 |
'#type' => 'checkbox', |
|
44 |
'#title' => t('AJAX API'), |
|
45 |
'#default_value' => variable_get('recaptcha_ajax_api', FALSE), |
|
46 |
'#description' => t('Use the AJAX API to display reCAPTCHA.'), |
|
47 |
); |
|
48 |
$form['recaptcha_nocookies'] = array( |
|
49 |
'#type' => 'checkbox', |
|
50 |
'#title' => t('Disable Client-Side Cookies'), |
|
51 |
'#default_value' => variable_get('recaptcha_nocookies', FALSE), |
|
52 |
'#description' => t('Add flag to disable third-party cookies set by reCAPTCHA.'), |
|
53 |
); |
|
54 |
$form['recaptcha_theme_settings'] = array( |
|
32 |
|
|
33 |
$form['recaptcha_widget_settings'] = array( |
|
55 | 34 |
'#type' => 'fieldset', |
56 |
'#title' => t('Theme Settings'),
|
|
35 |
'#title' => t('Widget settings'),
|
|
57 | 36 |
'#collapsible' => TRUE, |
58 |
'#collapsed' => TRUE,
|
|
37 |
'#collapsed' => FALSE,
|
|
59 | 38 |
); |
60 |
$form['recaptcha_theme_settings']['recaptcha_theme'] = array(
|
|
39 |
$form['recaptcha_widget_settings']['recaptcha_theme'] = array(
|
|
61 | 40 |
'#type' => 'select', |
62 | 41 |
'#title' => t('Theme'), |
63 | 42 |
'#description' => t('Defines which theme to use for reCAPTCHA.'), |
64 | 43 |
'#options' => array( |
65 |
'red' => t('Red'), |
|
66 |
'white' => t('White'), |
|
67 |
'blackglass' => t('Black Glass'), |
|
68 |
'clean' => t('Clean'), |
|
69 |
'custom' => t('Custom'), |
|
44 |
'light' => t('Light (default)'), |
|
45 |
'dark' => t('Dark'), |
|
70 | 46 |
), |
71 |
'#default_value' => variable_get('recaptcha_theme', 'red'), |
|
72 |
'#required' => TRUE, |
|
47 |
'#default_value' => variable_get('recaptcha_theme', 'light'), |
|
73 | 48 |
); |
74 |
$form['recaptcha_theme_settings']['recaptcha_tabindex'] = array( |
|
49 |
$form['recaptcha_widget_settings']['recaptcha_type'] = array( |
|
50 |
'#type' => 'select', |
|
51 |
'#title' => t('Type'), |
|
52 |
'#description' => t('The type of CAPTCHA to serve.'), |
|
53 |
'#options' => array( |
|
54 |
'image' => t('Image (default)'), |
|
55 |
'audio' => t('Audio'), |
|
56 |
), |
|
57 |
'#default_value' => variable_get('recaptcha_type', 'image'), |
|
58 |
); |
|
59 |
$form['recaptcha_widget_settings']['recaptcha_size'] = array( |
|
60 |
'#default_value' => variable_get('recaptcha_size', ''), |
|
61 |
'#description' => t('The size of CAPTCHA to serve.'), |
|
62 |
'#options' => array( |
|
63 |
'' => t('Normal (default)'), |
|
64 |
'compact' => t('Compact'), |
|
65 |
), |
|
66 |
'#title' => t('Size'), |
|
67 |
'#type' => 'select', |
|
68 |
); |
|
69 |
$form['recaptcha_widget_settings']['recaptcha_tabindex'] = array( |
|
75 | 70 |
'#type' => 'textfield', |
76 |
'#title' => t('Tab Index'),
|
|
77 |
'#description' => t('Sets a <a href="@tabindex" target="_blank">tabindex</a> for the reCAPTCHA text box. If other elements in the form use a tabindex, this should be set so that navigation is easier for the user.', array('@tabindex' => 'http://www.w3.org/TR/html4/interact/forms.html#adef-tabindex')),
|
|
78 |
'#default_value' => variable_get('recaptcha_tabindex', ''),
|
|
71 |
'#title' => t('Tabindex'),
|
|
72 |
'#description' => t('Set the <a href="@tabindex">tabindex</a> of the widget and challenge (Default = 0). If other elements in your page use tabindex, it should be set to make user navigation easier.', array('@tabindex' => 'http://www.w3.org/TR/html4/interact/forms.html#adef-tabindex')),
|
|
73 |
'#default_value' => variable_get('recaptcha_tabindex', 0),
|
|
79 | 74 |
'#size' => 4, |
80 | 75 |
); |
76 |
$form['recaptcha_widget_settings']['recaptcha_noscript'] = array( |
|
77 |
'#type' => 'checkbox', |
|
78 |
'#title' => t('Enable fallback for browsers with JavaScript disabled'), |
|
79 |
'#default_value' => variable_get('recaptcha_noscript', 0), |
|
80 |
'#description' => t('If JavaScript is a requirement for your site, you should <strong>not</strong> enable this feature. With this enabled, a compatibility layer will be added to the captcha to support non-js users.'), |
|
81 |
); |
|
81 | 82 |
|
82 | 83 |
return system_settings_form($form); |
83 | 84 |
} |
... | ... | |
88 | 89 |
* @see recaptcha_admin_settings() |
89 | 90 |
*/ |
90 | 91 |
function recaptcha_admin_settings_validate($form, &$form_state) { |
91 |
// Clear the page cache if Ajax API has been disabled. |
|
92 |
if (empty($form_state['values']['recaptcha_ajax_api']) && $form['recaptcha_ajax_api']['#default_value']) { |
|
93 |
cache_clear_all(NULL, 'cache_page'); |
|
94 |
} |
|
95 |
|
|
96 | 92 |
$tabindex = $form_state['values']['recaptcha_tabindex']; |
97 |
if (!empty($tabindex) && !is_numeric($tabindex)) {
|
|
98 |
form_set_error('recaptcha_tabindex', t('The Tab Index must be an integer.'));
|
|
93 |
if (!is_numeric($tabindex)) { |
|
94 |
form_set_error('recaptcha_tabindex', t('The tabindex must be an integer.'));
|
|
99 | 95 |
} |
100 | 96 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules