Révision 7547bb19
Ajouté par Assos Assos il y a environ 7 ans
drupal7/sites/all/modules/captcha/captcha.module | ||
---|---|---|
157 | 157 |
'#process' => array('captcha_element_process'), |
158 | 158 |
// The type of challenge: e.g. 'default', 'none', 'captcha/Math', 'image_captcha/Image'. |
159 | 159 |
'#captcha_type' => 'default', |
160 |
// Forces captcha validation for all cases if TRUE. |
|
161 |
'#captcha_always' => FALSE, |
|
160 | 162 |
'#default_value' => '', |
161 | 163 |
// CAPTCHA in admin mode: presolve the CAPTCHA and always show it (despite previous successful responses). |
162 | 164 |
'#captcha_admin_mode' => FALSE, |
... | ... | |
179 | 181 |
|
180 | 182 |
module_load_include('inc', 'captcha'); |
181 | 183 |
|
182 |
// Add Javascript for general CAPTCHA functionality.
|
|
184 |
// Add JavaScript for general CAPTCHA functionality.
|
|
183 | 185 |
drupal_add_js(drupal_get_path('module', 'captcha') . '/captcha.js'); |
184 | 186 |
|
185 | 187 |
// Prevent caching of the page with CAPTCHA elements. |
186 | 188 |
// This needs to be done even if the CAPTCHA will be ommitted later: |
187 | 189 |
// other untrusted users should not get a cached page when |
188 | 190 |
// the current untrusted user can skip the current CAPTCHA. |
189 |
global $conf; |
|
190 |
$conf['cache'] = FALSE; |
|
191 |
drupal_page_is_cacheable(FALSE); |
|
191 | 192 |
|
192 | 193 |
// Get the form ID of the form we are currently processing (which is not |
193 | 194 |
// necessary the same form that is submitted (if any). |
... | ... | |
254 | 255 |
'captcha_sid' => $captcha_sid, |
255 | 256 |
); |
256 | 257 |
|
257 |
if (_captcha_required_for_user($captcha_sid, $this_form_id) || $element['#captcha_admin_mode']) { |
|
258 |
if (_captcha_required_for_user($captcha_sid, $this_form_id) || $element['#captcha_admin_mode'] || $element['#captcha_always']) {
|
|
258 | 259 |
// Generate a CAPTCHA and its solution |
259 | 260 |
// (note that the CAPTCHA session ID is given as third argument). |
260 | 261 |
$captcha = module_invoke($captcha_type_module, 'captcha', 'generate', $captcha_type_challenge, $captcha_sid); |
... | ... | |
594 | 595 |
* if the values could not be found, e.g. for a fresh form). |
595 | 596 |
*/ |
596 | 597 |
function _captcha_get_posted_captcha_info($element, $form_state, $this_form_id) { |
597 |
if ($form_state['submitted'] && isset($form_state['captcha_info'])) { |
|
598 |
//Handle Ajax scenarios |
|
599 |
if (!empty($form_state['rebuild_info'])) { |
|
600 |
if (!empty($form_state['captcha_info']['posted_form_id'])) { |
|
601 |
$posted_form_id = $form_state['captcha_info']['posted_form_id']; |
|
602 |
} |
|
603 |
else { |
|
604 |
$posted_form_id = $form_state['input']['form_id']; |
|
605 |
} |
|
606 |
|
|
607 |
$posted_captcha_sid = $form_state['captcha_info']['captcha_sid']; |
|
608 |
} |
|
609 |
else if ($form_state['submitted'] && isset($form_state['captcha_info'])) { |
|
598 | 610 |
// We are handling (or rebuilding) an already submitted form, |
599 | 611 |
// so we already determined the posted form ID and CAPTCHA session ID |
600 | 612 |
// for this form (from before submitting). Reuse this info. |
... | ... | |
764 | 776 |
// of multi-page forms. Take previewing a node submission for example: |
765 | 777 |
// when the challenge is solved correctely on preview, the form is still |
766 | 778 |
// not completely submitted, but the CAPTCHA can be skipped. |
767 |
if (_captcha_required_for_user($captcha_sid, $form_id) || $element['#captcha_admin_mode']) { |
|
779 |
if (_captcha_required_for_user($captcha_sid, $form_id) || $element['#captcha_admin_mode'] || $element['#captcha_always']) {
|
|
768 | 780 |
// Update captcha_sessions table: store the solution of the generated CAPTCHA. |
769 | 781 |
_captcha_update_captcha_session($captcha_sid, $captcha_info['solution']); |
770 | 782 |
|
Formats disponibles : Unified diff
Weekly update of contrib modules