root/branches/portal_by_daris/panels/recent_posts.php

Revision 19, 1.8 KB (checked in by daris, 3 years ago)

portal: fixes for recent posts panel

Line 
1<?php
2/***********************************************************************
3
4        PunBB extension
5        Portal
6        Daris <daris91@gmail.com>
7
8************************************************************************/
9
10
11$count = 10; // count posts
12$subject_len = 20; // length of topic title
13
14
15// Make sure no one attempts to run this script "directly"
16if (!defined('FORUM'))
17        exit;
18
19// Fetch some info about the posts
20$query = array(
21        'SELECT'        => 't.subject, t.last_post, t.last_poster, t.last_post_id',
22        'FROM'          => 'topics AS t',
23        'JOINS'         => array(
24                array(
25                        'LEFT JOIN'             => 'forum_perms AS fp',
26                        'ON'                    => '(fp.forum_id=t.forum_id AND fp.group_id='.$forum_user['g_id'].')'
27                )
28        ),
29        'WHERE'         => '(fp.read_forum IS NULL OR fp.read_forum=1) AND t.moved_to IS NULL',
30        'ORDER BY'      => 't.last_post DESC',
31        'LIMIT'         => '0, '.$count
32);
33($hook = get_hook('pr_qr_get_recent_posts')) ? eval($hook) : null;
34$result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
35
36// If there are any posts
37if ($forum_db->num_rows($result) > 0)
38{
39
40?>
41                <ul class="recent-posts">
42<?php
43
44        while ($cur_topic = $forum_db->fetch_assoc($result))
45        {
46
47                if ($forum_config['o_censoring'] == '1')
48                        $cur_topic['subject'] = censor_words($cur_topic['subject']);
49
50                $subject = (utf8_strlen($cur_topic['subject']) > $subject_len ? utf8_substr($cur_topic['subject'], 0, $subject_len).'...' : $cur_topic['subject']);
51                $subject = forum_htmlencode($subject);
52                $title = forum_htmlencode($cur_topic['subject']);
53                $title .= ', '.$lang_portal['By'].': '.forum_htmlencode($cur_topic['last_poster']);
54                $title .= ', '.$lang_portal['Posted'].': '.format_time($cur_topic['last_post'])
55               
56?>
57                        <li><a href="<?php echo forum_link($forum_url['post'], array($cur_topic['last_post_id'])) ?>" title="<?php echo $title ?>"><?php echo $subject ?></a></li>
58<?php
59
60        }
61
62?>
63                </ul>
64<?php
65}
66// If there are no posts do not display panel
Note: See TracBrowser for help on using the browser.