diff options
-rw-r--r-- | phpBB/config/default/container/services_feed.yml | 8 | ||||
-rw-r--r-- | phpBB/phpbb/feed/base.php | 35 | ||||
-rw-r--r-- | phpBB/phpbb/feed/controller/feed.php | 24 |
3 files changed, 65 insertions, 2 deletions
diff --git a/phpBB/config/default/container/services_feed.yml b/phpBB/config/default/container/services_feed.yml index bec8649672..d3e7924f2f 100644 --- a/phpBB/config/default/container/services_feed.yml +++ b/phpBB/config/default/container/services_feed.yml @@ -11,6 +11,7 @@ services: - '@feed.helper' - '@user' - '@auth' + - '@dispatcher' - '%core.php_ext%' feed.helper: @@ -32,6 +33,7 @@ services: - '@user' - '@auth' - '@content.visibility' + - '@dispatcher' - '%core.php_ext%' feed.forums: @@ -45,6 +47,7 @@ services: - '@user' - '@auth' - '@content.visibility' + - '@dispatcher' - '%core.php_ext%' feed.news: @@ -58,6 +61,7 @@ services: - '@user' - '@auth' - '@content.visibility' + - '@dispatcher' - '%core.php_ext%' feed.overall: @@ -71,6 +75,7 @@ services: - '@user' - '@auth' - '@content.visibility' + - '@dispatcher' - '%core.php_ext%' feed.topic: @@ -84,6 +89,7 @@ services: - '@user' - '@auth' - '@content.visibility' + - '@dispatcher' - '%core.php_ext%' feed.topics: @@ -97,6 +103,7 @@ services: - '@user' - '@auth' - '@content.visibility' + - '@dispatcher' - '%core.php_ext%' feed.topics_active: @@ -110,4 +117,5 @@ services: - '@user' - '@auth' - '@content.visibility' + - '@dispatcher' - '%core.php_ext%' diff --git a/phpBB/phpbb/feed/base.php b/phpBB/phpbb/feed/base.php index 188d229515..d4be0dc592 100644 --- a/phpBB/phpbb/feed/base.php +++ b/phpBB/phpbb/feed/base.php @@ -39,6 +39,12 @@ abstract class base implements feed_interface /** @var \phpbb\auth\auth */ protected $auth; + /** @var \phpbb\content_visibility */ + protected $content_visibility; + + /** @var \phpbb\event\dispatcher_interface */ + protected $phpbb_dispatcher; + /** @var string */ protected $phpEx; @@ -80,9 +86,20 @@ abstract class base implements feed_interface * @param \phpbb\user $user User object * @param \phpbb\auth\auth $auth Auth object * @param \phpbb\content_visibility $content_visibility Auth object + * @param \phpbb\event\dispatcher_interface $phpbb_dispatcher Event dispatcher object * @param string $phpEx php file extension */ - public function __construct(\phpbb\feed\helper $helper, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\cache\driver\driver_interface $cache, \phpbb\user $user, \phpbb\auth\auth $auth, \phpbb\content_visibility $content_visibility, $phpEx) + public function __construct( + \phpbb\feed\helper $helper, + \phpbb\config\config $config, + \phpbb\db\driver\driver_interface $db, + \phpbb\cache\driver\driver_interface $cache, + \phpbb\user $user, + \phpbb\auth\auth $auth, + \phpbb\content_visibility $content_visibility, + \phpbb\event\dispatcher_interface $phpbb_dispatcher, + $phpEx + ) { $this->config = $config; $this->helper = $helper; @@ -91,6 +108,7 @@ abstract class base implements feed_interface $this->user = $user; $this->auth = $auth; $this->content_visibility = $content_visibility; + $this->phpbb_dispatcher = $phpbb_dispatcher; $this->phpEx = $phpEx; $this->set_keys(); @@ -161,6 +179,21 @@ abstract class base implements feed_interface return false; } + $sql_ary = $this->sql; + + /** + * Event to modify the feed item sql + * + * @event core.feed_base_modify_item_sql + * @var array sql_ary The SQL array to get the feed item data + * + * @since 3.1.10-RC1 + */ + $vars = array('sql_ary'); + extract($this->phpbb_dispatcher->trigger_event('core.feed_base_modify_item_sql', compact($vars))); + $this->sql = $sql_ary; + unset($sql_ary); + // Query database $sql = $this->db->sql_build_query('SELECT', $this->sql); $this->result = $this->db->sql_query_limit($sql, $this->num_items); diff --git a/phpBB/phpbb/feed/controller/feed.php b/phpBB/phpbb/feed/controller/feed.php index 31476b7317..c0d7bc72ec 100644 --- a/phpBB/phpbb/feed/controller/feed.php +++ b/phpBB/phpbb/feed/controller/feed.php @@ -16,6 +16,7 @@ namespace phpbb\feed\controller; use phpbb\auth\auth; use phpbb\config\config; use phpbb\db\driver\driver_interface; +use \phpbb\event\dispatcher_interface; use phpbb\exception\http_exception; use phpbb\feed\feed_interface; use phpbb\feed\exception\feed_unavailable_exception; @@ -76,6 +77,11 @@ class feed protected $auth; /** + * @var dispatcher_interface + */ + protected $phpbb_dispatcher; + + /** * @var string */ protected $php_ext; @@ -92,9 +98,10 @@ class feed * @param feed_helper $feed_helper * @param user $user * @param auth $auth + * @param dispatcher_interface $phpbb_dispatcher * @param string $php_ext */ - public function __construct(\Twig_Environment $twig, symfony_request $request, controller_helper $controller_helper, config $config, driver_interface $db, ContainerInterface $container, feed_helper $feed_helper, user $user, auth $auth, $php_ext) + public function __construct(\Twig_Environment $twig, symfony_request $request, controller_helper $controller_helper, config $config, driver_interface $db, ContainerInterface $container, feed_helper $feed_helper, user $user, auth $auth, dispatcher_interface $phpbb_dispatcher, $php_ext) { $this->request = $request; $this->controller_helper = $controller_helper; @@ -106,6 +113,7 @@ class feed $this->auth = $auth; $this->php_ext = $php_ext; $this->template = $twig; + $this->phpbb_dispatcher = $phpbb_dispatcher; } /** @@ -296,6 +304,20 @@ class feed // Iterate through items while ($row = $feed->get_item()) { + /** + * Event to modify the feed row + * + * @event core.feed_modify_feed_row + * @var int forum_id Forum ID + * @var string mode Feeds mode (forums|topics|topics_new|topics_active|news) + * @var array row Array with feed data + * @var int topic_id Topic ID + * + * @since 3.1.10-RC1 + */ + $vars = array('forum_id', 'mode', 'row', 'topic_id'); + extract($this->phpbb_dispatcher->trigger_event('core.feed_modify_feed_row', compact($vars))); + // BBCode options to correctly disable urls, smilies, bbcode... if ($feed->get('options') === null) { |