diff --git a/phpBB/config/feed.yml b/phpBB/config/feed.yml index 218ce7a4e4..59eeafd458 100644 --- a/phpBB/config/feed.yml +++ b/phpBB/config/feed.yml @@ -18,39 +18,81 @@ services: scope: prototype arguments: - @feed.helper + - @config + - @dbal.conn + - @cache.driver + - @user + - @auth + - %core.php_ext% feed.forums: class: phpbb_feed_forums scope: prototype arguments: - @feed.helper + - @config + - @dbal.conn + - @cache.driver + - @user + - @auth + - %core.php_ext% feed.news: class: phpbb_feed_news scope: prototype arguments: - @feed.helper + - @config + - @dbal.conn + - @cache.driver + - @user + - @auth + - %core.php_ext% feed.overall: class: phpbb_feed_overall scope: prototype arguments: - @feed.helper + - @config + - @dbal.conn + - @cache.driver + - @user + - @auth + - %core.php_ext% feed.topic: class: phpbb_feed_topic scope: prototype arguments: - @feed.helper + - @config + - @dbal.conn + - @cache.driver + - @user + - @auth + - %core.php_ext% feed.topics: class: phpbb_feed_topics scope: prototype arguments: - @feed.helper + - @config + - @dbal.conn + - @cache.driver + - @user + - @auth + - %core.php_ext% feed.topics_active: class: phpbb_feed_topics_active scope: prototype arguments: - @feed.helper + - @config + - @dbal.conn + - @cache.driver + - @user + - @auth + - %core.php_ext% diff --git a/phpBB/includes/feed/base.php b/phpBB/includes/feed/base.php index 2ffd20d31a..c8015ab916 100644 --- a/phpBB/includes/feed/base.php +++ b/phpBB/includes/feed/base.php @@ -28,6 +28,24 @@ abstract class phpbb_feed_base */ protected $helper; + /** @var phpbb_config */ + protected $config; + + /** @var phpbb_db_driver */ + protected $db; + + /** @var phpbb_cache_driver_interface */ + protected $cache; + + /** @var phpbb_user */ + protected $user; + + /** @var phpbb_auth */ + protected $auth; + + /** @var string */ + protected $phpEx; + /** * SQL Query to be executed to get feed items */ @@ -57,18 +75,30 @@ abstract class phpbb_feed_base * Constructor * * @param phpbb_feed_helper $helper Feed helper + * @param phpbb_config $config Config object + * @param phpbb_db_driver $db Database connection + * @param phpbb_cache_driver_interface $cache Cache object + * @param phpbb_user $user User object + * @param phpbb_auth $auth Auth object + * @param string $phpEx php file extension * @return null */ - function __construct(phpbb_feed_helper $helper) + function __construct(phpbb_feed_helper $helper, phpbb_config $config, phpbb_db_driver $db, phpbb_cache_driver_interface $cache, phpbb_user $user, phpbb_auth $auth, $phpEx) { - global $config; + $this->config = $config; + $this->helper = $helper; + $this->db = $db; + $this->cache = $cache; + $this->user = $user; + $this->auth = $auth; + $this->phpEx = $phpEx; $this->set_keys(); // Allow num_items to be string if (is_string($this->num_items)) { - $this->num_items = (int) $config[$this->num_items]; + $this->num_items = (int) $this->config[$this->num_items]; // A precaution if (!$this->num_items) @@ -76,8 +106,6 @@ abstract class phpbb_feed_base $this->num_items = 10; } } - - $this->helper = $helper; } /** @@ -99,11 +127,9 @@ abstract class phpbb_feed_base */ function close() { - global $db; - if (!empty($this->result)) { - $db->sql_freeresult($this->result); + $this->db->sql_freeresult($this->result); } } @@ -125,12 +151,11 @@ abstract class phpbb_feed_base function get_readable_forums() { - global $auth; static $forum_ids; if (!isset($forum_ids)) { - $forum_ids = array_keys($auth->acl_getf('f_read', true)); + $forum_ids = array_keys($this->auth->acl_getf('f_read', true)); } return $forum_ids; @@ -138,12 +163,11 @@ abstract class phpbb_feed_base function get_moderator_approve_forums() { - global $auth; static $forum_ids; if (!isset($forum_ids)) { - $forum_ids = array_keys($auth->acl_getf('m_approve', true)); + $forum_ids = array_keys($this->auth->acl_getf('m_approve', true)); } return $forum_ids; @@ -163,27 +187,26 @@ abstract class phpbb_feed_base function get_excluded_forums() { - global $db, $cache; static $forum_ids; // Matches acp/acp_board.php $cache_name = 'feed_excluded_forum_ids'; - if (!isset($forum_ids) && ($forum_ids = $cache->get('_' . $cache_name)) === false) + if (!isset($forum_ids) && ($forum_ids = $this->cache->get('_' . $cache_name)) === false) { $sql = 'SELECT forum_id FROM ' . FORUMS_TABLE . ' - WHERE ' . $db->sql_bit_and('forum_options', FORUM_OPTION_FEED_EXCLUDE, '<> 0'); - $result = $db->sql_query($sql); + WHERE ' . $this->db->sql_bit_and('forum_options', FORUM_OPTION_FEED_EXCLUDE, '<> 0'); + $result = $this->db->sql_query($sql); $forum_ids = array(); - while ($forum_id = (int) $db->sql_fetchfield('forum_id')) + while ($forum_id = (int) $this->db->sql_fetchfield('forum_id')) { $forum_ids[$forum_id] = $forum_id; } - $db->sql_freeresult($result); + $this->db->sql_freeresult($result); - $cache->put('_' . $cache_name, $forum_ids); + $this->cache->put('_' . $cache_name, $forum_ids); } return $forum_ids; @@ -198,14 +221,11 @@ abstract class phpbb_feed_base function get_passworded_forums() { - global $user; - - return $user->get_passworded_forums(); + return $this->user->get_passworded_forums(); } function get_item() { - global $db, $cache; static $result; if (!isset($result)) @@ -216,26 +236,24 @@ abstract class phpbb_feed_base } // Query database - $sql = $db->sql_build_query('SELECT', $this->sql); - $result = $db->sql_query_limit($sql, $this->num_items); + $sql = $this->db->sql_build_query('SELECT', $this->sql); + $result = $this->db->sql_query_limit($sql, $this->num_items); } - return $db->sql_fetchrow($result); + return $this->db->sql_fetchrow($result); } function user_viewprofile($row) { - global $phpEx, $user; - $author_id = (int) $row[$this->get('author_id')]; if ($author_id == ANONYMOUS) { // Since we cannot link to a profile, we just return GUEST // instead of $row['username'] - return $user->lang['GUEST']; + return $this->user->lang['GUEST']; } - return '' . $row[$this->get('creator')] . ''; + return '' . $row[$this->get('creator')] . ''; } } diff --git a/phpBB/includes/feed/factory.php b/phpBB/includes/feed/factory.php index 346cf9d870..63a1eb8ef0 100644 --- a/phpBB/includes/feed/factory.php +++ b/phpBB/includes/feed/factory.php @@ -31,7 +31,7 @@ class phpbb_feed_factory protected $config; /** @var phpbb_db_driver */ - protected $driver; + protected $db; /** * Constructor diff --git a/phpBB/includes/feed/forum.php b/phpBB/includes/feed/forum.php index ec95cabe89..7670fbeaaa 100644 --- a/phpBB/includes/feed/forum.php +++ b/phpBB/includes/feed/forum.php @@ -43,15 +43,13 @@ class phpbb_feed_forum extends phpbb_feed_post_base function open() { - global $db, $auth; - // Check if forum exists $sql = 'SELECT forum_id, forum_name, forum_password, forum_type, forum_options FROM ' . FORUMS_TABLE . ' WHERE forum_id = ' . $this->forum_id; - $result = $db->sql_query($sql); - $this->forum_data = $db->sql_fetchrow($result); - $db->sql_freeresult($result); + $result = $this->db->sql_query($sql); + $this->forum_data = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); if (empty($this->forum_data)) { @@ -71,7 +69,7 @@ class phpbb_feed_forum extends phpbb_feed_post_base } // Make sure we can read this forum - if (!$auth->acl_get('f_read', $this->forum_id)) + if (!$this->auth->acl_get('f_read', $this->forum_id)) { trigger_error('SORRY_AUTH_READ'); } @@ -92,9 +90,7 @@ class phpbb_feed_forum extends phpbb_feed_post_base function get_sql() { - global $auth, $db; - - $m_approve = ($auth->acl_get('m_approve', $this->forum_id)) ? true : false; + $m_approve = ($this->auth->acl_get('m_approve', $this->forum_id)) ? true : false; // Determine topics with recent activity $sql = 'SELECT topic_id, topic_last_post_time @@ -103,17 +99,17 @@ class phpbb_feed_forum extends phpbb_feed_post_base AND topic_moved_id = 0 ' . ((!$m_approve) ? 'AND topic_approved = 1' : '') . ' ORDER BY topic_last_post_time DESC'; - $result = $db->sql_query_limit($sql, $this->num_items); + $result = $this->db->sql_query_limit($sql, $this->num_items); $topic_ids = array(); $min_post_time = 0; - while ($row = $db->sql_fetchrow()) + while ($row = $this->db->sql_fetchrow()) { $topic_ids[] = (int) $row['topic_id']; $min_post_time = (int) $row['topic_last_post_time']; } - $db->sql_freeresult($result); + $this->db->sql_freeresult($result); if (empty($topic_ids)) { @@ -127,7 +123,7 @@ class phpbb_feed_forum extends phpbb_feed_post_base POSTS_TABLE => 'p', USERS_TABLE => 'u', ), - 'WHERE' => $db->sql_in_set('p.topic_id', $topic_ids) . ' + 'WHERE' => $this->db->sql_in_set('p.topic_id', $topic_ids) . ' ' . ((!$m_approve) ? 'AND p.post_approved = 1' : '') . ' AND p.post_time >= ' . $min_post_time . ' AND p.poster_id = u.user_id', diff --git a/phpBB/includes/feed/forums.php b/phpBB/includes/feed/forums.php index 5f56d28d2c..130da1c56a 100644 --- a/phpBB/includes/feed/forums.php +++ b/phpBB/includes/feed/forums.php @@ -39,8 +39,6 @@ class phpbb_feed_forums extends phpbb_feed_base function get_sql() { - global $auth, $db; - $in_fid_ary = array_diff($this->get_readable_forums(), $this->get_excluded_forums()); if (empty($in_fid_ary)) { @@ -54,7 +52,7 @@ class phpbb_feed_forums extends phpbb_feed_base f.forum_topics, f.forum_posts', 'FROM' => array(FORUMS_TABLE => 'f'), 'WHERE' => 'f.forum_type = ' . FORUM_POST . ' - AND ' . $db->sql_in_set('f.forum_id', $in_fid_ary), + AND ' . $this->db->sql_in_set('f.forum_id', $in_fid_ary), 'ORDER_BY' => 'f.left_id ASC', ); @@ -63,16 +61,12 @@ class phpbb_feed_forums extends phpbb_feed_base function adjust_item(&$item_row, &$row) { - global $phpEx, $config; + $item_row['link'] = $this->helper->append_sid('/viewforum.' . $this->phpEx, 'f=' . $row['forum_id']); - $item_row['link'] = $this->helper->append_sid('/viewforum.' . $phpEx, 'f=' . $row['forum_id']); - - if ($config['feed_item_statistics']) + if ($this->config['feed_item_statistics']) { - global $user; - - $item_row['statistics'] = $user->lang('TOTAL_TOPICS', (int) $row['forum_topics']) - . ' ' . $this->separator_stats . ' ' . $user->lang('TOTAL_POSTS_COUNT', (int) $row['forum_posts']); + $item_row['statistics'] = $this->user->lang('TOTAL_TOPICS', (int) $row['forum_topics']) + . ' ' . $this->separator_stats . ' ' . $this->user->lang('TOTAL_POSTS_COUNT', (int) $row['forum_posts']); } } } diff --git a/phpBB/includes/feed/news.php b/phpBB/includes/feed/news.php index 12deb69ae4..92cc18a3ab 100644 --- a/phpBB/includes/feed/news.php +++ b/phpBB/includes/feed/news.php @@ -27,27 +27,26 @@ class phpbb_feed_news extends phpbb_feed_topic_base { function get_news_forums() { - global $db, $cache; static $forum_ids; // Matches acp/acp_board.php $cache_name = 'feed_news_forum_ids'; - if (!isset($forum_ids) && ($forum_ids = $cache->get('_' . $cache_name)) === false) + if (!isset($forum_ids) && ($forum_ids = $this->cache->get('_' . $cache_name)) === false) { $sql = 'SELECT forum_id FROM ' . FORUMS_TABLE . ' - WHERE ' . $db->sql_bit_and('forum_options', FORUM_OPTION_FEED_NEWS, '<> 0'); - $result = $db->sql_query($sql); + WHERE ' . $this->db->sql_bit_and('forum_options', FORUM_OPTION_FEED_NEWS, '<> 0'); + $result = $this->db->sql_query($sql); $forum_ids = array(); - while ($forum_id = (int) $db->sql_fetchfield('forum_id')) + while ($forum_id = (int) $this->db->sql_fetchfield('forum_id')) { $forum_ids[$forum_id] = $forum_id; } - $db->sql_freeresult($result); + $this->db->sql_freeresult($result); - $cache->put('_' . $cache_name, $forum_ids); + $this->cache->put('_' . $cache_name, $forum_ids); } return $forum_ids; @@ -55,8 +54,6 @@ class phpbb_feed_news extends phpbb_feed_topic_base function get_sql() { - global $auth, $config, $db; - // Determine forum ids $in_fid_ary = array_intersect($this->get_news_forums(), $this->get_readable_forums()); if (empty($in_fid_ary)) @@ -73,18 +70,18 @@ class phpbb_feed_news extends phpbb_feed_topic_base // We really have to get the post ids first! $sql = 'SELECT topic_first_post_id, topic_time FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $in_fid_ary) . ' + WHERE ' . $this->db->sql_in_set('forum_id', $in_fid_ary) . ' AND topic_moved_id = 0 AND topic_approved = 1 ORDER BY topic_time DESC'; - $result = $db->sql_query_limit($sql, $this->num_items); + $result = $this->db->sql_query_limit($sql, $this->num_items); $post_ids = array(); - while ($row = $db->sql_fetchrow($result)) + while ($row = $this->db->sql_fetchrow($result)) { $post_ids[] = (int) $row['topic_first_post_id']; } - $db->sql_freeresult($result); + $this->db->sql_freeresult($result); if (empty($post_ids)) { @@ -106,7 +103,7 @@ class phpbb_feed_news extends phpbb_feed_topic_base ), ), 'WHERE' => 'p.topic_id = t.topic_id - AND ' . $db->sql_in_set('p.post_id', $post_ids), + AND ' . $this->db->sql_in_set('p.post_id', $post_ids), 'ORDER_BY' => 'p.post_time DESC', ); diff --git a/phpBB/includes/feed/overall.php b/phpBB/includes/feed/overall.php index 630f67660a..5fb922f6bb 100644 --- a/phpBB/includes/feed/overall.php +++ b/phpBB/includes/feed/overall.php @@ -27,8 +27,6 @@ class phpbb_feed_overall extends phpbb_feed_post_base { function get_sql() { - global $auth, $db; - $forum_ids = array_diff($this->get_readable_forums(), $this->get_excluded_forums(), $this->get_passworded_forums()); if (empty($forum_ids)) { @@ -37,27 +35,27 @@ class phpbb_feed_overall extends phpbb_feed_post_base // m_approve forums $fid_m_approve = $this->get_moderator_approve_forums(); - $sql_m_approve = (!empty($fid_m_approve)) ? 'OR ' . $db->sql_in_set('forum_id', $fid_m_approve) : ''; + $sql_m_approve = (!empty($fid_m_approve)) ? 'OR ' . $this->db->sql_in_set('forum_id', $fid_m_approve) : ''; // Determine topics with recent activity $sql = 'SELECT topic_id, topic_last_post_time FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_ids) . ' + WHERE ' . $this->db->sql_in_set('forum_id', $forum_ids) . ' AND topic_moved_id = 0 AND (topic_approved = 1 ' . $sql_m_approve . ') ORDER BY topic_last_post_time DESC'; - $result = $db->sql_query_limit($sql, $this->num_items); + $result = $this->db->sql_query_limit($sql, $this->num_items); $topic_ids = array(); $min_post_time = 0; - while ($row = $db->sql_fetchrow()) + while ($row = $this->db->sql_fetchrow()) { $topic_ids[] = (int) $row['topic_id']; $min_post_time = (int) $row['topic_last_post_time']; } - $db->sql_freeresult($result); + $this->db->sql_freeresult($result); if (empty($topic_ids)) { @@ -79,7 +77,7 @@ class phpbb_feed_overall extends phpbb_feed_post_base 'ON' => 'f.forum_id = p.forum_id', ), ), - 'WHERE' => $db->sql_in_set('p.topic_id', $topic_ids) . ' + 'WHERE' => $this->db->sql_in_set('p.topic_id', $topic_ids) . ' AND (p.post_approved = 1 ' . str_replace('forum_id', 'p.forum_id', $sql_m_approve) . ') AND p.post_time >= ' . $min_post_time . ' diff --git a/phpBB/includes/feed/post_base.php b/phpBB/includes/feed/post_base.php index b4ce467b9c..bfcb4141ec 100644 --- a/phpBB/includes/feed/post_base.php +++ b/phpBB/includes/feed/post_base.php @@ -45,15 +45,13 @@ abstract class phpbb_feed_post_base extends phpbb_feed_base function adjust_item(&$item_row, &$row) { - global $phpEx, $config, $user; + $item_row['link'] = $this->helper->append_sid('/viewtopic.' . $this->phpEx, "t={$row['topic_id']}&p={$row['post_id']}#p{$row['post_id']}"); - $item_row['link'] = $this->helper->append_sid('/viewtopic.' . $phpEx, "t={$row['topic_id']}&p={$row['post_id']}#p{$row['post_id']}"); - - if ($config['feed_item_statistics']) + if ($this->config['feed_item_statistics']) { - $item_row['statistics'] = $user->lang['POSTED'] . ' ' . $user->lang['POST_BY_AUTHOR'] . ' ' . $this->user_viewprofile($row) - . ' ' . $this->separator_stats . ' ' . $user->format_date($row[$this->get('published')]) - . (($this->is_moderator_approve_forum($row['forum_id']) && !$row['post_approved']) ? ' ' . $this->separator_stats . ' ' . $user->lang['POST_UNAPPROVED'] : ''); + $item_row['statistics'] = $this->user->lang['POSTED'] . ' ' . $this->user->lang['POST_BY_AUTHOR'] . ' ' . $this->user_viewprofile($row) + . ' ' . $this->separator_stats . ' ' . $this->user->format_date($row[$this->get('published')]) + . (($this->is_moderator_approve_forum($row['forum_id']) && !$row['post_approved']) ? ' ' . $this->separator_stats . ' ' . $this->user->lang['POST_UNAPPROVED'] : ''); } } } diff --git a/phpBB/includes/feed/topic.php b/phpBB/includes/feed/topic.php index e4805e5539..7d9a344982 100644 --- a/phpBB/includes/feed/topic.php +++ b/phpBB/includes/feed/topic.php @@ -43,16 +43,14 @@ class phpbb_feed_topic extends phpbb_feed_post_base function open() { - global $auth, $db, $user; - $sql = 'SELECT f.forum_options, f.forum_password, t.topic_id, t.forum_id, t.topic_approved, t.topic_title, t.topic_time, t.topic_views, t.topic_replies, t.topic_type FROM ' . TOPICS_TABLE . ' t LEFT JOIN ' . FORUMS_TABLE . ' f ON (f.forum_id = t.forum_id) WHERE t.topic_id = ' . $this->topic_id; - $result = $db->sql_query($sql); - $this->topic_data = $db->sql_fetchrow($result); - $db->sql_freeresult($result); + $result = $this->db->sql_query($sql); + $this->topic_data = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); if (empty($this->topic_data)) { @@ -62,7 +60,7 @@ class phpbb_feed_topic extends phpbb_feed_post_base $this->forum_id = (int) $this->topic_data['forum_id']; // Make sure topic is either approved or user authed - if (!$this->topic_data['topic_approved'] && !$auth->acl_get('m_approve', $this->forum_id)) + if (!$this->topic_data['topic_approved'] && !$this->auth->acl_get('m_approve', $this->forum_id)) { trigger_error('SORRY_AUTH_READ'); } @@ -74,7 +72,7 @@ class phpbb_feed_topic extends phpbb_feed_post_base } // Make sure we can read this forum - if (!$auth->acl_get('f_read', $this->forum_id)) + if (!$this->auth->acl_get('f_read', $this->forum_id)) { trigger_error('SORRY_AUTH_READ'); } @@ -95,8 +93,6 @@ class phpbb_feed_topic extends phpbb_feed_post_base function get_sql() { - global $auth, $db; - $this->sql = array( 'SELECT' => 'p.post_id, p.post_time, p.post_edit_time, p.post_approved, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, ' . 'u.username, u.user_id', @@ -105,7 +101,7 @@ class phpbb_feed_topic extends phpbb_feed_post_base USERS_TABLE => 'u', ), 'WHERE' => 'p.topic_id = ' . $this->topic_id . ' - ' . ($this->forum_id && !$auth->acl_get('m_approve', $this->forum_id) ? 'AND p.post_approved = 1' : '') . ' + ' . ($this->forum_id && !$this->auth->acl_get('m_approve', $this->forum_id) ? 'AND p.post_approved = 1' : '') . ' AND p.poster_id = u.user_id', 'ORDER_BY' => 'p.post_time DESC', ); diff --git a/phpBB/includes/feed/topic_base.php b/phpBB/includes/feed/topic_base.php index 959ed5c469..0c845c30bd 100644 --- a/phpBB/includes/feed/topic_base.php +++ b/phpBB/includes/feed/topic_base.php @@ -45,17 +45,15 @@ abstract class phpbb_feed_topic_base extends phpbb_feed_base function adjust_item(&$item_row, &$row) { - global $phpEx, $config, $user; + $item_row['link'] = $this->helper->append_sid('/viewtopic.' . $this->phpEx, 't=' . $row['topic_id'] . '&p=' . $row['post_id'] . '#p' . $row['post_id']); - $item_row['link'] = $this->helper->append_sid('/viewtopic.' . $phpEx, 't=' . $row['topic_id'] . '&p=' . $row['post_id'] . '#p' . $row['post_id']); - - if ($config['feed_item_statistics']) + if ($this->config['feed_item_statistics']) { - $item_row['statistics'] = $user->lang['POSTED'] . ' ' . $user->lang['POST_BY_AUTHOR'] . ' ' . $this->user_viewprofile($row) - . ' ' . $this->separator_stats . ' ' . $user->format_date($row[$this->get('published')]) - . ' ' . $this->separator_stats . ' ' . $user->lang['REPLIES'] . ' ' . (($this->is_moderator_approve_forum($row['forum_id'])) ? $row['topic_replies_real'] : $row['topic_replies']) - . ' ' . $this->separator_stats . ' ' . $user->lang['VIEWS'] . ' ' . $row['topic_views'] - . (($this->is_moderator_approve_forum($row['forum_id']) && ($row['topic_replies_real'] != $row['topic_replies'])) ? ' ' . $this->separator_stats . ' ' . $user->lang['POSTS_UNAPPROVED'] : ''); + $item_row['statistics'] = $this->user->lang['POSTED'] . ' ' . $this->user->lang['POST_BY_AUTHOR'] . ' ' . $this->user_viewprofile($row) + . ' ' . $this->separator_stats . ' ' . $this->user->format_date($row[$this->get('published')]) + . ' ' . $this->separator_stats . ' ' . $this->user->lang['REPLIES'] . ' ' . (($this->is_moderator_approve_forum($row['forum_id'])) ? $row['topic_replies_real'] : $row['topic_replies']) + . ' ' . $this->separator_stats . ' ' . $this->user->lang['VIEWS'] . ' ' . $row['topic_views'] + . (($this->is_moderator_approve_forum($row['forum_id']) && ($row['topic_replies_real'] != $row['topic_replies'])) ? ' ' . $this->separator_stats . ' ' . $this->user->lang['POSTS_UNAPPROVED'] : ''); } } } diff --git a/phpBB/includes/feed/topics.php b/phpBB/includes/feed/topics.php index 7cd557ffcc..c8761d7176 100644 --- a/phpBB/includes/feed/topics.php +++ b/phpBB/includes/feed/topics.php @@ -27,8 +27,6 @@ class phpbb_feed_topics extends phpbb_feed_topic_base { function get_sql() { - global $db, $config; - $forum_ids_read = $this->get_readable_forums(); if (empty($forum_ids_read)) { @@ -44,18 +42,18 @@ class phpbb_feed_topics extends phpbb_feed_topic_base // We really have to get the post ids first! $sql = 'SELECT topic_first_post_id, topic_time FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $in_fid_ary) . ' + WHERE ' . $this->db->sql_in_set('forum_id', $in_fid_ary) . ' AND topic_moved_id = 0 AND topic_approved = 1 ORDER BY topic_time DESC'; - $result = $db->sql_query_limit($sql, $this->num_items); + $result = $this->db->sql_query_limit($sql, $this->num_items); $post_ids = array(); - while ($row = $db->sql_fetchrow($result)) + while ($row = $this->db->sql_fetchrow($result)) { $post_ids[] = (int) $row['topic_first_post_id']; } - $db->sql_freeresult($result); + $this->db->sql_freeresult($result); if (empty($post_ids)) { @@ -77,7 +75,7 @@ class phpbb_feed_topics extends phpbb_feed_topic_base ), ), 'WHERE' => 'p.topic_id = t.topic_id - AND ' . $db->sql_in_set('p.post_id', $post_ids), + AND ' . $this->db->sql_in_set('p.post_id', $post_ids), 'ORDER_BY' => 'p.post_time DESC', ); diff --git a/phpBB/includes/feed/topics_active.php b/phpBB/includes/feed/topics_active.php index 36b6bcb1a2..d1c920c136 100644 --- a/phpBB/includes/feed/topics_active.php +++ b/phpBB/includes/feed/topics_active.php @@ -38,8 +38,6 @@ class phpbb_feed_topics_active extends phpbb_feed_topic_base function get_sql() { - global $db, $config; - $forum_ids_read = $this->get_readable_forums(); if (empty($forum_ids_read)) { @@ -59,19 +57,19 @@ class phpbb_feed_topics_active extends phpbb_feed_topic_base // We really have to get the post ids first! $sql = 'SELECT topic_last_post_id, topic_last_post_time FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $in_fid_ary) . ' + WHERE ' . $this->db->sql_in_set('forum_id', $in_fid_ary) . ' AND topic_moved_id = 0 AND topic_approved = 1 ' . $last_post_time_sql . ' ORDER BY topic_last_post_time DESC'; - $result = $db->sql_query_limit($sql, $this->num_items); + $result = $this->db->sql_query_limit($sql, $this->num_items); $post_ids = array(); - while ($row = $db->sql_fetchrow($result)) + while ($row = $this->db->sql_fetchrow($result)) { $post_ids[] = (int) $row['topic_last_post_id']; } - $db->sql_freeresult($result); + $this->db->sql_freeresult($result); if (empty($post_ids)) { @@ -94,7 +92,7 @@ class phpbb_feed_topics_active extends phpbb_feed_topic_base ), ), 'WHERE' => 'p.topic_id = t.topic_id - AND ' . $db->sql_in_set('p.post_id', $post_ids), + AND ' . $this->db->sql_in_set('p.post_id', $post_ids), 'ORDER_BY' => 'p.post_time DESC', ); @@ -103,28 +101,27 @@ class phpbb_feed_topics_active extends phpbb_feed_topic_base function get_forum_ids() { - global $db, $cache; static $forum_ids; $cache_name = 'feed_topic_active_forum_ids'; - if (!isset($forum_ids) && ($forum_ids = $cache->get('_' . $cache_name)) === false) + if (!isset($forum_ids) && ($forum_ids = $this->cache->get('_' . $cache_name)) === false) { $sql = 'SELECT forum_id FROM ' . FORUMS_TABLE . ' WHERE forum_type = ' . FORUM_POST . ' - AND ' . $db->sql_bit_and('forum_options', FORUM_OPTION_FEED_EXCLUDE, '= 0') . ' - AND ' . $db->sql_bit_and('forum_flags', log(FORUM_FLAG_ACTIVE_TOPICS, 2), '<> 0'); - $result = $db->sql_query($sql); + AND ' . $this->db->sql_bit_and('forum_options', FORUM_OPTION_FEED_EXCLUDE, '= 0') . ' + AND ' . $this->db->sql_bit_and('forum_flags', log(FORUM_FLAG_ACTIVE_TOPICS, 2), '<> 0'); + $result = $this->db->sql_query($sql); $forum_ids = array(); - while ($forum_id = (int) $db->sql_fetchfield('forum_id')) + while ($forum_id = (int) $this->db->sql_fetchfield('forum_id')) { $forum_ids[$forum_id] = $forum_id; } - $db->sql_freeresult($result); + $this->db->sql_freeresult($result); - $cache->put('_' . $cache_name, $forum_ids, 180); + $this->cache->put('_' . $cache_name, $forum_ids, 180); } return $forum_ids;