Completed
Push — master ( db7709...24ebcc )
by Daniel
10:24
created

member_menu::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 8
ccs 7
cts 7
cp 1
rs 9.4286
cc 1
eloc 6
nc 1
nop 5
crap 1
1
<?php
2
/**
3
 *
4
 * @package sitemaker
5
 * @copyright (c) 2013 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\blocks;
11
12
/**
13
 * Featured Member Block
14
 */
15
class member_menu extends \blitze\sitemaker\services\blocks\driver\block
16
{
17
	/** @var \phpbb\auth\auth */
18
	protected $auth;
19
20
	/** @var \phpbb\db\driver\driver_interface */
21
	protected $db;
22
23
	/** @var \phpbb\user */
24
	protected $user;
25
26
	/** @var string */
27
	protected $phpbb_root_path;
28
29
	/** @var string */
30
	protected $php_ext;
31
32
	/**
33
	 * Constructor
34
	 *
35
	 * @param \phpbb\auth\auth					$auth				Permission object
36
	 * @param \phpbb\db\driver\driver_interface	$db					Database connection
37
	 * @param \phpbb\user						$user				User object
38
	 * @param string							$phpbb_root_path	Path to the phpbb includes directory.
39
	 * @param string							$php_ext			php file extension
40
	 */
41 3
	public function __construct(\phpbb\auth\auth $auth, \phpbb\db\driver\driver_interface $db, \phpbb\user $user, $phpbb_root_path, $php_ext)
42
	{
43 3
		$this->auth = $auth;
44 3
		$this->db = $db;
45 3
		$this->user = $user;
46 3
		$this->phpbb_root_path = $phpbb_root_path;
47 3
		$this->php_ext = $php_ext;
48 3
	}
49
50
	/**
51
	 * {@inheritdoc}
52
	 */
53 2
	public function display(array $bdata, $edit_mode = false)
54
	{
55 2
		$content = '';
56 2
		if ($this->user->data['is_registered'])
57 2
		{
58 1
			$this->ptemplate->assign_vars(array(
59 1
				'USER_AVATAR'	=> phpbb_get_user_avatar($this->user->data),
60 1
				'USERNAME'		=> get_username_string('no_profile', $this->user->data['user_id'], $this->user->data['username'], $this->user->data['user_colour']),
61 1
				'USERNAME_FULL' => get_username_string('full', $this->user->data['user_id'], $this->user->data['username'], $this->user->data['user_colour']),
62
63 1
				'U_PROFILE'		=> append_sid($this->phpbb_root_path . 'memberlist.' . $this->php_ext, 'mode=viewprofile&amp;u=' . $this->user->data['user_id']),
64 1
				'U_SEARCH_NEW'	=> append_sid($this->phpbb_root_path . 'search.' . $this->php_ext, 'search_id=newposts'),
65 1
				'U_SEARCH_SELF'	=> append_sid($this->phpbb_root_path . 'search.' . $this->php_ext, 'search_id=egosearch'),
66 1
				'U_PRIVATE_MSG'	=> append_sid($this->phpbb_root_path . 'ucp.' . $this->php_ext, 'i=pm&amp;folder=inbox'),
67 1
				'U_LOGOUT'		=> append_sid($this->phpbb_root_path . 'ucp.' . $this->php_ext, 'mode=logout', true, $this->user->session_id),
68 1
				'U_MCP' 		=> ($this->auth->acl_get('m_')) ? append_sid($this->phpbb_root_path . 'mcp.' . $this->php_ext, false, true, $this->user->session_id) : '',
69 1
				'U_ACP'			=> ($this->auth->acl_get('a_')) ? append_sid($this->phpbb_root_path . 'adm/index.' . $this->php_ext, 'i=-blitze-sitemaker-acp-dashboard_module', true, $this->user->session_id) : '')
70 1
			);
71
72 1
			$content = $this->ptemplate->render_view('blitze/sitemaker', 'blocks/member_menu.html', 'member_menu_block');
73 1
		}
74
75
		return array(
76 2
			'title'		=> 'WELCOME',
77 2
			'content'	=> $content,
78 2
		);
79
	}
80
}
81