Commit 5f1b2ca1 authored by pvdjay's avatar pvdjay Committed by Fabiano Sant'Ana
Browse files

Issue #2955343 by pvdjay, Chris Matthews, wundo, alexharries: Backport base_form_id targeting to D7

parent c33a383c
...@@ -53,7 +53,7 @@ function captcha_admin_settings() { ...@@ -53,7 +53,7 @@ function captcha_admin_settings() {
$form['captcha_form_protection'] = array( $form['captcha_form_protection'] = array(
'#type' => 'fieldset', '#type' => 'fieldset',
'#title' => t('Form protection'), '#title' => t('Form protection'),
'#description' => t("Select the challenge type you want for each of the listed forms (identified by their so called <em>form_id</em>'s). You can easily add arbitrary forms with the textfield at the bottom of the table or with the help of the option <em>Add CAPTCHA administration links to forms</em> below."), '#description' => t("Select the challenge type you want for each of the listed forms (identified by their so called <em>form_id</em> or <em>base_form_id</em>). You can easily add arbitrary forms with the textfield at the bottom of the table or with the help of the option <em>Add CAPTCHA administration links to forms</em> below."),
); );
$form['captcha_form_protection']['captcha_default_challenge'] = array( $form['captcha_form_protection']['captcha_default_challenge'] = array(
'#type' => 'select', '#type' => 'select',
...@@ -454,7 +454,7 @@ function captcha_point_admin_form($form, $form_state, $captcha_point_form_id = N ...@@ -454,7 +454,7 @@ function captcha_point_admin_form($form, $form_state, $captcha_point_form_id = N
$form['captcha_point_form_id'] = array( $form['captcha_point_form_id'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Form ID'), '#title' => t('Form ID'),
'#description' => t('The Drupal form_id of the form to add the CAPTCHA to.'), '#description' => t('The Drupal form_id or base_form_id of the form to add the CAPTCHA to.'),
'#value' => check_plain($captcha_point_form_id), '#value' => check_plain($captcha_point_form_id),
'#disabled' => TRUE, '#disabled' => TRUE,
); );
...@@ -468,7 +468,7 @@ function captcha_point_admin_form($form, $form_state, $captcha_point_form_id = N ...@@ -468,7 +468,7 @@ function captcha_point_admin_form($form, $form_state, $captcha_point_form_id = N
$form['captcha_point_form_id'] = array( $form['captcha_point_form_id'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Form ID'), '#title' => t('Form ID'),
'#description' => t('The Drupal form_id of the form to add the CAPTCHA to.'), '#description' => t('The Drupal form_id or base_form_id of the form to add the CAPTCHA to.'),
); );
} }
// Select widget for CAPTCHA type. // Select widget for CAPTCHA type.
......
...@@ -403,6 +403,14 @@ function captcha_form_alter(&$form, &$form_state, $form_id) { ...@@ -403,6 +403,14 @@ function captcha_form_alter(&$form, &$form_state, $form_id) {
// Get CAPTCHA type and module for given form_id. // Get CAPTCHA type and module for given form_id.
$captcha_point = captcha_get_form_id_setting($form_id); $captcha_point = captcha_get_form_id_setting($form_id);
// If no captcha point found, check to see if there is a setting for the base form id
if (!$captcha_point) {
if (isset($form_state['build_info']['base_form_id'])) {
$captcha_point = captcha_get_form_id_setting($form_state['build_info']['base_form_id']);
}
}
if ($captcha_point && !empty($captcha_point->captcha_type)) { if ($captcha_point && !empty($captcha_point->captcha_type)) {
module_load_include('inc', 'captcha'); module_load_include('inc', 'captcha');
// Build CAPTCHA form element. // Build CAPTCHA form element.
......
Supports Markdown
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