function qa_page_q_add_c_form(&$qa_content, $questionid, $parentid, $formid, $usecaptcha, $in, $errors, $loadfocusnow) { switch (qa_user_permit_error('permit_post_c')) { case 'login': $form = array('title' => qa_insert_login_links(qa_lang_html('question/comment_must_login'), qa_request())); break; case 'confirm': $form = array('title' => qa_insert_login_links(qa_lang_html('question/comment_must_confirm'), qa_request())); break; case 'limit': $form = array('title' => qa_lang_html('question/comment_limit')); break; default: $form = array('title' => qa_lang_html('users/no_permission')); break; case false: $prefix = 'c' . $parentid . '_'; $editorname = isset($in['editor']) ? $in['editor'] : qa_opt('editor_for_cs'); $editor = qa_load_editor(@$in['content'], @$in['format'], $editorname); if (method_exists($editor, 'update_script')) { $updatescript = $editor->update_script($prefix . 'content'); } else { $updatescript = ''; } $custom = qa_opt('show_custom_comment') ? trim(qa_opt('custom_comment')) : ''; $form = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '" NAME="c_form_' . qa_html($parentid) . '"', 'title' => qa_lang_html($questionid == $parentid ? 'question/your_comment_q' : 'question/your_comment_a'), 'fields' => array('custom' => array('type' => 'custom', 'note' => $custom), 'content' => array_merge(qa_editor_load_field($editor, $qa_content, @$in['content'], @$in['format'], $prefix . 'content', 4, $loadfocusnow, $loadfocusnow), array('error' => qa_html(@$errors['content'])))), 'buttons' => array('comment' => array('tags' => 'onClick="' . $updatescript . ' return qa_submit_comment(' . qa_js($questionid) . ', ' . qa_js($parentid) . ', this);"', 'label' => qa_lang_html('question/add_comment_button')), 'cancel' => array('tags' => 'NAME="docancel"', 'label' => qa_lang_html('main/cancel_button'))), 'hidden' => array($prefix . 'editor' => qa_html($editorname), $prefix . 'doadd' => '1')); if (!strlen($custom)) { unset($form['fields']['custom']); } qa_set_up_notify_fields($qa_content, $form['fields'], 'C', qa_get_logged_in_email(), isset($in['notify']) ? $in['notify'] : qa_opt('notify_users_default'), $in['email'], @$errors['email'], $prefix); $onloads = array(); if ($usecaptcha) { $userid = qa_get_logged_in_userid(); $captchaloadscript = qa_set_up_captcha_field($qa_content, $form['fields'], $errors, qa_insert_login_links(qa_lang_html(isset($userid) ? 'misc/captcha_confirm_fix' : 'misc/captcha_login_fix'))); if (strlen($captchaloadscript)) { $onloads[] = 'document.getElementById(' . qa_js($formid) . ').qa_show=function() { ' . $captchaloadscript . ' }'; } } if (!$loadfocusnow) { if (method_exists($editor, 'load_script')) { $onloads[] = 'document.getElementById(' . qa_js($formid) . ').qa_load=function() { ' . $editor->load_script($prefix . 'content') . ' }'; } if (method_exists($editor, 'focus_script')) { $onloads[] = 'document.getElementById(' . qa_js($formid) . ').qa_focus=function() { ' . $editor->focus_script($prefix . 'content') . ' }'; } $form['buttons']['cancel']['tags'] .= ' onClick="return qa_toggle_element()"'; } if (count($onloads)) { $qa_content['script_onloads'][] = $onloads; } } $form['id'] = $formid; $form['collapse'] = !$loadfocusnow; $form['style'] = 'tall'; return $form; }
if (qa_using_categories() && count($categories)) { $field = array('label' => qa_lang_html('question/q_category_label'), 'error' => qa_html(@$errors['categoryid'])); qa_set_up_category_field($qa_content, $field, 'category', $categories, $in['categoryid'], true, qa_opt('allow_no_sub_category')); if (!qa_opt('allow_no_category')) { // don't auto-select a category even though one is required $field['options'][''] = ''; } qa_array_insert($qa_content['form']['fields'], 'content', array('category' => $field)); } if (qa_opt('extra_field_active')) { $field = array('label' => qa_html(qa_opt('extra_field_prompt')), 'tags' => 'name="extra"', 'value' => qa_html(@$in['extra']), 'error' => qa_html(@$errors['extra'])); qa_array_insert($qa_content['form']['fields'], null, array('extra' => $field)); } if (qa_using_tags()) { $field = array('error' => qa_html(@$errors['tags'])); qa_set_up_tag_field($qa_content, $field, 'tags', isset($in['tags']) ? $in['tags'] : array(), array(), qa_opt('do_complete_tags') ? array_keys($completetags) : array(), qa_opt('page_size_ask_tags')); qa_array_insert($qa_content['form']['fields'], null, array('tags' => $field)); } if (!isset($userid)) { qa_set_up_name_field($qa_content, $qa_content['form']['fields'], @$in['name']); } qa_set_up_notify_fields($qa_content, $qa_content['form']['fields'], 'Q', qa_get_logged_in_email(), isset($in['notify']) ? $in['notify'] : qa_opt('notify_users_default'), @$in['email'], @$errors['email']); if ($captchareason) { require_once 'qa-app-captcha.php'; qa_set_up_captcha_field($qa_content, $qa_content['form']['fields'], @$errors, qa_captcha_reason_note($captchareason)); } $qa_content['focusid'] = 'title'; return $qa_content; /* Omit PHP closing tag to help avoid accidental output */
} if (count($matchusers) != 1) { // if we get more than one match (should be impossible) also give an error $errors['emailhandle'] = qa_lang('users/user_not_found'); } if (qa_opt('captcha_on_reset_password')) { qa_captcha_validate_post($errors); } if (empty($errors)) { $inuserid = $matchusers[0]; qa_start_reset_user($inuserid); qa_redirect('reset', $passemailhandle ? array('e' => $inemailhandle) : null); // redirect to page where code is entered } } } else { $inemailhandle = qa_get('e'); } // Prepare content for theme $qa_content = qa_content_prepare(); $qa_content['title'] = qa_lang_html('users/reset_title'); $qa_content['error'] = @$errors['page']; $qa_content['form'] = array('tags' => 'method="post" action="' . qa_self_html() . '"', 'style' => 'tall', 'fields' => array('email_handle' => array('label' => qa_lang_html('users/email_handle_label'), 'tags' => 'name="emailhandle" id="emailhandle"', 'value' => qa_html(@$inemailhandle), 'error' => qa_html(@$errors['emailhandle']), 'note' => qa_lang_html('users/send_reset_note'))), 'buttons' => array('send' => array('label' => qa_lang_html('users/send_reset_button'))), 'hidden' => array('doforgot' => '1', 'code' => qa_get_form_security_code('forgot'))); if (qa_opt('captcha_on_reset_password')) { qa_set_up_captcha_field($qa_content, $qa_content['form']['fields'], @$errors); } $qa_content['focusid'] = 'emailhandle'; return $qa_content; /* Omit PHP closing tag to help avoid accidental output */
$field = array('type' => 'static', 'label' => qa_lang_html('question/ask_follow_from_a'), 'value' => $viewer->get_html($followanswer['content'], $followanswer['format'], array('blockwordspreg' => qa_get_block_words_preg()))); qa_array_insert($qa_content['form']['fields'], 'title', array('follows' => $field)); } if (qa_using_categories() && count($categories)) { $field = array('label' => qa_lang_html('question/q_category_label'), 'error' => qa_html(@$errors['categoryid'])); qa_set_up_category_field($qa_content, $field, 'category', $categories, $in['categoryid'], true, qa_opt('allow_no_sub_category')); if (!qa_opt('allow_no_category')) { // don't auto-select a category even though one is required $field['options'][''] = ''; } qa_array_insert($qa_content['form']['fields'], 'content', array('category' => $field)); } if (qa_opt('extra_field_active')) { $field = array('label' => qa_html(qa_opt('extra_field_prompt')), 'tags' => 'NAME="extra"', 'value' => qa_html(@$in['extra']), 'error' => qa_html(@$errors['extra'])); qa_array_insert($qa_content['form']['fields'], null, array('extra' => $field)); } if (qa_using_tags()) { $field = array('error' => qa_html(@$errors['tags'])); qa_set_up_tag_field($qa_content, $field, 'tags', isset($in['tags']) ? $in['tags'] : array(), array(), qa_opt('do_complete_tags') ? array_keys($completetags) : array(), qa_opt('page_size_ask_tags')); qa_array_insert($qa_content['form']['fields'], null, array('tags' => $field)); } qa_set_up_notify_fields($qa_content, $qa_content['form']['fields'], 'Q', qa_get_logged_in_email(), isset($in['notify']) ? $in['notify'] : qa_opt('notify_users_default'), @$in['email'], @$errors['email']); if ($usecaptcha) { require_once 'qa-app-captcha.php'; qa_set_up_captcha_field($qa_content, $qa_content['form']['fields'], @$errors, qa_insert_login_links(qa_lang_html(isset($userid) ? 'misc/captcha_confirm_fix' : 'misc/captcha_login_fix'))); } $qa_content['focusid'] = 'title'; return $qa_content; /* Omit PHP closing tag to help avoid accidental output */
function qa_page_q_add_c_form(&$qa_content, $question, $parent, $formid, $captchareason, $in, $errors, $loadfocusnow) { // The 'approve', 'login', 'confirm', 'userblock', 'ipblock' permission errors are reported to the user here // The other option ('level') prevents the comment button being shown, in qa_page_q_post_rules(...) switch (qa_user_post_permit_error('permit_post_c', $parent, QA_LIMIT_COMMENTS)) { case 'login': $form = array('title' => qa_insert_login_links(qa_lang_html('question/comment_must_login'), qa_request())); break; case 'confirm': $form = array('title' => qa_insert_login_links(qa_lang_html('question/comment_must_confirm'), qa_request())); break; case 'approve': $form = array('title' => qa_lang_html('question/comment_must_be_approved')); break; case 'limit': $form = array('title' => qa_lang_html('question/comment_limit')); break; default: $form = array('title' => qa_lang_html('users/no_permission')); break; case false: $prefix = 'c' . $parent['postid'] . '_'; $editorname = isset($in['editor']) ? $in['editor'] : qa_opt('editor_for_cs'); $editor = qa_load_editor(@$in['content'], @$in['format'], $editorname); if (method_exists($editor, 'update_script')) { $updatescript = $editor->update_script($prefix . 'content'); } else { $updatescript = ''; } $custom = qa_opt('show_custom_comment') ? trim(qa_opt('custom_comment')) : ''; $form = array('tags' => 'method="post" action="' . qa_self_html() . '" name="c_form_' . qa_html($parent['postid']) . '"', 'title' => qa_lang_html($question['postid'] == $parent['postid'] ? 'question/your_comment_q' : 'question/your_comment_a'), 'fields' => array('custom' => array('type' => 'custom', 'note' => $custom), 'content' => array_merge(qa_editor_load_field($editor, $qa_content, @$in['content'], @$in['format'], $prefix . 'content', 4, $loadfocusnow, $loadfocusnow), array('error' => qa_html(@$errors['content'])))), 'buttons' => array('comment' => array('tags' => 'onclick="' . $updatescript . ' return qa_submit_comment(' . qa_js($question['postid']) . ', ' . qa_js($parent['postid']) . ', this);"', 'label' => qa_lang_html('question/add_comment_button')), 'cancel' => array('tags' => 'name="docancel"', 'label' => qa_lang_html('main/cancel_button'))), 'hidden' => array($prefix . 'editor' => qa_html($editorname), $prefix . 'doadd' => '1', $prefix . 'code' => qa_get_form_security_code('comment-' . $parent['postid']))); if (!strlen($custom)) { unset($form['fields']['custom']); } if (!qa_is_logged_in()) { qa_set_up_name_field($qa_content, $form['fields'], @$in['name'], $prefix); } qa_set_up_notify_fields($qa_content, $form['fields'], 'C', qa_get_logged_in_email(), isset($in['notify']) ? $in['notify'] : qa_opt('notify_users_default'), $in['email'], @$errors['email'], $prefix); $onloads = array(); if ($captchareason) { $captchaloadscript = qa_set_up_captcha_field($qa_content, $form['fields'], $errors, qa_captcha_reason_note($captchareason)); if (strlen($captchaloadscript)) { $onloads[] = 'document.getElementById(' . qa_js($formid) . ').qa_show=function() { ' . $captchaloadscript . ' };'; } } if (!$loadfocusnow) { if (method_exists($editor, 'load_script')) { $onloads[] = 'document.getElementById(' . qa_js($formid) . ').qa_load=function() { ' . $editor->load_script($prefix . 'content') . ' };'; } if (method_exists($editor, 'focus_script')) { $onloads[] = 'document.getElementById(' . qa_js($formid) . ').qa_focus=function() { ' . $editor->focus_script($prefix . 'content') . ' };'; } $form['buttons']['cancel']['tags'] .= ' onclick="return qa_toggle_element()"'; } if (count($onloads)) { $qa_content['script_onloads'][] = $onloads; } } $form['id'] = $formid; $form['collapse'] = !$loadfocusnow; $form['style'] = 'tall'; return $form; }
function qa_ajax_comment_form() { global $qa_content, $incomment, $informat, $errors, $questionid, $ineditor, $innotify, $inemail, $jumptoanchor, $focusonid, $usecaptcha, $qa_login_userid; $jumptoanchor = isset($answerid) ? qa_anchor('A', $answerid) : qa_anchor('Q', $questionid); $focusonid = 'comment'; $editorname = isset($ineditor) ? $ineditor : qa_opt('editor_for_cs'); $editor = qa_load_editor(@$incomment, @$informat, $editorname); $form = array('title' => qa_lang_html(isset($answerid) ? 'question/your_comment_a' : 'question/your_comment_q'), 'style' => 'tall', 'fields' => array('content' => array_merge($editor->get_field($qa_content, @$incomment, @$informat, 'comment', 4, true), array('error' => qa_html(@$errors['content']), 'rows' => 8))), 'buttons' => array('comment' => array('tags' => 'onclick="ajaxPostComment()"', 'label' => qa_lang_html('question/add_comment_button'), 'ajax_comment' => $this->idx2), 'cancel' => array('tags' => 'NAME="docancel"', 'label' => qa_lang_html('main/cancel_button'), 'ajax_comment' => $this->idx2)), 'hidden' => array('editor' => qa_html($editorname))); $form['fields']['content']['tags'] = @$form['fields']['tags'] . ' id="comment" onkeydown="if(event.keyCode == 27) toggleComment(false);"'; // add reminder text if commenting on answer to own question $ourid = qa_get_logged_in_userid(); if (qa_opt('ajax_comment_answer_reminder') && !$this->content['q_view']['raw']['selchildid'] && isset($answerid) && $this->content['q_view']['raw']['userid'] == $ourid && @$this->content['a_list']['as'][$this->idx - 1]['raw']['userid'] != $ourid) { $form['fields']['custom_message'] = array('note' => '<div class="ajax-comment-reminder">' . qa_opt('ajax_comment_answer_reminder_text') . '</div>', 'type' => 'static'); } qa_set_up_notify_fields($qa_content, $form['fields'], 'C', qa_get_logged_in_email(), isset($innotify) ? $innotify : qa_opt('notify_users_default'), @$inemail, @$errors['email']); if ($usecaptcha) { qa_set_up_captcha_field($qa_content, $form['fields'], @$errors, qa_insert_login_links(qa_lang_html(isset($qa_login_userid) ? 'misc/captcha_confirm_fix' : 'misc/captcha_login_fix'))); } $form['ajax_comment'] = 0; $this->idx2++; return $form; }
function qa_page_q_add_c_form($answerid) { global $qa_content, $incomment, $informat, $errors, $questionid, $ineditor, $innotify, $inemail, $jumptoanchor, $focusonid, $usecaptcha, $qa_login_userid; $jumptoanchor = isset($answerid) ? qa_anchor('A', $answerid) : qa_anchor('Q', $questionid); $focusonid = 'comment'; $editorname = isset($ineditor) ? $ineditor : qa_opt('editor_for_cs'); $editor = qa_load_editor(@$incomment, @$informat, $editorname); $form = array('title' => qa_lang_html(isset($answerid) ? 'question/your_comment_a' : 'question/your_comment_q'), 'style' => 'tall', 'fields' => array('content' => array_merge($editor->get_field($qa_content, @$incomment, @$informat, 'comment', 4, true), array('error' => qa_html(@$errors['content'])))), 'buttons' => array('comment' => array('tags' => 'NAME="' . (isset($answerid) ? 'docommentadda_' . $answerid : 'docommentaddq') . '"', 'label' => qa_lang_html('question/add_comment_button')), 'cancel' => array('tags' => 'NAME="docancel"', 'label' => qa_lang_html('main/cancel_button'))), 'hidden' => array('editor' => qa_html($editorname))); qa_set_up_notify_fields($qa_content, $form['fields'], 'C', qa_get_logged_in_email(), isset($innotify) ? $innotify : qa_opt('notify_users_default'), @$inemail, @$errors['email']); if ($usecaptcha) { qa_set_up_captcha_field($qa_content, $form['fields'], @$errors, qa_insert_login_links(qa_lang_html(isset($qa_login_userid) ? 'misc/captcha_confirm_fix' : 'misc/captcha_login_fix'))); } return $form; }