Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 38 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| topics | |
0.00% |
0 / 38 |
|
0.00% |
0 / 2 |
72 | |
0.00% |
0 / 1 |
| get_sql | |
0.00% |
0 / 36 |
|
0.00% |
0 / 1 |
30 | |||
| adjust_item | |
0.00% |
0 / 2 |
|
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 | |
| 14 | namespace phpbb\feed; |
| 15 | |
| 16 | /** |
| 17 | * New Topics feed |
| 18 | * |
| 19 | * This will give you the last {$this->num_items} created topics |
| 20 | * including the first post. |
| 21 | */ |
| 22 | class topics extends topic_base |
| 23 | { |
| 24 | /** |
| 25 | * {@inheritdoc} |
| 26 | */ |
| 27 | protected function get_sql() |
| 28 | { |
| 29 | $forum_ids_read = $this->get_readable_forums(); |
| 30 | if (empty($forum_ids_read)) |
| 31 | { |
| 32 | return false; |
| 33 | } |
| 34 | |
| 35 | $in_fid_ary = array_diff($forum_ids_read, $this->get_excluded_forums(), $this->get_passworded_forums()); |
| 36 | if (empty($in_fid_ary)) |
| 37 | { |
| 38 | return false; |
| 39 | } |
| 40 | |
| 41 | // We really have to get the post ids first! |
| 42 | $sql = 'SELECT topic_first_post_id, topic_time |
| 43 | FROM ' . TOPICS_TABLE . ' |
| 44 | WHERE topic_moved_id = 0 |
| 45 | AND ' . $this->content_visibility->get_forums_visibility_sql('topic', $in_fid_ary) . ' |
| 46 | ORDER BY topic_time DESC'; |
| 47 | $result = $this->db->sql_query_limit($sql, $this->num_items); |
| 48 | |
| 49 | $post_ids = array(); |
| 50 | while ($row = $this->db->sql_fetchrow($result)) |
| 51 | { |
| 52 | $post_ids[] = (int) $row['topic_first_post_id']; |
| 53 | } |
| 54 | $this->db->sql_freeresult($result); |
| 55 | |
| 56 | if (empty($post_ids)) |
| 57 | { |
| 58 | return false; |
| 59 | } |
| 60 | |
| 61 | parent::fetch_attachments($post_ids); |
| 62 | |
| 63 | $this->sql = array( |
| 64 | 'SELECT' => 'f.forum_id, f.forum_name, |
| 65 | t.topic_id, t.topic_title, t.topic_poster, t.topic_first_poster_name, t.topic_posts_approved, t.topic_posts_unapproved, t.topic_posts_softdeleted, t.topic_views, t.topic_time, t.topic_last_post_time, |
| 66 | p.post_id, p.post_time, p.post_edit_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.post_attachment, t.topic_visibility', |
| 67 | 'FROM' => array( |
| 68 | TOPICS_TABLE => 't', |
| 69 | POSTS_TABLE => 'p', |
| 70 | ), |
| 71 | 'LEFT_JOIN' => array( |
| 72 | array( |
| 73 | 'FROM' => array(FORUMS_TABLE => 'f'), |
| 74 | 'ON' => 'p.forum_id = f.forum_id', |
| 75 | ), |
| 76 | ), |
| 77 | 'WHERE' => 'p.topic_id = t.topic_id |
| 78 | AND ' . $this->db->sql_in_set('p.post_id', $post_ids), |
| 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 | } |