header('Location: ../');
    exit;
}
require_once QA_INCLUDE_DIR . 'app/cookies.php';
require_once QA_INCLUDE_DIR . 'app/format.php';
require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR . 'util/sort.php';
require_once QA_INCLUDE_DIR . 'util/string.php';
require_once QA_INCLUDE_DIR . 'app/captcha.php';
require_once QA_INCLUDE_DIR . 'pages/question-view.php';
require_once QA_INCLUDE_DIR . 'app/updates.php';
$questionid = qa_request_part(0);
$userid = qa_get_logged_in_userid();
$cookieid = qa_cookie_get();
//	Get information about this question
list($question, $childposts, $achildposts, $parentquestion, $closepost, $extravalue, $categories, $favorite) = qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $questionid), qa_db_full_child_posts_selectspec($userid, $questionid), qa_db_full_a_child_posts_selectspec($userid, $questionid), qa_db_post_parent_q_selectspec($questionid), qa_db_post_close_post_selectspec($questionid), qa_db_post_meta_selectspec($questionid, 'qa_q_extra'), qa_db_category_nav_selectspec($questionid, true, true, true), isset($userid) ? qa_db_is_favorite_selectspec($userid, QA_ENTITY_QUESTION, $questionid) : null);
if ($question['basetype'] != 'Q') {
    // don't allow direct viewing of other types of post
    $question = null;
}
if (isset($question)) {
    $question['extra'] = $extravalue;
    $answers = qa_page_q_load_as($question, $childposts);
    $commentsfollows = qa_page_q_load_c_follows($question, $childposts, $achildposts);
    $question = $question + qa_page_q_post_rules($question, null, null, $childposts);
    // array union
    if ($question['selchildid'] && @$answers[$question['selchildid']]['type'] != 'A') {
        $question['selchildid'] = null;
    }
    // if selected answer is hidden or somehow not there, consider it not selected
    foreach ($answers as $key => $answer) {
Example #2
0
function qa_post_get_question_closepost($questionid)
{
    return qa_db_single_select(qa_db_post_close_post_selectspec($questionid));
}
Example #3
0
 function get_single_question($data, $questionin)
 {
     $userid = qa_get_logged_in_userid();
     $questionid = $questionin['postid'];
     $options = qa_post_html_defaults('Q', @$data['full']);
     if (@$data['full']) {
         require_once QA_INCLUDE_DIR . 'qa-page-question-view.php';
         $cookieid = isset($userid) ? qa_cookie_get() : qa_cookie_get_create();
         // create a new cookie if necessary
         $coptions = qa_post_html_defaults('C', true);
         @(list($childposts, $achildposts, $parentquestion, $closepost, $extravalue, $categories, $favorite) = qa_db_select_with_pending(qa_db_full_child_posts_selectspec($userid, $questionid), qa_db_full_a_child_posts_selectspec($userid, $questionid), qa_db_post_parent_q_selectspec($questionid), qa_db_post_close_post_selectspec($questionid), qa_db_post_meta_selectspec($questionid, 'qa_q_extra'), qa_db_category_nav_selectspec($questionid, true, true, true), isset($userid) ? qa_db_is_favorite_selectspec($userid, QA_ENTITY_QUESTION, $questionid) : null));
         if ($questionin['basetype'] != 'Q') {
             // don't allow direct viewing of other types of post
             return null;
         }
         $questionin['extra'] = $extravalue;
         $answers = qa_page_q_load_as($questionin, $childposts);
         $allcomments = qa_page_q_load_c_follows($questionin, $childposts, $achildposts);
         $questionin = $questionin + qa_page_q_post_rules($questionin, null, null, $childposts);
         // array union
         if ($questionin['selchildid'] && @$answers[$questionin['selchildid']]['type'] != 'A') {
             $questionin['selchildid'] = null;
         }
         // if selected answer is hidden or somehow not there, consider it not selected
         foreach ($answers as $key => $answer) {
             $answers[$key] = $answer + qa_page_q_post_rules($answer, $questionin, $answers, $achildposts);
             $answers[$key]['isselected'] = $answer['postid'] == $questionin['selchildid'];
         }
         foreach ($allcomments as $key => $commentfollow) {
             $parent = $commentfollow['parentid'] == $questionid ? $questionin : @$answers[$commentfollow['parentid']];
             $allcomments[$key] = $commentfollow + qa_page_q_post_rules($commentfollow, $parent, $allcomments, null);
         }
         $usershtml = qa_userids_handles_html(array_merge(array($questionin), $answers, $allcomments), true);
         $question = $this->get_full_post($questionin, $options, $usershtml);
         $qcomments = array();
         foreach ($allcomments as $idx => $comment) {
             if ($comment['basetype'] == 'C') {
                 $comment = $this->get_full_post($comment, $coptions, $usershtml);
             } else {
                 $comment = $this->get_full_post($comment, $options, $usershtml);
             }
             $comment['username'] = $this->get_username($comment['raw']['userid']);
             if ($comment['raw']['parentid'] == $questionid) {
                 $qcomments[] = $comment;
             }
             $allcomments[$idx] = $comment;
         }
         $aoptions = qa_post_html_defaults('A', true);
         $outanswers = array();
         foreach ($answers as $answer) {
             $aoptions['isselected'] = @$answer['isselected'];
             $answer = $this->get_full_post($answer, $aoptions, $usershtml);
             if (!$answer) {
                 continue;
             }
             $answer['username'] = $this->get_username($answer['raw']['userid']);
             $acomments = array();
             foreach ($allcomments as $comment) {
                 if ($comment['raw']['parentid'] == $answer['raw']['postid']) {
                     $acomments[] = $comment;
                 }
             }
             $answer['comments'] = $acomments;
             $outanswers[] = $answer;
         }
         $question['answers'] = $outanswers;
         $question['comments'] = $qcomments;
         $question['parentquestion'] = $parentquestion;
         $question['closepost'] = $closepost;
         $question['extravalue'] = $extravalue;
         $question['categories'] = $categories;
         $question['favorite'] = $favorite;
     } else {
         $questionin = qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $questionid));
         $usershtml = qa_userids_handles_html(array($questionin), true);
         $question = qa_any_to_q_html_fields($questionin, $userid, qa_cookie_get(), $usershtml, null, $options);
     }
     $question['username'] = $this->get_username($userid);
     return $question;
 }