Revision a8cee257
Added by Assos Assos almost 5 years ago
drupal7/sites/all/modules/captcha/captcha.admin.inc | ||
---|---|---|
44 | 44 |
// Use JavaScript for some added usability on admin form. |
45 | 45 |
drupal_add_js(drupal_get_path('module', 'captcha') . '/captcha.js'); |
46 | 46 |
|
47 |
// Load languages for configurable texts. |
|
48 |
if (module_exists('locale')) { |
|
49 |
$langs = locale_language_list(); |
|
50 |
} |
|
51 |
|
|
47 | 52 |
// Configuration of which forms to protect, with what challenge. |
48 | 53 |
$form['captcha_form_protection'] = array( |
49 | 54 |
'#type' => 'fieldset', |
... | ... | |
150 | 155 |
'#submit' => array('captcha_clear_captcha_placement_cache_submit'), |
151 | 156 |
); |
152 | 157 |
|
158 |
// Textfield(s) for editing the error message. |
|
159 |
if (module_exists('locale')) { |
|
160 |
$form['captcha_error_messages'] = array( |
|
161 |
'#type' => 'fieldset', |
|
162 |
'#title' => t('Error message'), |
|
163 |
'#description' => t('Message displayed when the CAPTCHA has not been solved. An empty entry will reset the error message to default.'), |
|
164 |
); |
|
165 |
foreach ($langs as $lang_code => $lang_name) { |
|
166 |
$form['captcha_error_messages']['captcha_error_message_' . $lang_code] = array( |
|
167 |
'#type' => 'textfield', |
|
168 |
'#title' => t('For language %lang_name (code %lang_code)', array('%lang_name' => $lang_name, '%lang_code' => $lang_code)), |
|
169 |
'#default_value' => _captcha_get_error_message($lang_code), |
|
170 |
'#maxlength' => 256, |
|
171 |
); |
|
172 |
} |
|
173 |
} |
|
174 |
else { |
|
175 |
$form['captcha_error_message'] = array( |
|
176 |
'#type' => 'textfield', |
|
177 |
'#title' => t('Error message'), |
|
178 |
'#description' => t('Message displayed when the CAPTCHA has not been solved. An empty entry will reset the error message to default.'), |
|
179 |
'#default_value' => _captcha_get_error_message(), |
|
180 |
'#maxlength' => 256, |
|
181 |
); |
|
182 |
} |
|
183 |
|
|
153 | 184 |
// Configuration option for adding a CAPTCHA description. |
154 | 185 |
$form['captcha_add_captcha_description'] = array( |
155 | 186 |
'#type' => 'checkbox', |
... | ... | |
159 | 190 |
); |
160 | 191 |
// Textfield(s) for the CAPTCHA description. |
161 | 192 |
if (module_exists('locale')) { |
162 |
$langs = locale_language_list(); |
|
163 | 193 |
$form['captcha_descriptions'] = array( |
164 | 194 |
'#type' => 'fieldset', |
165 | 195 |
'#title' => t('CAPTCHA description'), |
... | ... | |
286 | 316 |
variable_set('captcha_default_challenge', $form_state['values']['captcha_default_challenge']); |
287 | 317 |
variable_set('captcha_default_challenge_on_nonlisted_forms', $form_state['values']['captcha_default_challenge_on_nonlisted_forms']); |
288 | 318 |
|
319 |
// Load languages for configurable texts. |
|
320 |
if (module_exists('locale')) { |
|
321 |
$langs = locale_language_list(); |
|
322 |
} |
|
323 |
|
|
289 | 324 |
// Process CAPTCHA points. |
290 | 325 |
if (isset($form_state['values']['captcha_form_id_overview']['captcha_captcha_points'])) { |
291 | 326 |
// Load existing data. |
... | ... | |
320 | 355 |
drupal_set_message(t('Added CAPTCHA point.'), 'status'); |
321 | 356 |
} |
322 | 357 |
|
358 |
// Error message. |
|
359 |
if (module_exists('locale')) { |
|
360 |
foreach ($langs as $lang_code => $lang_name) { |
|
361 |
$description = $form_state['values']['captcha_error_message_' . $lang_code]; |
|
362 |
if ($description) { |
|
363 |
variable_set('captcha_error_message_' . $lang_code, $description); |
|
364 |
} |
|
365 |
else { |
|
366 |
variable_del('captcha_error_message_' . $lang_code); |
|
367 |
drupal_set_message(t('Reset of error message for language %language.', array('%language' => $lang_name)), 'status'); |
|
368 |
} |
|
369 |
} |
|
370 |
} |
|
371 |
else { |
|
372 |
$description = $form_state['values']['captcha_error_message']; |
|
373 |
if ($description) { |
|
374 |
variable_set('captcha_error_message', $description); |
|
375 |
} |
|
376 |
else { |
|
377 |
variable_del('captcha_error_message'); |
|
378 |
drupal_set_message(t('Reset of error message.'), 'status'); |
|
379 |
} |
|
380 |
} |
|
381 |
|
|
323 | 382 |
// CAPTCHA description stuff. |
324 | 383 |
variable_set('captcha_add_captcha_description', $form_state['values']['captcha_add_captcha_description']); |
325 | 384 |
// Save (or reset) the CAPTCHA descriptions. |
326 | 385 |
if (module_exists('locale')) { |
327 |
$langs = locale_language_list(); |
|
328 | 386 |
foreach ($langs as $lang_code => $lang_name) { |
329 | 387 |
$description = $form_state['values']["captcha_description_$lang_code"]; |
330 | 388 |
if ($description) { |
Also available in: Unified diff
Weekly update of contrib modules