1 | <?php
|
---|
2 |
|
---|
3 | require_once('includes/game.php');
|
---|
4 |
|
---|
5 | function getcomments($type, $typeid)
|
---|
6 | {
|
---|
7 | global $DB;
|
---|
8 | global $rDB;
|
---|
9 |
|
---|
10 | $rows = $DB->select('
|
---|
11 | SELECT id, userid, post_date, commentbody, replyto
|
---|
12 | FROM ?_comments
|
---|
13 | WHERE type=? AND typeid=?
|
---|
14 | ORDER BY replyto, post_date
|
---|
15 | ',
|
---|
16 | $type, $typeid
|
---|
17 | );
|
---|
18 |
|
---|
19 | $comments = array();
|
---|
20 |
|
---|
21 | foreach ($rows as $i=>$row)
|
---|
22 | {
|
---|
23 | $comments[$i] = array();
|
---|
24 | $comments[$i] = $rDB->selectRow('SELECT username as user, gmlevel as roles FROM account WHERE id=? LIMIT 1', $row['userid']);
|
---|
25 | if (!(IsSet($comments[$i]['user'])))
|
---|
26 | $comments[$i]['user'] = "Anonymous";
|
---|
27 | $comments[$i]['number'] = $i;
|
---|
28 | $comments[$i]['id'] = $row['id'];
|
---|
29 | $comments[$i]['body'] = $row['commentbody'];
|
---|
30 | $comments[$i]['date'] = $row['post_date'];
|
---|
31 | $comments[$i]['replyto'] = $row['replyto'];
|
---|
32 | if ($comments[$i]['replyto'] != $comments[$i]['id'])
|
---|
33 | $comments[$i]['indent'] = 1;
|
---|
34 |
|
---|
35 | $comments[$i]['raters'] = array();
|
---|
36 | $comments[$i]['raters'] = $DB->select('SELECT userid, rate FROM ?_comments_rates WHERE commentid=?d', $comments[$i]['id']);
|
---|
37 | $comments[$i]['rating'] = sum_subarrays_by_key($comments[$i]['raters'], 'rate');
|
---|
38 | $comments[$i]['purged'] = ($comments[$i]['rating'] <= -50)? 1: 0;
|
---|
39 | $comments[$i]['deleted'] = 0;
|
---|
40 | }
|
---|
41 |
|
---|
42 | return $comments;
|
---|
43 | }
|
---|
44 |
|
---|
45 | ?>
|
---|