Gazelle/sections/ajax/tcomments.php
2013-08-28 23:08:41 +00:00

42 lines
1.3 KiB
PHP

<?
include(SERVER_ROOT.'/classes/text.class.php');
$Text = new TEXT;
if (empty($_GET['id']) || !is_number($_GET['id'])) {
json_die("failure");
}
list($NumComments, $Page, $Thread) = Comments::load('torrents', (int)$_GET['id'], false);
//---------- Begin printing
$JsonComments = array();
foreach ($Thread as $Key => $Post) {
list($PostID, $AuthorID, $AddedTime, $Body, $EditedUserID, $EditedTime, $EditedUsername) = array_values($Post);
list($AuthorID, $Username, $PermissionID, $Paranoia, $Artist, $Donor, $Warned, $Avatar, $Enabled, $UserTitle) = array_values(Users::user_info($AuthorID));
$JsonComments[] = array(
'postId' => (int) $PostID,
'addedTime' => $AddedTime,
'bbBody' => $Body,
'body' => $Text->full_format($Body),
'editedUserId' => (int) $EditedUserID,
'editedTime' => $EditedTime,
'editedUsername' => $EditedUsername,
'userinfo' => array(
'authorId' => (int) $AuthorID,
'authorName' => $Username,
'artist' => $Artist == 1,
'donor' => $Donor == 1,
'warned' => ($Warned != '0000-00-00 00:00:00'),
'avatar' => $Avatar,
'enabled' => ($Enabled == 2 ? false : true),
'userTitle' => $UserTitle
)
);
}
json_die("success", array(
'page' => (int) $Page,
'pages' => ceil($NumComments / TORRENT_COMMENTS_PER_PAGE),
'comments' => $JsonComments
));