allow_captcha()); } /** * Return an HTML string explaining $captchareason (from qa_user_captcha_reason()) to the user about why they are seeing a captcha * @param $captchareason * @return mixed|null|string */ function qa_captcha_reason_note($captchareason) { $notehtml = null; switch ($captchareason) { case 'login': $notehtml = qa_insert_login_links(qa_lang_html('misc/captcha_login_fix')); break; case 'confirm': $notehtml = qa_insert_login_links(qa_lang_html('misc/captcha_confirm_fix')); break; case 'approve': $notehtml = qa_lang_html('misc/captcha_approve_fix'); break; } return $notehtml; } /** * Prepare $qa_content for showing a captcha, adding the element to $fields, given previous $errors, and a $note to display. * Returns JavaScript required to load CAPTCHA when field is shown by user (e.g. clicking comment button). * @param $qa_content * @param $fields * @param $errors * @param $note * @return string */ function qa_set_up_captcha_field(&$qa_content, &$fields, $errors, $note = null) { if (!qa_captcha_available()) return ''; $captcha = qa_load_module('captcha', qa_opt('captcha_module')); // workaround for reCAPTCHA, to load multiple instances via JS $count = @++$qa_content['qa_captcha_count']; if ($count > 1) { // use blank captcha in order to load via JS $html = ''; } else { // first captcha is always loaded explicitly $qa_content['script_var']['qa_captcha_in'] = 'qa_captcha_div_1'; $html = $captcha->form_html($qa_content, @$errors['captcha']); } $fields['captcha'] = array( 'type' => 'custom', 'label' => qa_lang_html('misc/captcha_label'), 'html' => '