comparison sites/all/modules/recaptcha/recaptcha.admin.inc @ 2:b74b41bb73f0

-- Google analytics module
author danieleb <danielebarchiesi@me.com>
date Thu, 22 Aug 2013 17:22:54 +0100
parents
children b28be78d8160
comparison
equal deleted inserted replaced
1:67ce89da90df 2:b74b41bb73f0
1 <?php
2
3 /**
4 * @file
5 * Provides the reCAPTCHA administration settings.
6 */
7
8 /**
9 * Form callback; administrative settings for reCaptcha.
10 */
11 function recaptcha_admin_settings() {
12 // Load the recaptcha library.
13 _recaptcha_load_library();
14
15 $form = array();
16 $form['recaptcha_public_key'] = array(
17 '#type' => 'textfield',
18 '#title' => t('Public Key'),
19 '#default_value' => variable_get('recaptcha_public_key', ''),
20 '#maxlength' => 40,
21 '#description' => t('The public key given to you when you <a href="@url" target="_blank">registered at reCAPTCHA.net</a>.', array('@url' => url(recaptcha_get_signup_url($_SERVER['SERVER_NAME'], variable_get('site_name', ''))))),
22 '#required' => TRUE,
23 );
24 $form['recaptcha_private_key'] = array(
25 '#type' => 'textfield',
26 '#title' => t('Private Key'),
27 '#default_value' => variable_get('recaptcha_private_key', ''),
28 '#maxlength' => 40,
29 '#description' => t('The private key given to you when you <a href="@url" target="_blank">registered at reCAPTCHA.net</a>.', array('@url' => url(recaptcha_get_signup_url($_SERVER['SERVER_NAME'], variable_get('site_name', ''))))),
30 '#required' => TRUE,
31 );
32 $form['recaptcha_ajax_api'] = array(
33 '#type' => 'checkbox',
34 '#title' => t('AJAX API'),
35 '#default_value' => variable_get('recaptcha_ajax_api', FALSE),
36 '#description' => t('Use the AJAX API to display reCAPTCHA.'),
37 );
38 $form['recaptcha_nocookies'] = array(
39 '#type' => 'checkbox',
40 '#title' => t('Disable Client-Side Cookies'),
41 '#default_value' => variable_get('recaptcha_nocookies', FALSE),
42 '#description' => t('Add flag to disable third-party cookies set by reCAPTCHA.'),
43 );
44 $form['recaptcha_theme_settings'] = array(
45 '#type' => 'fieldset',
46 '#title' => t('Theme Settings'),
47 '#collapsible' => TRUE,
48 '#collapsed' => TRUE,
49 );
50 $form['recaptcha_theme_settings']['recaptcha_theme'] = array(
51 '#type' => 'select',
52 '#title' => t('Theme'),
53 '#description' => t('Defines which theme to use for reCAPTCHA.'),
54 '#options' => array(
55 'red' => t('Red'),
56 'white' => t('White'),
57 'blackglass' => t('Black Glass'),
58 'clean' => t('Clean'),
59 'custom' => t('Custom'),
60 ),
61 '#default_value' => variable_get('recaptcha_theme', 'red'),
62 '#required' => TRUE,
63 );
64 $form['recaptcha_theme_settings']['recaptcha_tabindex'] = array(
65 '#type' => 'textfield',
66 '#title' => t('Tab Index'),
67 '#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')),
68 '#default_value' => variable_get('recaptcha_tabindex', ''),
69 '#size' => 4,
70 );
71
72 return system_settings_form($form);
73 }
74
75 /**
76 * Validation function for recaptcha_admin_settings().
77 *
78 * @see recaptcha_admin_settings()
79 */
80 function recaptcha_admin_settings_validate($form, &$form_state) {
81 $tabindex = $form_state['values']['recaptcha_tabindex'];
82 if (!empty($tabindex) && !is_numeric($tabindex)) {
83 form_set_error('recaptcha_tabindex', t('The Tab Index must be an integer.'));
84 }
85 }