function qa_post_create($type, $parentid, $title, $content, $format = '', $categoryid = null, $tags = null, $userid = null, $notify = null, $email = null, $extravalue = null) { $handle = qa_post_userid_to_handle($userid); $text = qa_post_content_to_text($content, $format); switch ($type) { case 'Q': case 'Q_QUEUED': $followanswer = isset($parentid) ? qa_post_get_full($parentid, 'A') : null; $tagstring = qa_post_tags_to_tagstring($tags); $postid = qa_question_create($followanswer, $userid, $handle, null, $title, $content, $format, $text, $tagstring, $notify, $email, $categoryid, $extravalue, $type == 'Q_QUEUED'); break; case 'A': case 'A_QUEUED': $question = qa_post_get_full($parentid, 'Q'); $postid = qa_answer_create($userid, $handle, null, $content, $format, $text, $notify, $email, $question, $type == 'A_QUEUED'); break; case 'C': case 'C_QUEUED': $parent = qa_post_get_full($parentid, 'QA'); $commentsfollows = qa_db_single_select(qa_db_full_child_posts_selectspec(null, $parentid)); $question = qa_post_parent_to_question($parent); $postid = qa_comment_create($userid, $handle, null, $content, $format, $text, $notify, $email, $question, $parent, $commentsfollows, $type == 'C_QUEUED'); break; default: qa_fatal_error('Post type not recognized: ' . $type); break; } return $postid; }
$filtermodule->filter_question($in, $errors, null); qa_update_post_text($in, $oldin); } if (qa_using_categories() && count($categories) && !qa_opt('allow_no_category') && !isset($in['categoryid'])) { $errors['categoryid'] = qa_lang_html('question/category_required'); } elseif (qa_user_permit_error('permit_post_q', null, $userlevel)) { $errors['categoryid'] = qa_lang_html('question/category_ask_not_allowed'); } if ($captchareason) { require_once 'qa-app-captcha.php'; qa_captcha_validate_post($errors); } if (empty($errors)) { $cookieid = isset($userid) ? qa_cookie_get() : qa_cookie_get_create(); // create a new cookie if necessary $questionid = qa_question_create($followanswer, $userid, qa_get_logged_in_handle(), $cookieid, $in['title'], $in['content'], $in['format'], $in['text'], qa_tags_to_tagstring($in['tags']), $in['notify'], $in['email'], $in['categoryid'], $in['extra'], $in['queued'], $in['name']); qa_redirect(qa_q_request($questionid, $in['title'])); // our work is done here } } } // Prepare content for theme $qa_content = qa_content_prepare(false, array_keys(qa_category_path($categories, @$in['categoryid']))); $qa_content['title'] = qa_lang_html(isset($followanswer) ? 'question/ask_follow_title' : 'question/ask_title'); $qa_content['error'] = @$errors['page']; $editorname = isset($in['editor']) ? $in['editor'] : qa_opt('editor_for_qs'); $editor = qa_load_editor(@$in['content'], @$in['format'], $editorname); $field = qa_editor_load_field($editor, $qa_content, @$in['content'], @$in['format'], 'content', 12, false); $field['label'] = qa_lang_html('question/q_content_label'); $field['error'] = qa_html(@$errors['content']); $custom = qa_opt('show_custom_ask') ? trim(qa_opt('custom_ask')) : '';
qa_get_post_content('editor', 'content', $ineditor, $incontent, $informat, $intext); $tagstring = qa_tags_to_tagstring($intags); $errors = qa_question_validate($intitle, $incontent, $informat, $intext, $tagstring, $innotify, $inemail); if (qa_using_categories() && count($categories) && !qa_opt('allow_no_category') && !isset($incategoryid)) { $errors['category'] = qa_lang_html('question/category_required'); } if ($usecaptcha) { require_once 'qa-app-captcha.php'; qa_captcha_validate($_POST, $errors); } if (empty($errors)) { if (!isset($qa_login_userid)) { $qa_cookieid = qa_cookie_get_create(); } // create a new cookie if necessary $questionid = qa_question_create($followanswer, $qa_login_userid, qa_get_logged_in_handle(), $qa_cookieid, $intitle, $incontent, $informat, $intext, $tagstring, $innotify, $inemail, $incategoryid); qa_report_write_action($qa_login_userid, $qa_cookieid, 'q_post', $questionid, null, null); qa_redirect(qa_q_request($questionid, $intitle)); // our work is done here } } // Prepare content for theme $qa_content = qa_content_prepare(false, array_keys(qa_category_path($categories, @$incategoryid))); $qa_content['title'] = qa_lang_html(isset($followanswer) ? 'question/ask_follow_title' : 'question/ask_title'); $editorname = isset($ineditor) ? $ineditor : qa_opt('editor_for_qs'); $editor = qa_load_editor(@$incontent, @$informat, $editorname); // MP: find category title $categoryinfo = mp_get_categoryinfo(mp_get_categoryid()); $qa_content['form'] = array('tags' => 'NAME="ask" METHOD="POST" ACTION="' . qa_self_html() . '"', 'style' => 'tall', 'fields' => array('follows' => array(), 'title' => array('label' => qa_lang_html('question/q_title_label'), 'tags' => 'NAME="title" ID="title" AUTOCOMPLETE="off"', 'value' => qa_html(@$intitle), 'error' => qa_html(@$errors['title'])), 'similar' => array('type' => 'custom', 'html' => '<SPAN ID="similar"></SPAN>'), 'categorylabel' => array('type' => 'static', 'label' => qa_lang_html('question/q_category_label'), 'error' => qa_html(@$errors['category']), 'value' => $categoryinfo['title']), 'content' => array_merge($editor->get_field($qa_content, @$incontent, @$informat, 'content', 12, false), array('label' => qa_lang_html('question/q_content_label'), 'error' => qa_html(@$errors['content']))), 'tags' => array('error' => qa_html(@$errors['tags']))), 'buttons' => array('ask' => array('label' => qa_lang_html('question/ask_button'))), 'hidden' => array('editor' => qa_html($editorname), 'doask' => '1', 'category' => mp_get_categoryid())); if (qa_opt('do_ask_check_qs') || qa_opt('do_example_tags')) { $qa_content['script_rel'][] = 'qa-content/qa-ask.js?' . QA_VERSION;