qa-ajax-show-comments.php 2.4 KB
Newer Older
Gideon Greenspan committed
1 2 3 4 5 6 7
<?php

/*
	Question2Answer (c) Gideon Greenspan

	http://www.question2answer.org/

Scott Vivian committed
8

Gideon Greenspan committed
9 10 11 12 13 14 15 16 17
	File: qa-include/qa-ajax-show-comments.php
	Version: See define()s at top of qa-include/qa-base.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.
Scott Vivian committed
18

Gideon Greenspan committed
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
	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
*/

	require_once QA_INCLUDE_DIR.'qa-db-selects.php';
	require_once QA_INCLUDE_DIR.'qa-app-users.php';
	require_once QA_INCLUDE_DIR.'qa-app-cookies.php';
	require_once QA_INCLUDE_DIR.'qa-app-format.php';
	require_once QA_INCLUDE_DIR.'qa-page-question-view.php';
	require_once QA_INCLUDE_DIR.'qa-util-sort.php';


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

Gideon Greenspan committed
37
	$questionid=qa_post_text('c_questionid');
Gideon Greenspan committed
38 39
	$parentid=qa_post_text('c_parentid');
	$userid=qa_get_logged_in_userid();
Scott Vivian committed
40

Gideon Greenspan committed
41 42
	list($question, $parent, $children)=qa_db_select_with_pending(
		qa_db_full_post_selectspec($userid, $questionid),
Gideon Greenspan committed
43 44 45
		qa_db_full_post_selectspec($userid, $parentid),
		qa_db_full_child_posts_selectspec($userid, $parentid)
	);
Scott Vivian committed
46

Gideon Greenspan committed
47
	if (isset($parent)) {
Scott Vivian committed
48
		$parent=$parent+qa_page_q_post_rules($parent, null, null, $children);
Gideon Greenspan committed
49 50 51 52
			// 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);
Scott Vivian committed
53

Gideon Greenspan committed
54
		$usershtml=qa_userids_handles_html($children, true);
Scott Vivian committed
55

Gideon Greenspan committed
56
		qa_sort_by($children, 'created');
Scott Vivian committed
57

Gideon Greenspan committed
58
		$c_list=qa_page_q_comment_follow_list($question, $parent, $children, true, $usershtml, false, null);
Scott Vivian committed
59

Gideon Greenspan committed
60
		$themeclass=qa_load_theme_class(qa_get_site_theme(), 'ajax-comments', null, null);
Scott Vivian committed
61

Gideon Greenspan committed
62 63
		echo "QA_AJAX_RESPONSE\n1\n";

Scott Vivian committed
64

Gideon Greenspan committed
65 66
	//	Send back the HTML

Gideon Greenspan committed
67
		$themeclass->c_list_items($c_list['cs']);
Gideon Greenspan committed
68 69 70 71

		return;
	}

Scott Vivian committed
72

Gideon Greenspan committed
73 74
	echo "QA_AJAX_RESPONSE\n0\n";

Scott Vivian committed
75

Gideon Greenspan committed
76 77 78
/*
	Omit PHP closing tag to help avoid accidental output
*/