Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 22
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
forums
0.00% covered (danger)
0.00%
0 / 22
0.00% covered (danger)
0.00%
0 / 3
30
0.00% covered (danger)
0.00%
0 / 1
 set_keys
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
2
 get_sql
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 1
6
 adjust_item
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2/**
3 *
4 * This file is part of the phpBB Forum Software package.
5 *
6 * @copyright (c) phpBB Limited <https://www.phpbb.com>
7 * @license GNU General Public License, version 2 (GPL-2.0)
8 *
9 * For full copyright and license information, please see
10 * the docs/CREDITS.txt file.
11 *
12 */
13
14namespace phpbb\feed;
15
16/**
17 * 'All Forums' feed
18 *
19 * This will give you a list of all postable forums where feeds are enabled
20 * including forum description, topic stats and post stats
21 */
22class forums extends base
23{
24    protected $num_items    = 0;
25
26    /**
27     * {@inheritdoc}
28     */
29    public function set_keys()
30    {
31        $this->set('title',        'forum_name');
32        $this->set('text',        'forum_desc');
33        $this->set('bitfield',    'forum_desc_bitfield');
34        $this->set('bbcode_uid','forum_desc_uid');
35        $this->set('updated',    'forum_last_post_time');
36        $this->set('options',    'forum_desc_options');
37    }
38
39    /**
40     * {@inheritdoc}
41     */
42    public function get_sql()
43    {
44        $in_fid_ary = array_diff($this->get_readable_forums(), $this->get_excluded_forums());
45        if (empty($in_fid_ary))
46        {
47            return false;
48        }
49
50        // Build SQL Query
51        $this->sql = array(
52            'SELECT'    => 'f.forum_id, f.left_id, f.forum_name, f.forum_last_post_time,
53                            f.forum_desc, f.forum_desc_bitfield, f.forum_desc_uid, f.forum_desc_options,
54                            f.forum_topics_approved, f.forum_posts_approved',
55            'FROM'        => array(FORUMS_TABLE => 'f'),
56            'WHERE'        => 'f.forum_type = ' . FORUM_POST . '
57                            AND ' . $this->db->sql_in_set('f.forum_id', $in_fid_ary),
58            'ORDER_BY'    => 'f.left_id ASC',
59        );
60
61        return true;
62    }
63
64    /**
65     * {@inheritdoc}
66     */
67    public function adjust_item(&$item_row, &$row)
68    {
69        $item_row['link'] = $this->helper->append_sid('viewforum.' . $this->phpEx, 'f=' . $row['forum_id']);
70
71        if ($this->config['feed_item_statistics'])
72        {
73            $item_row['statistics'] = $this->user->lang('TOTAL_TOPICS', (int) $row['forum_topics_approved'])
74                . ' ' . $this->separator_stats . ' ' . $this->user->lang('TOTAL_POSTS_COUNT', (int) $row['forum_posts_approved']);
75        }
76    }
77}