Passed
Push — develop ( b3eda6...9f2d35 )
by Daniel
03:59 queued 40s
created

whois::get_template()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 0
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 *
5
 * @package sitemaker
6
 * @copyright (c) 2013 Daniel A. (blitze)
7
 * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
8
 *
9
 */
10
11
namespace blitze\sitemaker\blocks;
12
13
use blitze\sitemaker\services\blocks\driver\block;
14
15
/**
16
 * Whois Block
17
 */
18
class whois extends block
19
{
20
	/** @var \phpbb\auth\auth */
21
	protected $auth;
22
23
	/** @var \phpbb\config\config */
24
	protected $config;
25
26
	/** @var \phpbb\language\language */
27
	protected $translator;
28
29
	/** @var \phpbb\template\template */
30
	protected $template;
31
32
	/** @var \phpbb\user */
33
	protected $user;
34
35
	/** @var string */
36
	protected $phpbb_root_path;
37
38
	/** @var string */
39
	protected $php_ext;
40
41
	/**
42
	 * Constructor
43
	 *
44
	 * @param \phpbb\auth\auth					$auth				Permission object
45
	 * @param \phpbb\config\config				$config				phpBB configuration
46
	 * @param \phpbb\language\language			$translator			Language object
47
	 * @param \phpbb\template\template			$template			Template object
48
	 * @param \phpbb\user						$user				User object
49
	 * @param string							$phpbb_root_path	Path to the phpbb includes directory.
50
	 * @param string							$php_ext			php file extension
51 3
	 */
52
	public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\language\language $translator, \phpbb\template\template $template, \phpbb\user $user, $phpbb_root_path, $php_ext)
53 3
	{
54 3
		$this->auth = $auth;
55 3
		$this->config = $config;
56 3
		$this->translator = $translator;
57 3
		$this->template = $template;
58 3
		$this->user = $user;
59 3
		$this->phpbb_root_path = $phpbb_root_path;
60 3
		$this->php_ext = $php_ext;
61
	}
62
63
	/**
64
	 * {@inheritdoc}
65 2
	 */
66
	public function display(array $settings, $edit_mode = false)
67 2
	{
68
		$data = $this->template->retrieve_vars(array('TOTAL_USERS_ONLINE', 'LOGGED_IN_USER_LIST', 'RECORD_USERS'));
69 2
70 2
		if ($data['TOTAL_USERS_ONLINE'])
71 1
		{
72 1
			list($l_online_users, $online_userlist, $l_online_record) = array_values($data);
73
		}
74
		else
75 1
		{
76 1
			$item_id = 0;
77
			$item = 'forum';
78 1
79 1
			$online_users = obtain_users_online($item_id, $item);
80
			$user_online_strings = obtain_users_online_string($online_users, $item_id, $item);
81 1
82 1
			$l_online_users = $user_online_strings['l_online_users'];
83
			$online_userlist = $user_online_strings['online_userlist'];
84 1
85
			$l_online_record = $this->translator->lang('RECORD_ONLINE_USERS', (int) $this->config['record_online_users'], $this->user->format_date($this->config['record_online_date'], false, true));
86
		}
87 2
88
		$this->template->assign_var('S_DISPLAY_ONLINE_LIST', false);
89 2
90 2
		return array(
91 2
			'title'	=> 'WHO_IS_ONLINE',
92 2
			'data'	=> array(
93 2
				'TOTAL_USERS_ONLINE'	=> $l_online_users,
94 2
				'LOGGED_IN_USER_LIST'	=> $online_userlist,
95 2
				'RECORD_USERS'			=> $l_online_record,
96
				'U_VIEWONLINE'			=> $this->get_viewonline_url(),
97
			)
98 2
		);
99 2
	}
100 2
101
	/**
102
	 * @return string
103
	 */
104
	private function get_viewonline_url()
105
	{
106 2
		return ($this->auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel')) ? append_sid("{$this->phpbb_root_path}viewonline." . $this->php_ext) : '';
107
	}
108 2
109
	/**
110
	 * {@inheritdoc}
111
	 */
112
	public function get_template()
113
	{
114
		return '@blitze_sitemaker/blocks/whois.html';
115
	}
116
}
117