function qa_question_set_content($oldquestion, $title, $content, $format, $text, $tagstring, $notify, $userid, $handle, $cookieid, $extravalue = null, $name = null, $remoderate = false, $silent = false) { qa_post_unindex($oldquestion['postid']); $wasqueued = $oldquestion['type'] == 'Q_QUEUED'; $titlechanged = strcmp($oldquestion['title'], $title) ? true : false; $contentchanged = strcmp($oldquestion['content'], $content) || strcmp($oldquestion['format'], $format); $tagschanged = strcmp($oldquestion['tags'], $tagstring) ? true : false; $setupdated = ($titlechanged || $contentchanged || $tagschanged) && !$wasqueued && !$silent; qa_db_post_set_content($oldquestion['postid'], $title, $content, $format, $tagstring, $notify, $setupdated ? $userid : null, $setupdated ? qa_remote_ip_address() : null, $titlechanged || $contentchanged ? QA_UPDATE_CONTENT : QA_UPDATE_TAGS, $name); if (isset($extravalue)) { require_once QA_INCLUDE_DIR . 'qa-db-metas.php'; qa_db_postmeta_set($oldquestion['postid'], 'qa_q_extra', $extravalue); } if ($setupdated && $remoderate) { require_once QA_INCLUDE_DIR . 'qa-app-posts.php'; $answers = qa_post_get_question_answers($oldquestion['postid']); $commentsfollows = qa_post_get_question_commentsfollows($oldquestion['postid']); $closepost = qa_post_get_question_closepost($oldquestion['postid']); foreach ($answers as $answer) { qa_post_unindex($answer['postid']); } foreach ($commentsfollows as $comment) { if ($comment['basetype'] == 'C') { qa_post_unindex($comment['postid']); } } if (@$closepost['parentid'] == $oldquestion['postid']) { qa_post_unindex($closepost['postid']); } qa_db_post_set_type($oldquestion['postid'], 'Q_QUEUED'); qa_update_counts_for_q($oldquestion['postid']); qa_db_queuedcount_update(); qa_db_points_update_ifuser($oldquestion['userid'], array('qposts', 'aselects')); if ($oldquestion['flagcount']) { qa_db_flaggedcount_update(); } } elseif ($oldquestion['type'] == 'Q') { // not hidden or queued qa_post_index($oldquestion['postid'], 'Q', $oldquestion['postid'], $oldquestion['parentid'], $title, $content, $format, $text, $tagstring, $oldquestion['categoryid']); } $eventparams = array('postid' => $oldquestion['postid'], 'title' => $title, 'content' => $content, 'format' => $format, 'text' => $text, 'tags' => $tagstring, 'extra' => $extravalue, 'name' => $name, 'oldquestion' => $oldquestion); qa_report_event('q_edit', $userid, $handle, $cookieid, $eventparams + array('silent' => $silent, 'oldtitle' => $oldquestion['title'], 'oldcontent' => $oldquestion['content'], 'oldformat' => $oldquestion['format'], 'oldtags' => $oldquestion['tags'], 'titlechanged' => $titlechanged, 'contentchanged' => $contentchanged, 'tagschanged' => $tagschanged)); if ($setupdated && $remoderate) { qa_report_event('q_requeue', $userid, $handle, $cookieid, $eventparams); } }
function process_event($event, $userid, $handle, $cookieid, $params) { switch ($event) { case 'q_queue': case 'q_post': case 'q_edit': //Save Selected Category if (qa_opt('it_cat_advanced_enable')) { $categories = explode(",", qa_post_text('q_category')); $category = $categories[0]; //qa_fatal_error(var_dump($category)); if (!empty($category)) { $this->AddCategoryToPost($params, $category); } } // Save Featured image if (qa_opt('it_feature_img_enable')) { $image = qa_post_text('featured_image'); $postid = $params['postid']; if (isset($image) && !empty($image)) { //save image qa_db_postmeta_set($postid, 'et_featured_image', $image); } else { // remove image from db qa_db_postmeta_clear($postid, 'et_featured_image'); // remove image file $output_dir = QA_BLOBS_DIRECTORY . "featured/"; $filePath = $output_dir . $image; if (file_exists($filePath)) { unlink($filePath); } } } // Save Excerpt if (qa_opt('it_excerpt_field_enable')) { $excerpt = qa_post_text('q-excerpt'); if (empty($excerpt)) { qa_db_postmeta_clear($postid, 'et_excerpt_text'); } else { qa_db_postmeta_set($postid, 'et_excerpt_text', $excerpt); } } break; } }
function qa_question_set_content($oldquestion, $title, $content, $format, $text, $tagstring, $notify, $userid, $handle, $cookieid, $extravalue = null) { qa_post_unindex($oldquestion['postid']); $titlechanged = strcmp($oldquestion['title'], $title) ? true : false; $contentchanged = strcmp($oldquestion['content'], $content) || strcmp($oldquestion['format'], $format); $tagschanged = strcmp($oldquestion['tags'], $tagstring) ? true : false; $setupdated = $titlechanged || $contentchanged || $tagschanged; qa_db_post_set_content($oldquestion['postid'], $title, $content, $format, $tagstring, $notify, $setupdated ? $userid : null, $setupdated ? qa_remote_ip_address() : null, $titlechanged || $contentchanged ? QA_UPDATE_CONTENT : QA_UPDATE_TAGS); if (isset($extravalue)) { require_once QA_INCLUDE_DIR . 'qa-db-metas.php'; qa_db_postmeta_set($oldquestion['postid'], 'qa_q_extra', $extravalue); } if ($oldquestion['type'] == 'Q') { // not hidden or queued qa_post_index($oldquestion['postid'], 'Q', $oldquestion['postid'], $oldquestion['parentid'], $title, $content, $format, $text, $tagstring, $oldquestion['categoryid']); } qa_report_event('q_edit', $userid, $handle, $cookieid, array('postid' => $oldquestion['postid'], 'title' => $title, 'content' => $content, 'format' => $format, 'text' => $text, 'tags' => $tagstring, 'extra' => $extravalue, 'oldquestion' => $oldquestion, 'oldtitle' => $oldquestion['title'], 'oldcontent' => $oldquestion['content'], 'oldformat' => $oldquestion['format'], 'oldtags' => $oldquestion['tags'], 'titlechanged' => $titlechanged, 'contentchanged' => $contentchanged, 'tagschanged' => $tagschanged)); }
function qa_question_create($followanswer, $userid, $handle, $cookieid, $title, $content, $format, $text, $tagstring, $notify, $email, $categoryid = null, $extravalue = null, $queued = false, $name = null) { require_once QA_INCLUDE_DIR . 'db/selects.php'; $postid = qa_db_post_create($queued ? 'Q_QUEUED' : 'Q', @$followanswer['postid'], $userid, isset($userid) ? null : $cookieid, qa_remote_ip_address(), $title, $content, $format, $tagstring, qa_combine_notify_email($userid, $notify, $email), $categoryid, isset($userid) ? null : $name); if (isset($extravalue)) { require_once QA_INCLUDE_DIR . 'db/metas.php'; qa_db_postmeta_set($postid, 'qa_q_extra', $extravalue); } qa_db_posts_calc_category_path($postid); qa_db_hotness_update($postid); if ($queued) { qa_db_queuedcount_update(); } else { qa_post_index($postid, 'Q', $postid, @$followanswer['postid'], $title, $content, $format, $text, $tagstring, $categoryid); qa_update_counts_for_q($postid); qa_db_points_update_ifuser($userid, 'qposts'); } qa_report_event($queued ? 'q_queue' : 'q_post', $userid, $handle, $cookieid, array('postid' => $postid, 'parentid' => @$followanswer['postid'], 'parent' => $followanswer, 'title' => $title, 'content' => $content, 'format' => $format, 'text' => $text, 'tags' => $tagstring, 'categoryid' => $categoryid, 'extra' => $extravalue, 'name' => $name, 'notify' => $notify, 'email' => $email)); return $postid; }
function cs_ajax_set_question_featured() { require_once QA_INCLUDE_DIR . 'qa-db-metas.php'; $postid = @$this->content["q_view"]["raw"]["postid"]; if ($this->template == 'question' && qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) { if (!is_featured($postid)) { qa_db_postmeta_set($postid, 'featured_question', true); } else { qa_db_postmeta_clear($postid, 'featured_question'); } } die; }
header('Content-Type: text/plain; charset=utf-8'); // Ensure no PHP errors are shown in the Ajax response //@ini_set('display_errors', 0); // Load the Q2A base file which sets up a bunch of crucial functions require_once '../../qa-include/qa-base.php'; qa_report_process_stage('init_ajax'); // Get general Ajax parameters from the POST payload, and clear $_GET qa_set_request(qa_post_text('qa_request'), qa_post_text('qa_root')); require_once QA_INCLUDE_DIR . 'qa-app-options.php'; require_once QA_INCLUDE_DIR . 'qa-db-metas.php'; //require_once QA_INCLUDE_DIR.'qa-page.php'; //qa_set_template('qa'); $action = $_POST['action']; $data = $_POST['data']; $postid = $_POST['postid']; if ($action == 'meta-save') { if ($data == '{}' or $data == '') { qa_db_postmeta_clear($postid, 'useo-meta-info'); } else { qa_db_postmeta_set($postid, 'useo-meta-info', $data); } } elseif ($action == 'social-save') { if ($data == '{}' or $data == '') { qa_db_postmeta_clear($postid, 'useo-social-info'); } else { qa_db_postmeta_set($postid, 'useo-social-info', $data); } } /* Omit PHP closing tag to help avoid accidental output */