Passed
Push — 3.3.x ( 3f7215...fbaa03 )
by Mario
04:04 queued 11s
created

auth::set_guest_acl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 6
rs 10
c 1
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\actions;
12
13
class auth
14
{
15
	protected $auth;
16
	protected $auth_admin;
17
	protected $phpbb_root_path;
18
	protected $php_ext;
19
	protected $config;
20
21
	/**
22
	 * currency constructor.
23
	 *
24
	 * @param \phpbb\auth\auth     $auth            Auth Auth object
25
	 * @param \phpbb\config\config $config          Config object
26
	 * @param string               $phpbb_root_path phpBB root path
27
	 * @param string               $php_ext         phpEx
28
	 *
29
	 * @access public
30
	 */
31
32
	public function __construct(
33
		\phpbb\auth\auth $auth,
34
		\phpbb\config\config $config,
35
		$phpbb_root_path,
36
		$php_ext
37
	)
38
	{
39
		$this->auth = $auth;
40
		$this->config = $config;
41
		$this->phpbb_root_path = $phpbb_root_path;
42
		$this->php_ext = $php_ext;
43
44
		if (!class_exists('auth_admin'))
45
		{
46
			include($this->phpbb_root_path . 'includes/acp/auth.' . $this->php_ext);
47
		}
48
		$this->auth_admin = new \auth_admin();
49
	}
50
51
	public function set_guest_acl()
52
	{
53
		$auth['u_ppde_use'] = (int) $this->config['ppde_allow_guest'];
1 ignored issue
show
Comprehensibility Best Practice introduced by
$auth was never initialized. Although not strictly required by PHP, it is generally a good practice to add $auth = array(); before regardless.
Loading history...
54
		$auth['u_ppde_view_donorlist'] = (int) $this->config['ppde_ipn_dl_allow_guest'];
55
56
		$this->auth_admin->acl_set('user', [0], [ANONYMOUS], $auth);
57
	}
58
59
	/**
60
	 * @return bool
61
	 * @access public
62
	 */
63
	public function can_use_ppde()
64
	{
65
		return $this->auth->acl_get('u_ppde_use');
66
	}
67
68
	/**
69
	 * @return bool
70
	 * @access public
71
	 */
72
	public function can_view_ppde_donorlist()
73
	{
74
		return $this->auth->acl_get('u_ppde_view_donorlist');
75
	}
76
}
77