1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
be58a50c
|
Assos Assos
|
* Provides the Google No CAPTCHA administration settings.
|
6 |
85ad3d82
|
Assos Assos
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
be58a50c
|
Assos Assos
|
* Form callback; administrative settings for Google No CAPTCHA.
|
10 |
85ad3d82
|
Assos Assos
|
*/
|
11 |
|
|
function recaptcha_admin_settings() {
|
12 |
be58a50c
|
Assos Assos
|
$form['recaptcha_general_settings'] = array(
|
13 |
|
|
'#type' => 'fieldset',
|
14 |
|
|
'#title' => t('General settings'),
|
15 |
|
|
);
|
16 |
|
|
$form['recaptcha_general_settings']['recaptcha_site_key'] = array(
|
17 |
85ad3d82
|
Assos Assos
|
'#type' => 'textfield',
|
18 |
be58a50c
|
Assos Assos
|
'#title' => t('Site key'),
|
19 |
|
|
'#default_value' => variable_get('recaptcha_site_key', ''),
|
20 |
85ad3d82
|
Assos Assos
|
'#maxlength' => 40,
|
21 |
be58a50c
|
Assos Assos
|
'#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')),
|
22 |
85ad3d82
|
Assos Assos
|
'#required' => TRUE,
|
23 |
|
|
);
|
24 |
be58a50c
|
Assos Assos
|
$form['recaptcha_general_settings']['recaptcha_secret_key'] = array(
|
25 |
85ad3d82
|
Assos Assos
|
'#type' => 'textfield',
|
26 |
be58a50c
|
Assos Assos
|
'#title' => t('Secret key'),
|
27 |
|
|
'#default_value' => variable_get('recaptcha_secret_key', ''),
|
28 |
85ad3d82
|
Assos Assos
|
'#maxlength' => 40,
|
29 |
be58a50c
|
Assos Assos
|
'#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')),
|
30 |
85ad3d82
|
Assos Assos
|
'#required' => TRUE,
|
31 |
|
|
);
|
32 |
be58a50c
|
Assos Assos
|
|
33 |
|
|
$form['recaptcha_widget_settings'] = array(
|
34 |
85ad3d82
|
Assos Assos
|
'#type' => 'fieldset',
|
35 |
be58a50c
|
Assos Assos
|
'#title' => t('Widget settings'),
|
36 |
85ad3d82
|
Assos Assos
|
'#collapsible' => TRUE,
|
37 |
be58a50c
|
Assos Assos
|
'#collapsed' => FALSE,
|
38 |
85ad3d82
|
Assos Assos
|
);
|
39 |
be58a50c
|
Assos Assos
|
$form['recaptcha_widget_settings']['recaptcha_theme'] = array(
|
40 |
85ad3d82
|
Assos Assos
|
'#type' => 'select',
|
41 |
|
|
'#title' => t('Theme'),
|
42 |
|
|
'#description' => t('Defines which theme to use for reCAPTCHA.'),
|
43 |
|
|
'#options' => array(
|
44 |
be58a50c
|
Assos Assos
|
'light' => t('Light (default)'),
|
45 |
|
|
'dark' => t('Dark'),
|
46 |
85ad3d82
|
Assos Assos
|
),
|
47 |
be58a50c
|
Assos Assos
|
'#default_value' => variable_get('recaptcha_theme', 'light'),
|
48 |
85ad3d82
|
Assos Assos
|
);
|
49 |
be58a50c
|
Assos Assos
|
$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(
|
70 |
85ad3d82
|
Assos Assos
|
'#type' => 'textfield',
|
71 |
be58a50c
|
Assos Assos
|
'#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),
|
74 |
85ad3d82
|
Assos Assos
|
'#size' => 4,
|
75 |
|
|
);
|
76 |
be58a50c
|
Assos Assos
|
$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 |
|
|
);
|
82 |
85ad3d82
|
Assos Assos
|
|
83 |
|
|
return system_settings_form($form);
|
84 |
|
|
}
|
85 |
|
|
|
86 |
|
|
/**
|
87 |
|
|
* Validation function for recaptcha_admin_settings().
|
88 |
|
|
*
|
89 |
|
|
* @see recaptcha_admin_settings()
|
90 |
|
|
*/
|
91 |
|
|
function recaptcha_admin_settings_validate($form, &$form_state) {
|
92 |
|
|
$tabindex = $form_state['values']['recaptcha_tabindex'];
|
93 |
be58a50c
|
Assos Assos
|
if (!is_numeric($tabindex)) {
|
94 |
|
|
form_set_error('recaptcha_tabindex', t('The tabindex must be an integer.'));
|
95 |
85ad3d82
|
Assos Assos
|
}
|
96 |
|
|
} |