Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 40
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
overall
0.00% covered (danger)
0.00%
0 / 40
0.00% covered (danger)
0.00%
0 / 2
56
0.00% covered (danger)
0.00%
0 / 1
 get_sql
0.00% covered (danger)
0.00%
0 / 38
0.00% covered (danger)
0.00%
0 / 1
20
 adjust_item
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
12
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 * Board wide feed (aka overall feed)
18 *
19 * This will give you the newest {$this->num_items} posts
20 * from the whole board.
21 */
22class overall extends post_base
23{
24    /**
25     * {@inheritdoc}
26     */
27    protected function get_sql()
28    {
29        $forum_ids = array_diff($this->get_readable_forums(), $this->get_excluded_forums(), $this->get_passworded_forums());
30        if (empty($forum_ids))
31        {
32            return false;
33        }
34
35        // Determine topics with recent activity
36        $sql = 'SELECT topic_id, topic_last_post_time
37            FROM ' . TOPICS_TABLE . '
38            WHERE topic_moved_id = 0
39                AND ' . $this->content_visibility->get_forums_visibility_sql('topic', $forum_ids) . '
40            ORDER BY topic_last_post_time DESC, topic_last_post_id DESC';
41        $result = $this->db->sql_query_limit($sql, $this->num_items);
42
43        $topic_ids = array();
44        $min_post_time = 0;
45        while ($row = $this->db->sql_fetchrow())
46        {
47            $topic_ids[] = (int) $row['topic_id'];
48
49            $min_post_time = (int) $row['topic_last_post_time'];
50        }
51        $this->db->sql_freeresult($result);
52
53        if (empty($topic_ids))
54        {
55            return false;
56        }
57
58        parent::fetch_attachments(array(), $topic_ids);
59
60        // Get the actual data
61        $this->sql = array(
62            'SELECT'    =>    'f.forum_id, f.forum_name, ' .
63                'p.post_id, p.topic_id, p.post_time, p.post_edit_time, p.post_visibility, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.post_attachment, ' .
64                'u.username, u.user_id',
65            'FROM'        => array(
66                USERS_TABLE        => 'u',
67                POSTS_TABLE        => 'p',
68            ),
69            'LEFT_JOIN'    => array(
70                array(
71                    'FROM'    => array(FORUMS_TABLE    => 'f'),
72                    'ON'    => 'f.forum_id = p.forum_id',
73                ),
74            ),
75            'WHERE'        => $this->db->sql_in_set('p.topic_id', $topic_ids) . '
76                            AND ' . $this->content_visibility->get_forums_visibility_sql('post', $forum_ids, 'p.') . '
77                            AND p.post_time >= ' . $min_post_time . '
78                            AND u.user_id = p.poster_id',
79            'ORDER_BY'    => 'p.post_time DESC, p.post_id DESC',
80        );
81
82        return true;
83    }
84
85    /**
86     * {@inheritdoc}
87     */
88    public function adjust_item(&$item_row, &$row)
89    {
90        parent::adjust_item($item_row, $row);
91
92        $item_row['title'] = (isset($row['forum_name']) && $row['forum_name'] !== '') ? $row['forum_name'] . ' ' . $this->separator . ' ' . $item_row['title'] : $item_row['title'];
93    }
94}