function qa_page_q_single_click_q($question, $answers, $commentsfollows, $closepost, &$error) { require_once QA_INCLUDE_DIR . 'qa-app-post-update.php'; require_once QA_INCLUDE_DIR . 'qa-app-limits.php'; $userid = qa_get_logged_in_userid(); $handle = qa_get_logged_in_handle(); $cookieid = qa_cookie_get(); if (qa_page_q_clicked('q_doreopen') && $question['reopenable']) { qa_question_close_clear($question, $closepost, $userid, $handle, $cookieid); return true; } if (qa_page_q_clicked('q_dohide') && $question['hideable'] || qa_page_q_clicked('q_doreject') && $question['moderatable']) { qa_question_set_hidden($question, true, $userid, $handle, $cookieid, $answers, $commentsfollows, $closepost); return true; } if (qa_page_q_clicked('q_doreshow') && $question['reshowable'] || qa_page_q_clicked('q_doapprove') && $question['moderatable']) { qa_question_set_hidden($question, false, $userid, $handle, $cookieid, $answers, $commentsfollows, $closepost); return true; } if (qa_page_q_clicked('q_doclaim') && $question['claimable']) { if (qa_limits_remaining($userid, QA_LIMIT_QUESTIONS)) { // already checked 'permit_post_q' qa_question_set_userid($question, $userid, $handle, $cookieid); return true; } else { $error = qa_lang_html('question/ask_limit'); } } if (qa_page_q_clicked('q_doflag') && $question['flagbutton']) { require_once QA_INCLUDE_DIR . 'qa-app-votes.php'; $error = qa_flag_error_html($question, $userid, qa_request()); if (!$error) { if (qa_flag_set_tohide($question, $userid, $handle, $cookieid, $question)) { qa_question_set_hidden($question, true, null, null, null, $answers, $commentsfollows, $closepost); } // hiding not really by this user so pass nulls return true; } } if (qa_page_q_clicked('q_dounflag') && $question['unflaggable']) { require_once QA_INCLUDE_DIR . 'qa-app-votes.php'; qa_flag_clear($question, $userid, $handle, $cookieid); return true; } if (qa_page_q_clicked('q_doclearflags') && $question['clearflaggable']) { require_once QA_INCLUDE_DIR . 'qa-app-votes.php'; qa_flags_clear_all($question, $userid, $handle, $cookieid); return true; } return false; }
function process_event($event, $userid, $handle, $cookieid, $params) { if (qa_opt('expert_question_enable')) { switch ($event) { case 'q_post': if (qa_post_text('is_expert_question') == 'yes' || in_array(qa_opt('expert_question_type'), array(1, 2)) && !qa_get_logged_in_userid() || qa_opt('expert_question_type') == 3) { require_once QA_INCLUDE_DIR . 'qa-app-post-update.php'; qa_question_set_hidden($params, true, $userid, $handle, $cookieid, array(), array()); qa_db_query_sub('CREATE TABLE IF NOT EXISTS ^postmeta ( meta_id bigint(20) unsigned NOT NULL AUTO_INCREMENT, post_id bigint(20) unsigned NOT NULL, meta_key varchar(255) DEFAULT \'\', meta_value longtext, PRIMARY KEY (meta_id), KEY post_id (post_id), KEY meta_key (meta_key) ) ENGINE=MyISAM DEFAULT CHARSET=utf8'); qa_db_query_sub("INSERT INTO ^postmeta (post_id,meta_key,meta_value) VALUES (#,'is_expert_question','1')", $params['postid']); if (qa_opt('expert_question_email_experts')) { $subs = array('^post_title' => $params['title'], '^post_url' => qa_path_html(qa_q_request($params['postid'], $params['title']), null, qa_opt('site_url')), '^questions_list' => qa_path_html(qa_opt('expert_question_page_url'), null, qa_opt('site_url')), '^site_url' => qa_opt('site_url')); $experts = explode("\n", qa_opt('expert_question_users')); foreach ($experts as $expert) { if (strpos($expert, '=')) { $expert = explode('=', $expert); $catnames = explode(',', $expert[1]); $cats = qa_db_read_all_values(qa_db_query_sub('SELECT categoryid FROM ^categories WHERE title IN ($)', $catnames)); if (in_array($params['categoryid'], $cats)) { qa_send_notification($this->getuserfromhandle($expert[0]), '@', $expert[0], qa_opt('expert_question_email_subject'), qa_opt('expert_question_email_body'), $subs); } } else { qa_send_notification($this->getuserfromhandle($expert), '@', $expert, qa_opt('expert_question_email_subject'), qa_opt('expert_question_email_body'), $subs); } } } } break; default: break; } } }
function qa_page_q_single_click_q($question, $answers, $commentsfollows, $closepost, &$error) { require_once QA_INCLUDE_DIR . 'app/post-update.php'; require_once QA_INCLUDE_DIR . 'app/limits.php'; $userid = qa_get_logged_in_userid(); $handle = qa_get_logged_in_handle(); $cookieid = qa_cookie_get(); if (qa_clicked('q_doreopen') && $question['reopenable'] && qa_page_q_click_check_form_code($question, $error)) { qa_question_close_clear($question, $closepost, $userid, $handle, $cookieid); return true; } if (qa_clicked('q_dohide') && $question['hideable'] || qa_clicked('q_doreject') && $question['moderatable']) { if (qa_page_q_click_check_form_code($question, $error)) { qa_question_set_hidden($question, true, $userid, $handle, $cookieid, $answers, $commentsfollows, $closepost); return true; } } if (qa_clicked('q_doreshow') && $question['reshowable'] || qa_clicked('q_doapprove') && $question['moderatable']) { if (qa_page_q_click_check_form_code($question, $error)) { if ($question['moderatable'] || $question['reshowimmed']) { $status = QA_POST_STATUS_NORMAL; } else { $in = qa_page_q_prepare_post_for_filters($question); $filtermodules = qa_load_modules_with('filter', 'filter_question'); // run through filters but only for queued status foreach ($filtermodules as $filtermodule) { $tempin = $in; // always pass original question in because we aren't modifying anything else $filtermodule->filter_question($tempin, $temperrors, $question); $in['queued'] = $tempin['queued']; // only preserve queued status in loop } $status = $in['queued'] ? QA_POST_STATUS_QUEUED : QA_POST_STATUS_NORMAL; } qa_question_set_status($question, $status, $userid, $handle, $cookieid, $answers, $commentsfollows, $closepost); return true; } } if (qa_clicked('q_doclaim') && $question['claimable'] && qa_page_q_click_check_form_code($question, $error)) { if (qa_user_limits_remaining(QA_LIMIT_QUESTIONS)) { // already checked 'permit_post_q' qa_question_set_userid($question, $userid, $handle, $cookieid); return true; } else { $error = qa_lang_html('question/ask_limit'); } } if (qa_clicked('q_doflag') && $question['flagbutton'] && qa_page_q_click_check_form_code($question, $error)) { require_once QA_INCLUDE_DIR . 'app/votes.php'; $error = qa_flag_error_html($question, $userid, qa_request()); if (!$error) { if (qa_flag_set_tohide($question, $userid, $handle, $cookieid, $question)) { qa_question_set_hidden($question, true, null, null, null, $answers, $commentsfollows, $closepost); } // hiding not really by this user so pass nulls return true; } } if (qa_clicked('q_dounflag') && $question['unflaggable'] && qa_page_q_click_check_form_code($question, $error)) { require_once QA_INCLUDE_DIR . 'app/votes.php'; qa_flag_clear($question, $userid, $handle, $cookieid); return true; } if (qa_clicked('q_doclearflags') && $question['clearflaggable'] && qa_page_q_click_check_form_code($question, $error)) { require_once QA_INCLUDE_DIR . 'app/votes.php'; qa_flags_clear_all($question, $userid, $handle, $cookieid); return true; } return false; }
function qa_post_set_hidden($postid, $hidden = true, $byuserid = null) { $oldpost = qa_post_get_full($postid, 'QAC'); $byhandle = qa_post_userid_to_handle($byuserid); switch ($oldpost['basetype']) { case 'Q': $answers = qa_post_get_question_answers($postid); $commentsfollows = qa_post_get_question_commentsfollows($postid); $closepost = qa_post_get_question_closepost($postid); qa_question_set_hidden($oldpost, $hidden, $byuserid, $byhandle, null, $answers, $commentsfollows, $closepost); break; case 'A': $question = qa_post_get_full($oldpost['parentid'], 'Q'); $commentsfollows = qa_post_get_answer_commentsfollows($postid); qa_answer_set_hidden($oldpost, $hidden, $byuserid, $byhandle, null, $question, $commentsfollows); break; case 'C': $parent = qa_post_get_full($oldpost['parentid'], 'QA'); $question = qa_post_parent_to_question($parent); qa_comment_set_hidden($oldpost, $hidden, $byuserid, $byhandle, null, $question, $parent); break; } }
if (qa_limits_remaining($qa_login_userid, 'Q')) { // already checked 'permit_post_q' qa_question_set_userid($question, $qa_login_userid, qa_get_logged_in_handle(), $qa_cookieid); qa_report_write_action($qa_login_userid, $qa_cookieid, 'q_claim', $questionid, null, null); qa_redirect($qa_request); } else { $pageerror = qa_lang_html('question/ask_limit'); } } // Process flag or unflag button for question if (qa_clicked('doflagq') && $question['flagbutton']) { require_once QA_INCLUDE_DIR . 'qa-app-votes.php'; $pageerror = qa_flag_error_html($question, $qa_login_userid, $qa_request); if (!$pageerror) { if (qa_flag_set_tohide($question, $qa_login_userid, qa_get_logged_in_handle(), $qa_cookieid, $question)) { qa_question_set_hidden($question, true, null, null, null, $answers, $commentsfollows); } // hiding not really by this user so pass nulls qa_redirect($qa_request); } } if (qa_clicked('dounflagq') && $question['unflaggable']) { require_once QA_INCLUDE_DIR . 'qa-app-votes.php'; qa_flag_clear($question, $qa_login_userid, qa_get_logged_in_handle(), $qa_cookieid); qa_redirect($qa_request); } if (qa_clicked('doclearflagsq') && $question['clearflaggable']) { require_once QA_INCLUDE_DIR . 'qa-app-votes.php'; qa_flags_clear_all($question, $qa_login_userid, qa_get_logged_in_handle(), $qa_cookieid); qa_redirect($qa_request); }