show-comments.php 2.26 KB
Newer Older
Scott committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
<?php
/*
	Question2Answer by Gideon Greenspan and contributors
	http://www.question2answer.org/

	File: qa-include/qa-ajax-show-comments.php
	Description: Server-side response to Ajax request to view full comment list


	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	More about this license: http://www.question2answer.org/license.php
*/

Scott committed
23
	require_once QA_INCLUDE_DIR.'db/selects.php';
Scott committed
24 25 26
	require_once QA_INCLUDE_DIR.'app/users.php';
	require_once QA_INCLUDE_DIR.'app/cookies.php';
	require_once QA_INCLUDE_DIR.'app/format.php';
27
	require_once QA_INCLUDE_DIR.'pages/question-view.php';
Scott committed
28
	require_once QA_INCLUDE_DIR.'util/sort.php';
Scott committed
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73


//	Load relevant information about this question and check it exists

	$questionid=qa_post_text('c_questionid');
	$parentid=qa_post_text('c_parentid');
	$userid=qa_get_logged_in_userid();

	list($question, $parent, $children)=qa_db_select_with_pending(
		qa_db_full_post_selectspec($userid, $questionid),
		qa_db_full_post_selectspec($userid, $parentid),
		qa_db_full_child_posts_selectspec($userid, $parentid)
	);

	if (isset($parent)) {
		$parent=$parent+qa_page_q_post_rules($parent, null, null, $children);
			// in theory we should retrieve the parent's parent and siblings for the above, but they're not going to be relevant

		foreach ($children as $key => $child)
			$children[$key]=$child+qa_page_q_post_rules($child, $parent, $children, null);

		$usershtml=qa_userids_handles_html($children, true);

		qa_sort_by($children, 'created');

		$c_list=qa_page_q_comment_follow_list($question, $parent, $children, true, $usershtml, false, null);

		$themeclass=qa_load_theme_class(qa_get_site_theme(), 'ajax-comments', null, null);

		echo "QA_AJAX_RESPONSE\n1\n";


	//	Send back the HTML

		$themeclass->c_list_items($c_list['cs']);

		return;
	}


	echo "QA_AJAX_RESPONSE\n0\n";


/*
	Omit PHP closing tag to help avoid accidental output
Gideon Greenspan committed
74
*/