Completed
Push — develop ( cc7114...ef0a0d )
by Daniel
08:51
created

setup::get_access_key()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 *
4
 * @package sitemaker
5
 * @copyright (c) 2017 Daniel A. (blitze)
6
 * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
7
 *
8
 */
9
10
namespace blitze\sitemaker\services\filemanager;
11
12
/**
13
* @package sitemaker
14
*/
15
class setup
16
{
17
	/** @var \phpbb\auth\auth */
18
	protected $auth;
19
20
	/** @var \phpbb\config\config */
21
	protected $config;
22
23
	/** @var \phpbb\template\template */
24
	protected $template;
25
26
	/**
27
	 * Constructor
28
	 *
29
	 * @param \phpbb\auth\auth				$auth				Auth object
30
	 * @param \phpbb\config\config			$config				Config object
31
	 * @param \phpbb\template\template		$template			Template object
32
	 */
33 12
	public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\template\template $template)
34
	{
35 12
		$this->auth = $auth;
36 12
		$this->config = $config;
37 12
		$this->template = $template;
38 12
	}
39
40
	/**
41
	 * @return bool
42
	 */
43 4
	public function is_enabled()
44
	{
45 4
		return $this->config['sm_filemanager'] && $this->auth->acl_get('u_sm_filemanager');
46
	}
47
48
	/**
49
	 * @return void
50
	 */
51 4
	public function get_access_key()
52
	{
53 4
		return sha1($this->user->data['user_form_salt'] . 'filemanager');
0 ignored issues
show
Bug introduced by
The property user does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
54
	}
55
56
	/**
57
	 * @return array
58
	 */
59 4
	public function set_js_vars()
60
	{
61 4
		$this->template->assign_vars(array(
62 4
			'UA_FILEMANAGER'	=> $this->is_enabled(),
63 4
			'UA_RF_ACCESS_KEY'	=> $this->get_access_key(),
64 4
		));
65 4
	}
66
}
67