[ticket/207] Use different template var for redirect and fix portal link
This commit is contained in:
@@ -83,6 +83,7 @@ services:
|
||||
class: board3\portal\event\listener
|
||||
arguments:
|
||||
- @controller.helper
|
||||
- @path_helper
|
||||
- @template
|
||||
- @user
|
||||
- %core.php_ext%
|
||||
|
||||
@@ -16,6 +16,9 @@ class listener implements EventSubscriberInterface
|
||||
/** @var \phpbb\controller\helper */
|
||||
protected $controller_helper;
|
||||
|
||||
/** @var \phpbb\path_helper */
|
||||
protected $path_helper;
|
||||
|
||||
/** @var \phpbb\template\template */
|
||||
protected $template;
|
||||
|
||||
@@ -29,13 +32,15 @@ class listener implements EventSubscriberInterface
|
||||
* Constructor of Board3 Portal event listener
|
||||
*
|
||||
* @param \phpbb\controller\helper $controller_helper Controller helper object
|
||||
* @param \phpbb\path_helper $path_helper phpBB path helper
|
||||
* @param \phpbb\template\template $template Template object
|
||||
* @param \phpbb\user $user User object
|
||||
* @param string $php_ext phpEx
|
||||
*/
|
||||
public function __construct(\phpbb\controller\helper $controller_helper, \phpbb\template\template $template, \phpbb\user $user, $php_ext)
|
||||
public function __construct(\phpbb\controller\helper $controller_helper, \phpbb\path_helper $path_helper, \phpbb\template\template $template, \phpbb\user $user, $php_ext)
|
||||
{
|
||||
$this->controller_helper = $controller_helper;
|
||||
$this->path_helper = $path_helper;
|
||||
$this->template = $template;
|
||||
$this->user = $user;
|
||||
$this->php_ext = $php_ext;
|
||||
@@ -94,8 +99,17 @@ class listener implements EventSubscriberInterface
|
||||
*/
|
||||
public function add_portal_link($event)
|
||||
{
|
||||
if (strpos($this->user->data['session_page'], '/portal') === false)
|
||||
{
|
||||
$portal_link = $this->controller_helper->route('board3_controller');
|
||||
}
|
||||
else
|
||||
{
|
||||
$portal_link = $this->path_helper->remove_web_root_path($this->controller_helper->route('board3_controller'));
|
||||
}
|
||||
|
||||
$this->template->assign_vars(array(
|
||||
'U_PORTAL' => $this->controller_helper->route('board3_controller'),
|
||||
'U_PORTAL' => $portal_link,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ class user_menu extends module_base
|
||||
* redirect
|
||||
*/
|
||||
$this->template->assign_vars(array(
|
||||
'U_PORTAL' => $this->path_helper->remove_web_root_path($this->controller_helper->route('board3_controller')),
|
||||
'U_PORTAL_REDIRECT' => $this->path_helper->remove_web_root_path($this->controller_helper->route('board3_controller')),
|
||||
'S_DISPLAY_FULL_LOGIN' => true,
|
||||
'S_AUTOLOGIN_ENABLED' => ($this->config['allow_autologin']) ? true : false,
|
||||
'S_LOGIN_ACTION' => append_sid("{$this->phpbb_root_path}ucp.{$this->php_ext}", 'mode=login'),
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<br /><a href="{U_REGISTER}">{L_UM_REGISTER_NOW}</a><br />
|
||||
<!-- ENDIF -->
|
||||
<br />
|
||||
<input type="hidden" name="redirect" value="{U_PORTAL}" />
|
||||
<input type="hidden" name="redirect" value="{U_PORTAL_REDIRECT}" />
|
||||
<input type="submit" name="login" tabindex="5" value="{L_LOGIN}" class="button1" />
|
||||
{$LR_BLOCK_F_L}{$LR_BLOCK_F_R}
|
||||
</div>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<!-- ENDIF -->
|
||||
<!-- ENDIF -->
|
||||
<br />
|
||||
<input type="hidden" name="redirect" value="{U_PORTAL}" />
|
||||
<input type="hidden" name="redirect" value="{U_PORTAL_REDIRECT}" />
|
||||
<input type="submit" name="login" tabindex="5" value="{L_LOGIN}" class="button1" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -51,8 +51,19 @@ class listener_test extends \phpbb_template_template_test_case
|
||||
$provider->find(dirname(__FILE__) . '/');
|
||||
$this->controller_helper = new \phpbb_mock_controller_helper($this->template, $this->user, $this->config, $provider, $manager, '', 'php', dirname(__FILE__) . '/');
|
||||
|
||||
$this->path_helper = new \phpbb\path_helper(
|
||||
new \phpbb\symfony_request(
|
||||
new \phpbb_mock_request()
|
||||
),
|
||||
new \phpbb\filesystem(),
|
||||
new \phpbb_mock_request(),
|
||||
$this->phpbb_root_path,
|
||||
$this->php_ext
|
||||
);
|
||||
|
||||
$this->listener = new \board3\portal\event\listener(
|
||||
$this->controller_helper,
|
||||
$this->path_helper,
|
||||
$this->template,
|
||||
$this->user,
|
||||
'php'
|
||||
@@ -108,6 +119,11 @@ class listener_test extends \phpbb_template_template_test_case
|
||||
$result = $this->phpbb_dispatcher->trigger_event('core.page_header', compact($vars));
|
||||
|
||||
$this->assertEmpty($result);
|
||||
|
||||
$this->user->data['session_page'] = '/app.php/portal';
|
||||
$result = $this->phpbb_dispatcher->trigger_event('core.page_header', compact($vars));
|
||||
|
||||
$this->assertEmpty($result);
|
||||
}
|
||||
|
||||
public function test_load_portal_language()
|
||||
|
||||
Reference in New Issue
Block a user