Commit dd68633e authored by Chris Graham's avatar Chris Graham
Browse files

Fixed MANTIS-4269 (Decision Tree system needs to support CAPTCHA)

parent 8d57e2b2
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -59,6 +59,8 @@ if (is_guest()) {
    }
}

require_code('decision_tree');

$decision_tree = array(
    'start' => array(
        'title' => 'Contact request',
@@ -184,6 +186,7 @@ Ask us if you wanted to be listed as one of the [page=\"site:stars\"]Composr dev
                'required' => false,
            ),
        ) + $extra_brief_details,
        'needs_captcha' => ((addon_installed('captcha')) && (get_option('captcha_on_feedback') == '1') && (use_captcha())),
        'next' => build_url(array('page' => 'tickets', 'type' => 'post', 'ticket_type' => 'Job'), '_SEARCH'),
    ),

@@ -882,6 +885,7 @@ Ask us if you wanted to be listed as one of the [page=\"site:stars\"]Composr dev
                'required' => false,
            ),
        ),
        'needs_captcha' => ((addon_installed('captcha')) && (get_option('captcha_on_feedback') == '1') && (use_captcha())),
        'next' => build_url(array('page' => 'tickets', 'type' => 'post', 'ticket_type' => 'Project'), '_SEARCH'),
        'expects_parameters' => array(
            'title',
@@ -944,6 +948,7 @@ Ask us if you wanted to be listed as one of the [page=\"site:stars\"]Composr dev
                'required' => false,
            ),
        ) + $extra_brief_details,
        'needs_captcha' => ((addon_installed('captcha')) && (get_option('captcha_on_feedback') == '1') && (use_captcha())),
        'next' => build_url(array('page' => 'tickets', 'type' => 'post', 'ticket_type' => 'Installation'), '_SEARCH'),
    ),

@@ -1005,6 +1010,7 @@ Ask us if you wanted to be listed as one of the [page=\"site:stars\"]Composr dev
                'required' => true,
            ),
        ) + $extra_brief_details,
        'needs_captcha' => ((addon_installed('captcha')) && (get_option('captcha_on_feedback') == '1') && (use_captcha())),
        'next' => build_url(array('page' => 'tickets', 'type' => 'post', 'ticket_type' => 'Secondment'), '_SEARCH'),
    ),

@@ -1050,6 +1056,7 @@ Ask us if you wanted to be listed as one of the [page=\"site:stars\"]Composr dev
                'required' => false,
            ),
        ) + $extra_brief_details,
        'needs_captcha' => ((addon_installed('captcha')) && (get_option('captcha_on_feedback') == '1') && (use_captcha())),
        'next' => build_url(array('page' => 'tickets', 'type' => 'post', 'ticket_type' => 'Professional support'), '_SEARCH'),
    ),

@@ -1104,6 +1111,7 @@ Ask us if you wanted to be listed as one of the [page=\"site:stars\"]Composr dev
                'required' => false,
            ),
        ) + $extra_brief_details,
        'needs_captcha' => ((addon_installed('captcha')) && (get_option('captcha_on_feedback') == '1') && (use_captcha())),
        'next' => build_url(array('page' => 'tickets', 'type' => 'post', 'ticket_type' => 'Professional support'), '_SEARCH'),
    ),

@@ -1198,11 +1206,11 @@ Ask us if you wanted to be listed as one of the [page=\"site:stars\"]Composr dev
                'required' => false,
            ),
        ) + $extra_brief_details,
        'needs_captcha' => ((addon_installed('captcha')) && (get_option('captcha_on_feedback') == '1') && (use_captcha())),
        'next' => build_url(array('page' => 'tickets', 'type' => 'post', 'ticket_type' => 'Upgrade'), '_SEARCH'),
    ),
);

require_code('decision_tree');
$ob = new DecisionTree($decision_tree, 'start');
$tpl = $ob->run();
$tpl->evaluate_echo();
+16 −0
Original line number Diff line number Diff line
@@ -59,6 +59,18 @@ Other features
 - Actually 'inform'/'notice'/'warn' can take a 'next'-style array, in which case the messages are shown using JavaScript upon option selection
*/

/**
 * Standard code module initialisation function.
 *
 * @ignore
 */
function init__decision_tree()
{
    if (addon_installed('captcha')) {
        require_code('captcha');
    }
}

/**
 * Provide multi-screen (multi-form) decision trees.
 *
@@ -331,6 +343,10 @@ class DecisionTree
            }
        }

        if (!empty($details['needs_captcha'])) {
            $fields->attach(form_input_captcha());
        }

        $form_method = empty($details['form_method']) ? 'POST' : $details['form_method'];

        $hidden->attach(build_keep_post_fields(null, true));