Passed
Push — develop-3.3.x ( 5782d9...f10cd4 )
by Mario
03:04
created

auth_helper::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 4
dl 0
loc 11
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 *
4
 * PayPal Donation extension for the phpBB Forum Software package.
5
 *
6
 * @copyright (c) 2015-2020 Skouat
7
 * @license GNU General Public License, version 2 (GPL-2.0)
8
 *
9
 */
10
11
namespace skouat\ppde\helpers;
12
13
class auth_helper
14
{
15
	protected $auth;
16
	protected $phpbb_root_path;
17
	protected $php_ext;
18
	protected $config;
19
20
	/**
21
	 * currency constructor.
22
	 *
23
	 * @param \phpbb\auth\auth     $auth            Auth Auth object
24
	 * @param \phpbb\config\config $config          Config object
25
	 * @param string               $phpbb_root_path phpBB root path
26
	 * @param string               $php_ext         phpEx
27
	 *
28
	 * @access public
29
	 */
30
31
	public function __construct(
32
		\phpbb\auth\auth $auth,
33
		\phpbb\config\config $config,
34
		$phpbb_root_path,
35
		$php_ext
36
	)
37
	{
38
		$this->auth = $auth;
39
		$this->config = $config;
40
		$this->phpbb_root_path = $phpbb_root_path;
41
		$this->php_ext = $php_ext;
42
	}
43
44
	public function set_guest_acl(): void
45
	{
46
		if (!class_exists(\auth_admin::class))
47
		{
48
			include($this->phpbb_root_path . 'includes/acp/auth.' . $this->php_ext);
49
		}
50
		$auth_admin = new \auth_admin();
51
52
		$auth['u_ppde_use'] = (int) $this->config['ppde_allow_guest'];
53
		$auth['u_ppde_view_donorlist'] = (int) $this->config['ppde_ipn_dl_allow_guest'];
54
55
		$auth_admin->acl_set('user', [0], [ANONYMOUS], $auth);
56
	}
57
58
	/**
59
	 * @return bool
60
	 * @access public
61
	 */
62
	public function can_use_ppde(): bool
63
	{
64
		return $this->auth->acl_get('u_ppde_use');
65
	}
66
67
	/**
68
	 * @return bool
69
	 * @access public
70
	 */
71
	public function can_view_ppde_donorlist(): bool
72
	{
73
		return $this->auth->acl_get('u_ppde_view_donorlist');
74
	}
75
}
76