diff --git a/captcha.module b/captcha.module index 329d2c3..0fcb175 100644 --- a/captcha.module +++ b/captcha.module @@ -308,10 +308,13 @@ function theme_captcha($element) { */ function captcha_form_alter(&$form, $form_state, $form_id) { - if (!user_access('skip CAPTCHA')) { - // Visitor does not have permission to skip CAPTCHAs. + if (arg(0) != 'admin' || variable_get('captcha_allow_on_admin_pages', FALSE)) { + module_load_include('inc', 'captcha'); + if (!user_access('skip CAPTCHA')) { + // Visitor does not have permission to skip the CAPTCHA + // Get CAPTCHA type and module for given form_id. $captcha_point = captcha_get_form_id_setting($form_id); if ($captcha_point && $captcha_point->captcha_type) { @@ -329,16 +332,10 @@ function captcha_form_alter(&$form, $form_state, $form_id) { // Get placement in form and insert in form. $captcha_placement = _captcha_get_captcha_placement($form_id, $form); _captcha_insert_captcha_element($form, $captcha_placement, $captcha_element); + } } - else if ( - variable_get('captcha_administration_mode', FALSE) - && user_access('administer CAPTCHA settings') - && (arg(0) != 'admin' || variable_get('captcha_allow_on_admin_pages', FALSE)) - ) { - // Add CAPTCHA administration tools. - module_load_include('inc', 'captcha'); - + else if (user_access('administer CAPTCHA settings') && variable_get('captcha_administration_mode', FALSE)) { $captcha_point = captcha_get_form_id_setting($form_id); // For administrators: show CAPTCHA info and offer link to configure it $captcha_element = array( @@ -395,8 +392,7 @@ function captcha_form_alter(&$form, $form_state, $form_id) { _captcha_insert_captcha_element($form, $captcha_placement, $captcha_element); } - - + } // Add a warning about caching on the Perfomance settings page. if ($form_id == 'system_performance_settings') { $form['page_cache']['cache']['#description'] .= '

' diff --git a/captcha.test b/captcha.test index c3d098f..4397a2d 100644 --- a/captcha.test +++ b/captcha.test @@ -373,24 +373,6 @@ class CaptchaTestCase extends CaptchaBaseWebTestCase { $this->assertCaptchaPresence(FALSE); } - - /** - * CAPTCHA should also be put on admin pages even if visitor - * has no access - */ - function testCaptchaOnLoginBlockOnAdminPagesIssue893810() { - // Set a CAPTCHA on login block form - captcha_set_form_id_setting('user_login_block', 'captcha/Math'); - - // Check if there is a CAPTCHA on home page. - $this->drupalGet('node'); - $this->assertCaptchaPresence(TRUE); - - // Check there is a CAPTCHA on "forbidden" admin pages - $this->drupalGet('admin'); - $this->assertCaptchaPresence(TRUE); - } - }