Completed
Push — develop ( 733603...f85365 )
by Daniel
15:29 queued 09:35
created

whois::get_viewonline_url()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

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