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
|
|
|
* Featured Member Block |
17
|
|
|
*/ |
18
|
|
|
class member_menu extends block |
19
|
|
|
{ |
20
|
|
|
/** @var \phpbb\auth\auth */ |
21
|
|
|
protected $auth; |
22
|
|
|
|
23
|
|
|
/** @var \phpbb\user */ |
24
|
|
|
protected $user; |
25
|
|
|
|
26
|
|
|
/** @var \blitze\sitemaker\services\forum\data */ |
27
|
|
|
protected $forum_data; |
28
|
|
|
|
29
|
|
|
/** @var \blitze\sitemaker\services\util */ |
30
|
|
|
protected $util; |
31
|
|
|
|
32
|
|
|
/** @var string */ |
33
|
|
|
protected $phpbb_root_path; |
34
|
|
|
|
35
|
|
|
/** @var string */ |
36
|
|
|
protected $php_ext; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Constructor |
40
|
|
|
* |
41
|
|
|
* @param \phpbb\auth\auth $auth Permission object |
42
|
|
|
* @param \phpbb\user $user User object |
43
|
|
|
* @param \blitze\sitemaker\services\forum\data $forum_data Forum Data object |
44
|
|
|
* @param \blitze\sitemaker\services\util $util utility Object |
45
|
|
|
* @param string $phpbb_root_path Path to the phpbb includes directory. |
46
|
|
|
* @param string $php_ext php file extension |
47
|
3 |
|
*/ |
48
|
|
|
public function __construct(\phpbb\auth\auth $auth, \phpbb\user $user, \blitze\sitemaker\services\forum\data $forum_data, \blitze\sitemaker\services\util $util, $phpbb_root_path, $php_ext) |
49
|
3 |
|
{ |
50
|
3 |
|
$this->auth = $auth; |
51
|
3 |
|
$this->user = $user; |
52
|
3 |
|
$this->forum_data = $forum_data; |
53
|
3 |
|
$this->util = $util; |
54
|
3 |
|
$this->phpbb_root_path = $phpbb_root_path; |
55
|
3 |
|
$this->php_ext = $php_ext; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* {@inheritdoc} |
60
|
2 |
|
*/ |
61
|
|
|
public function display(array $bdata, $edit_mode = false) |
62
|
2 |
|
{ |
63
|
2 |
|
$data = []; |
64
|
2 |
|
if ($this->user->data['is_registered']) |
65
|
1 |
|
{ |
66
|
1 |
|
$data = array( |
67
|
1 |
|
'USER_AVATAR' => $this->get_user_avatar(), |
68
|
1 |
|
'USERNAME' => get_username_string('full', $this->user->data['user_id'], $this->user->data['username'], $this->user->data['user_colour']), |
69
|
1 |
|
'USER_POSTS' => $this->user->data['user_posts'], |
70
|
|
|
'NEW_POSTS' => $this->get_new_posts_count(), |
71
|
1 |
|
|
72
|
1 |
|
'U_PROFILE' => append_sid($this->phpbb_root_path . 'memberlist.' . $this->php_ext, 'mode=viewprofile&u=' . $this->user->data['user_id']), |
73
|
1 |
|
'U_SEARCH_NEW' => append_sid($this->phpbb_root_path . 'search.' . $this->php_ext, 'search_id=newposts'), |
74
|
1 |
|
'U_SEARCH_SELF' => append_sid($this->phpbb_root_path . 'search.' . $this->php_ext, 'search_id=egosearch'), |
75
|
1 |
|
'U_PRIVATE_MSG' => append_sid($this->phpbb_root_path . 'ucp.' . $this->php_ext, 'i=pm&folder=inbox'), |
76
|
1 |
|
'U_LOGOUT' => append_sid($this->phpbb_root_path . 'ucp.' . $this->php_ext, 'mode=logout', true, $this->user->session_id), |
77
|
1 |
|
'U_MCP' => $this->get_mcp_url(), |
78
|
1 |
|
'U_ACP' => $this->get_acp_url(), |
79
|
|
|
); |
80
|
1 |
|
} |
81
|
1 |
|
|
82
|
|
|
return array( |
83
|
|
|
'title' => 'WELCOME', |
84
|
2 |
|
'data' => $data, |
85
|
2 |
|
); |
86
|
2 |
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @return string |
90
|
|
|
*/ |
91
|
|
|
protected function get_user_avatar() |
92
|
1 |
|
{ |
93
|
|
|
return ($this->user->data['user_avatar']) ? phpbb_get_user_avatar($this->user->data) : $this->util->get_default_avatar(); |
94
|
1 |
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @return string |
98
|
|
|
*/ |
99
|
|
|
protected function get_mcp_url() |
100
|
1 |
|
{ |
101
|
|
|
return ($this->auth->acl_get('m_')) ? append_sid($this->phpbb_root_path . 'mcp.' . $this->php_ext, false, true, $this->user->session_id) : ''; |
102
|
1 |
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @return string |
106
|
|
|
*/ |
107
|
|
|
protected function get_acp_url() |
108
|
1 |
|
{ |
109
|
|
|
return ($this->auth->acl_get('a_')) ? append_sid($this->phpbb_root_path . 'adm/index.' . $this->php_ext, 'i=-blitze-sitemaker-acp-menu_module', true, $this->user->session_id) : ''; |
110
|
1 |
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @return int |
114
|
|
|
*/ |
115
|
|
|
protected function get_new_posts_count() |
116
|
1 |
|
{ |
117
|
|
|
$sql_array = array( |
118
|
|
|
'FROM' => array( |
119
|
|
|
POSTS_TABLE => 'p', |
120
|
1 |
|
), |
121
|
1 |
|
'WHERE' => array( |
122
|
|
|
't.topic_id = p.topic_id AND p.post_time > ' . (int) $this->user->data['user_lastvisit'], |
123
|
1 |
|
), |
124
|
1 |
|
); |
125
|
1 |
|
|
126
|
|
|
$this->forum_data->query(false, false) |
127
|
1 |
|
->fetch_custom($sql_array) |
128
|
1 |
|
->build(true, false); |
129
|
1 |
|
|
130
|
|
|
return (int) $this->forum_data->get_topics_count(); |
131
|
1 |
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* {@inheritdoc} |
135
|
|
|
*/ |
136
|
|
|
public function get_template() |
137
|
|
|
{ |
138
|
|
|
return '@blitze_sitemaker/blocks/member_menu.html'; |
139
|
|
|
} |
140
|
|
|
} |
141
|
|
|
|