Passed
Push — renovate/configure ( c923d4...2c70da )
by
unknown
20:13
created

whois::get_template()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
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
	 */
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
	{
54
		$this->auth = $auth;
55
		$this->config = $config;
56
		$this->translator = $translator;
57
		$this->template = $template;
58
		$this->user = $user;
59
		$this->phpbb_root_path = $phpbb_root_path;
60
		$this->php_ext = $php_ext;
61
	}
62
63
	/**
64
	 * {@inheritdoc}
65
	 */
66
	public function display(array $settings, $edit_mode = false)
67
	{
68
		$data = $this->template->retrieve_vars(array('TOTAL_USERS_ONLINE', 'LOGGED_IN_USER_LIST', 'RECORD_USERS'));
69
70
		if ($data['TOTAL_USERS_ONLINE'])
71
		{
72
			list($l_online_users, $online_userlist, $l_online_record) = array_values($data);
73
		}
74
		else
75
		{
76
			$item_id = 0;
77
			$item = 'forum';
78
79
			$online_users = obtain_users_online($item_id, $item);
80
			$user_online_strings = obtain_users_online_string($online_users, $item_id, $item);
81
82
			$l_online_users = $user_online_strings['l_online_users'];
83
			$online_userlist = $user_online_strings['online_userlist'];
84
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
88
		$this->template->assign_var('S_DISPLAY_ONLINE_LIST', false);
89
90
		return array(
91
			'title'	=> 'WHO_IS_ONLINE',
92
			'data'	=> array(
93
				'TOTAL_USERS_ONLINE'	=> $l_online_users,
94
				'LOGGED_IN_USER_LIST'	=> $online_userlist,
95
				'RECORD_USERS'			=> $l_online_record,
96
				'U_VIEWONLINE'			=> $this->get_viewonline_url(),
97
			)
98
		);
99
	}
100
101
	/**
102
	 * @return string
103
	 */
104
	private function get_viewonline_url()
105
	{
106
		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
109
	/**
110
	 * {@inheritdoc}
111
	 */
112
	public function get_template()
113
	{
114
		return '@blitze_sitemaker/blocks/whois.html';
115
	}
116
}
117