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