hiragana_captcha.admin.inc 6.x-1.x head
<?php
// $Id: hiragana_captcha.admin.inc,v 1.0 2008/06/29 0829 Exp $
/**
* Administration form.
*/
function hiragana_captcha_settings_form() {
$form = array();
$form['hiragana_captcha_words'] = array(
'#type' => 'fieldset',
'#title' => t('Words settings'),
'#description' => t('Input the generated word length and number of words in the phrase for hiragana CAPTCHA.'),
);
$form['hiragana_captcha_words']['hiragana_captcha_length_min'] = array(
'#type' => 'textfield',
'#title' => t('Minimum number of characters'),
'#default_value' => variable_get('hiragana_captcha_length_min', 3),
'#size' => 2,
'#maxlength' => 2,
);
$form['hiragana_captcha_words']['hiragana_captcha_length_max'] = array(
'#type' => 'textfield',
'#title' => t('Maximum number of characters'),
'#default_value' => variable_get('hiragana_captcha_length_max', 3),
'#size' => 2,
'#maxlength' => 2,
);
$form['hiragana_captcha_words']['hiragana_captcha_quantity'] = array(
'#type' => 'textfield',
'#title' => t('Number of words in the phrase'),
'#default_value' => variable_get('hiragana_captcha_quantity', 5),
'#size' => 2,
'#maxlength' => 2,
);
$form['#validate'][] = 'hiragana_captcha_settings_form_validate';
return system_settings_form($form);
}
/**
* Validate function of the administration form.
*/
function hiragana_captcha_settings_form_validate($form, &$form_state) {
if ($form_state['values']['hiragana_captcha_length_min'] < 1 || $form_state['values']['hiragana_captcha_length_max'] < 1) {
form_set_error('hiragana_captcha_length', t('Minimum and maximum number of characters should be more than \'1\'.'));
}
else if ($form_state['values']['hiragana_captcha_length_min'] > $form_state['values']['hiragana_captcha_length_max']) {
form_set_error('hiragana_captcha_length', t('Maximum number of characters should be more than minimum number of characters.'));
}
if ($form_state['values']['hiragana_captcha_quantity'] < 4 || $form_state['values']['hiragana_captcha_quantity'] > 10) {
form_set_error('hiragana_captcha_quantity', t('Number of words in the phrase should be between 4 and 10.'));
}
}
// $Id: hiragana_captcha.admin.inc,v 1.0 2008/06/29 0829 Exp $
/**
* Administration form.
*/
function hiragana_captcha_settings_form() {
$form = array();
$form['hiragana_captcha_words'] = array(
'#type' => 'fieldset',
'#title' => t('Words settings'),
'#description' => t('Input the generated word length and number of words in the phrase for hiragana CAPTCHA.'),
);
$form['hiragana_captcha_words']['hiragana_captcha_length_min'] = array(
'#type' => 'textfield',
'#title' => t('Minimum number of characters'),
'#default_value' => variable_get('hiragana_captcha_length_min', 3),
'#size' => 2,
'#maxlength' => 2,
);
$form['hiragana_captcha_words']['hiragana_captcha_length_max'] = array(
'#type' => 'textfield',
'#title' => t('Maximum number of characters'),
'#default_value' => variable_get('hiragana_captcha_length_max', 3),
'#size' => 2,
'#maxlength' => 2,
);
$form['hiragana_captcha_words']['hiragana_captcha_quantity'] = array(
'#type' => 'textfield',
'#title' => t('Number of words in the phrase'),
'#default_value' => variable_get('hiragana_captcha_quantity', 5),
'#size' => 2,
'#maxlength' => 2,
);
$form['#validate'][] = 'hiragana_captcha_settings_form_validate';
return system_settings_form($form);
}
/**
* Validate function of the administration form.
*/
function hiragana_captcha_settings_form_validate($form, &$form_state) {
if ($form_state['values']['hiragana_captcha_length_min'] < 1 || $form_state['values']['hiragana_captcha_length_max'] < 1) {
form_set_error('hiragana_captcha_length', t('Minimum and maximum number of characters should be more than \'1\'.'));
}
else if ($form_state['values']['hiragana_captcha_length_min'] > $form_state['values']['hiragana_captcha_length_max']) {
form_set_error('hiragana_captcha_length', t('Maximum number of characters should be more than minimum number of characters.'));
}
if ($form_state['values']['hiragana_captcha_quantity'] < 4 || $form_state['values']['hiragana_captcha_quantity'] > 10) {
form_set_error('hiragana_captcha_quantity', t('Number of words in the phrase should be between 4 and 10.'));
}
}

