-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathlistener.php
More file actions
84 lines (68 loc) · 2.3 KB
/
listener.php
File metadata and controls
84 lines (68 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
/**
*
* @package Quick Login Extension
* @copyright (c) 2015 PayBas
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/
namespace paybas\quicklogin\event;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class listener implements EventSubscriberInterface
{
/** @var \phpbb\auth\auth */
protected $auth_provider_collection;
/** @var \phpbb\config\config */
protected $config;
/** @var \phpbb\template\template */
protected $template;
/** @var \phpbb\user */
protected $user;
/** @var string phpBB root path */
protected $root_path;
/** @var string PHP extension */
protected $phpEx;
public function __construct(\phpbb\auth\provider_collection $auth_provider_collection, \phpbb\config\config $config, \phpbb\template\template $template, \phpbb\user $user, $root_path, $phpEx)
{
$this->auth_provider_collection = $auth_provider_collection;
$this->config = $config;
$this->template = $template;
$this->user = $user;
$this->root_path = $root_path;
$this->phpEx = $phpEx;
}
static public function getSubscribedEvents()
{
return array(
'core.page_header_after' => 'quick_login',
);
}
/**
*/
public function quick_login()
{
if (!$this->user->data['is_registered'] && !$this->user->data['is_bot'])
{
$auth_provider = $this->auth_provider_collection->get_provider();
$auth_provider_data = $auth_provider->get_login_data();
if ($auth_provider_data)
{
if (isset($auth_provider_data['BLOCK_VAR_NAME']) && ($auth_provider_data['BLOCK_VAR_NAME'] == 'oauth'))
{
foreach ($auth_provider_data['BLOCK_VARS'] as $oauth_provider => $block_vars)
{
$oauth_provider = str_replace('auth.provider.oauth.service.', '', $oauth_provider);
$redirect_url = './ucp.php?mode=login&login=external&oauth_service='.$oauth_provider;
$block_vars['REDIRECT_URL'] = $redirect_url;
$this->template->assign_block_vars('ql_' . $auth_provider_data['BLOCK_VAR_NAME'], $block_vars);
}
}
}
$tpl_vars = array(
'S_QUICK_LOGIN' => true,
'U_SEND_PASSWORD_EXT' => ($this->config['email_enable']) ? append_sid("{$this->root_path}ucp.$this->phpEx", 'mode=sendpassword') : '',
);
$this->template->assign_vars($tpl_vars);
}
}
}