[ticket/469] Make listener display portal if settings are set to true

B3P-469
This commit is contained in:
Marc Alexander
2015-02-12 22:24:36 +01:00
parent e4861caed8
commit a50e6c04d0
2 changed files with 23 additions and 1 deletions

View File

@@ -87,6 +87,7 @@ services:
board3.portal.listener: board3.portal.listener:
class: board3\portal\event\listener class: board3\portal\event\listener
arguments: arguments:
- @board3.portal.main
- @auth - @auth
- @config - @config
- @controller.helper - @controller.helper

View File

@@ -13,6 +13,9 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class listener implements EventSubscriberInterface class listener implements EventSubscriberInterface
{ {
/** @var \board3\portal\controller\main */
protected $board3_controller;
/** @var \phpbb\auth\auth */ /** @var \phpbb\auth\auth */
protected $auth; protected $auth;
@@ -37,6 +40,7 @@ class listener implements EventSubscriberInterface
/** /**
* Constructor of Board3 Portal event listener * 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\auth\auth $auth phpBB auth object
* @param \phpbb\config\config $config phpBB config * @param \phpbb\config\config $config phpBB config
* @param \phpbb\controller\helper $controller_helper Controller helper object * @param \phpbb\controller\helper $controller_helper Controller helper object
@@ -45,8 +49,9 @@ class listener implements EventSubscriberInterface
* @param \phpbb\user $user User object * @param \phpbb\user $user User object
* @param string $php_ext phpEx * @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->auth = $auth;
$this->config = $config; $this->config = $config;
$this->controller_helper = $controller_helper; $this->controller_helper = $controller_helper;
@@ -116,6 +121,7 @@ class listener implements EventSubscriberInterface
if (strpos($this->user->data['session_page'], '/portal') === false) if (strpos($this->user->data['session_page'], '/portal') === false)
{ {
$portal_link = $this->controller_helper->route('board3_portal_controller'); $portal_link = $this->controller_helper->route('board3_portal_controller');
$this->display_portal();
} }
else else
{ {
@@ -136,4 +142,19 @@ class listener implements EventSubscriberInterface
{ {
return $this->auth->acl_get('u_view_portal') && $this->config['board3_enable']; 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'],
));
}
}
} }