Commit d82603a5 authored by soxofaan's avatar soxofaan

solved some minor issues reported by coder module

parent 27f29200
......@@ -155,6 +155,8 @@ function captcha_admin_settings() {
'#type' => 'submit',
'#value' => t('Save'),
);
$form['#submit'][] = 'captcha_admin_settings_submit';
return $form;
}
......@@ -178,31 +180,29 @@ function theme_captcha_admin_settings_captcha_points($form) {
* Submission function for captcha_admin_settings form
*/
function captcha_admin_settings_submit($form, &$form_state) {
if ($form['form_id']['#value'] == 'captcha_admin_settings') {
variable_set('captcha_administration_mode', $form_state['values']['captcha_administration_mode']);
foreach ($form_state['values']['captcha_types'] as $captcha_point_form_id => $data) {
if ($data['captcha_type'] == 'none') {
db_query("UPDATE {captcha_points} SET module = NULL, type = NULL WHERE form_id = '%s'", $captcha_point_form_id);
}
else {
list($module, $type) = explode('/', $data['captcha_type']);
db_query("UPDATE {captcha_points} SET module = '%s', type = '%s' WHERE form_id = '%s'", $module, $type, $captcha_point_form_id);
}
}
// description stuff
if (module_exists('locale')) {
$langs = locale_language_list();
foreach ($langs as $lang_code => $lang_name) {
variable_set("captcha_description_$lang_code", $form_state['values']["captcha_description_$lang_code"]);
}
variable_set('captcha_administration_mode', $form_state['values']['captcha_administration_mode']);
foreach ($form_state['values']['captcha_types'] as $captcha_point_form_id => $data) {
if ($data['captcha_type'] == 'none') {
db_query("UPDATE {captcha_points} SET module = NULL, type = NULL WHERE form_id = '%s'", $captcha_point_form_id);
}
else {
variable_set('captcha_description', $form_state['values']['captcha_description']);
list($module, $type) = explode('/', $data['captcha_type']);
db_query("UPDATE {captcha_points} SET module = '%s', type = '%s' WHERE form_id = '%s'", $module, $type, $captcha_point_form_id);
}
variable_set('captcha_persistence', $form_state['values']['captcha_persistence']);
variable_set('captcha_log_wrong_responses', $form_state['values']['captcha_log_wrong_responses']);
drupal_set_message(t('The CAPTCHA settings were saved.'), 'status');
}
// description stuff
if (module_exists('locale')) {
$langs = locale_language_list();
foreach ($langs as $lang_code => $lang_name) {
variable_set("captcha_description_$lang_code", $form_state['values']["captcha_description_$lang_code"]);
}
}
else {
variable_set('captcha_description', $form_state['values']['captcha_description']);
}
variable_set('captcha_persistence', $form_state['values']['captcha_persistence']);
variable_set('captcha_log_wrong_responses', $form_state['values']['captcha_log_wrong_responses']);
drupal_set_message(t('The CAPTCHA settings were saved.'), 'status');
}
/**
......
......@@ -37,7 +37,7 @@ function captcha_help($path, $arg) {
case 'admin/user/captcha/captcha/settings':
$output = '<p>'. t('A CAPTCHA can be added to virtually each Drupal form. Some default forms are already provided in the form list, but arbitrary forms can be easily added and managed when the option "%adminlinks" is enabled.',
array('%adminlinks' => t('Add CAPTCHA administration links to forms'))) .'</p>';
$output .= '<p>' . t('Users with the "%skipcaptcha" <a href="@perm">permission</a> won\'t be offered a challenge. Be sure to grant this permission to the trusted users (e.g. site administrators). If you want to test a protected form, be sure to do it as a user without the "%skipcaptcha" permission (e.g. as anonymous user).',
$output .= '<p>'. t('Users with the "%skipcaptcha" <a href="@perm">permission</a> won\'t be offered a challenge. Be sure to grant this permission to the trusted users (e.g. site administrators). If you want to test a protected form, be sure to do it as a user without the "%skipcaptcha" permission (e.g. as anonymous user).',
array('%skipcaptcha' => 'skip CAPTCHA', '@perm' => url('admin/user/permissions'))) .'</p>';
return $output;
}
......@@ -304,7 +304,7 @@ function captcha_form_alter(&$form, $form_state, $form_id) {
function captcha_validate($form, &$form_state) {
// Get answer and preprocess if needed
$captcha_response = $form_state['values']['captcha_response'];
$captcha_info = $form['captcha_info']['#value'];
$captcha_info = $form_state['values']['captcha_info'];
if ($captcha_info['preprocess']) {
$captcha_response = module_invoke($captcha_info['module'], 'captcha', 'preprocess', $captcha_info['type'], $captcha_response);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment