From a50e6c04d090488d4a43c2af1526af4164ab9d05 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 12 Feb 2015 22:24:36 +0100 Subject: [PATCH] [ticket/469] Make listener display portal if settings are set to true B3P-469 --- config/services.yml | 1 + event/listener.php | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/config/services.yml b/config/services.yml index 593fb918..df0d08a4 100644 --- a/config/services.yml +++ b/config/services.yml @@ -87,6 +87,7 @@ services: board3.portal.listener: class: board3\portal\event\listener arguments: + - @board3.portal.main - @auth - @config - @controller.helper diff --git a/event/listener.php b/event/listener.php index e31415e8..a529253e 100644 --- a/event/listener.php +++ b/event/listener.php @@ -13,6 +13,9 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; class listener implements EventSubscriberInterface { + /** @var \board3\portal\controller\main */ + protected $board3_controller; + /** @var \phpbb\auth\auth */ protected $auth; @@ -37,6 +40,7 @@ class listener implements EventSubscriberInterface /** * Constructor of Board3 Portal event listener * + * @param \board3\portal\controller\main $board3_controller Board3 Portal controller * @param \phpbb\auth\auth $auth phpBB auth object * @param \phpbb\config\config $config phpBB config * @param \phpbb\controller\helper $controller_helper Controller helper object @@ -45,8 +49,9 @@ class listener implements EventSubscriberInterface * @param \phpbb\user $user User object * @param string $php_ext phpEx */ - public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\controller\helper $controller_helper, \phpbb\path_helper $path_helper, \phpbb\template\template $template, \phpbb\user $user, $php_ext) + public function __construct(\board3\portal\controller\main $board3_controller, \phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\controller\helper $controller_helper, \phpbb\path_helper $path_helper, \phpbb\template\template $template, \phpbb\user $user, $php_ext) { + $this->board3_controller = $board3_controller; $this->auth = $auth; $this->config = $config; $this->controller_helper = $controller_helper; @@ -116,6 +121,7 @@ class listener implements EventSubscriberInterface if (strpos($this->user->data['session_page'], '/portal') === false) { $portal_link = $this->controller_helper->route('board3_portal_controller'); + $this->display_portal(); } else { @@ -136,4 +142,19 @@ class listener implements EventSubscriberInterface { return $this->auth->acl_get('u_view_portal') && $this->config['board3_enable']; } + + /** + * Display portal columns on all pages if specified in portal settings + */ + protected function display_portal() + { + // Check if we should show the portal + if (isset($this->config['board3_show_all_pages']) && ($this->config['board3_show_all_left'] || $this->config['board3_show_all_right']) && !defined('ADMIN_START')) + { + $this->board3_controller->handle(array( + 'left' => $this->config['board3_show_all_left'], + 'right' => $this->config['board3_show_all_right'], + )); + } + } }