|
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\services\users; |
|
11
|
|
|
|
|
12
|
|
|
abstract class contacts |
|
13
|
|
|
{ |
|
14
|
|
|
/** @var \phpbb\auth\auth */ |
|
15
|
|
|
protected $auth; |
|
16
|
|
|
|
|
17
|
|
|
/** @var \phpbb\config\config */ |
|
18
|
|
|
protected $config; |
|
19
|
|
|
|
|
20
|
|
|
/** @var \phpbb\language\language */ |
|
21
|
|
|
protected $translator; |
|
22
|
|
|
|
|
23
|
|
|
/** @var \phpbb\user */ |
|
24
|
|
|
protected $user; |
|
25
|
|
|
|
|
26
|
|
|
/** @var string */ |
|
27
|
|
|
protected $phpbb_root_path; |
|
28
|
|
|
|
|
29
|
|
|
/** @var string */ |
|
30
|
|
|
protected $php_ext; |
|
31
|
|
|
|
|
32
|
|
|
/** @var bool */ |
|
33
|
|
|
protected $mailto_allowed; |
|
34
|
|
|
|
|
35
|
|
|
/** @var bool */ |
|
36
|
|
|
protected $email_form_allowed; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Constructor |
|
40
|
|
|
* |
|
41
|
|
|
* @param \phpbb\auth\auth $auth Auth object |
|
42
|
|
|
* @param \phpbb\config\config $config Config object |
|
43
|
|
|
* @param \phpbb\language\language $translator Language object |
|
44
|
|
|
* @param \phpbb\user $user User Object |
|
45
|
|
|
* @param string $phpbb_root_path Path to the phpbb includes directory. |
|
46
|
|
|
* @param string $php_ext php file extension |
|
47
|
|
|
*/ |
|
48
|
88 |
|
public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\language\language $translator, \phpbb\user $user, $phpbb_root_path, $php_ext) |
|
49
|
|
|
{ |
|
50
|
88 |
|
$this->auth = $auth; |
|
51
|
88 |
|
$this->config = $config; |
|
52
|
88 |
|
$this->translator = $translator; |
|
53
|
88 |
|
$this->user = $user; |
|
54
|
88 |
|
$this->phpbb_root_path = $phpbb_root_path; |
|
55
|
88 |
|
$this->php_ext = $php_ext; |
|
56
|
|
|
|
|
57
|
88 |
|
$this->mailto_allowed = $this->get_mailto_allowed(); |
|
58
|
88 |
|
$this->email_form_allowed = $this->get_email_form_allowed(); |
|
59
|
88 |
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @param array $row |
|
63
|
|
|
* @return array |
|
64
|
|
|
*/ |
|
65
|
8 |
|
protected function get_email_contact(array $row) |
|
66
|
|
|
{ |
|
67
|
8 |
|
$email = array(); |
|
68
|
8 |
|
if ($this->user_email_allowed($row)) |
|
69
|
8 |
|
{ |
|
70
|
|
|
$email = array( |
|
71
|
8 |
|
'ID' => 'email', |
|
72
|
8 |
|
'NAME' => $this->translator->lang('SEND_EMAIL'), |
|
73
|
8 |
|
'U_CONTACT' => $this->get_email_url($row), |
|
74
|
8 |
|
); |
|
75
|
8 |
|
} |
|
76
|
|
|
|
|
77
|
8 |
|
return $email; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* @param array $row |
|
82
|
|
|
* @return bool |
|
83
|
|
|
*/ |
|
84
|
8 |
|
protected function user_email_allowed(array $row) |
|
85
|
|
|
{ |
|
86
|
8 |
|
return ((!empty($row['user_allow_viewemail']) && $this->auth->acl_get('u_sendemail')) || $this->auth->acl_get('a_email')) ? true : false; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @param array $row |
|
91
|
|
|
* @return string |
|
92
|
|
|
*/ |
|
93
|
8 |
|
protected function get_email_url(array $row) |
|
94
|
|
|
{ |
|
95
|
8 |
|
return ($this->email_form_allowed) ? append_sid("{$this->phpbb_root_path}memberlist.{$this->php_ext}", 'mode=email&u=' . $row['user_id']) : (($this->mailto_allowed) ? 'mailto:' . $row['user_email'] : ''); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* @return bool |
|
100
|
|
|
*/ |
|
101
|
88 |
|
protected function get_email_form_allowed() |
|
102
|
|
|
{ |
|
103
|
88 |
|
return ($this->config['board_email_form'] && $this->config['email_enable']) ? true : false; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* @return bool |
|
108
|
|
|
*/ |
|
109
|
88 |
|
protected function get_mailto_allowed() |
|
110
|
|
|
{ |
|
111
|
88 |
|
return ($this->config['board_hide_emails'] && !$this->auth->acl_get('a_email')) ? false : true; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* @param array $row |
|
116
|
|
|
* @return array |
|
117
|
|
|
*/ |
|
118
|
8 |
|
protected function get_jabber_contact(array $row) |
|
119
|
|
|
{ |
|
120
|
8 |
|
$jabber = array(); |
|
121
|
8 |
|
if ($this->user_can_jabber($row)) |
|
122
|
8 |
|
{ |
|
123
|
|
|
$jabber = array( |
|
124
|
|
|
'ID' => 'jabber', |
|
125
|
|
|
'NAME' => $this->translator->lang('JABBER'), |
|
126
|
|
|
'U_CONTACT' => append_sid("{$this->phpbb_root_path}memberlist.{$this->php_ext}", 'mode=contact&action=jabber&u=' . $row['user_id']), |
|
127
|
|
|
); |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
8 |
|
return $jabber; |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* @param array $row |
|
135
|
|
|
* @return bool |
|
136
|
|
|
*/ |
|
137
|
8 |
|
protected function user_can_jabber(array $row) |
|
138
|
|
|
{ |
|
139
|
8 |
|
return ($this->config['jab_enable'] && $row['user_jabber'] && $this->auth->acl_get('u_sendim')) ? true : false; |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
/** |
|
143
|
|
|
* @param array $row |
|
144
|
|
|
* @param array $can_receive_pm_list |
|
145
|
|
|
* @param array $permanently_banned_users |
|
146
|
|
|
* @return array |
|
147
|
|
|
*/ |
|
148
|
8 |
|
protected function get_pm_contact(array $row, array $can_receive_pm_list, array $permanently_banned_users) |
|
149
|
|
|
{ |
|
150
|
8 |
|
$pm = array(); |
|
151
|
8 |
|
if ($this->user_can_pm() && $this->can_receive_pm($row, $can_receive_pm_list, $permanently_banned_users)) |
|
152
|
8 |
|
{ |
|
153
|
|
|
$pm = array( |
|
154
|
|
|
'ID' => 'pm', |
|
155
|
|
|
'NAME' => $this->translator->lang('SEND_PRIVATE_MESSAGE'), |
|
156
|
|
|
'U_CONTACT' => append_sid("{$this->phpbb_root_path}ucp.{$this->php_ext}", 'i=pm&mode=compose&u=' . $row['user_id']), |
|
157
|
|
|
); |
|
158
|
|
|
} |
|
159
|
|
|
|
|
160
|
8 |
|
return $pm; |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
/** |
|
164
|
|
|
* @return bool |
|
165
|
|
|
*/ |
|
166
|
8 |
|
protected function user_can_pm() |
|
167
|
|
|
{ |
|
168
|
8 |
|
return ($this->config['allow_privmsg'] && $this->auth->acl_get('u_sendpm')) ? true : false; |
|
169
|
|
|
} |
|
170
|
|
|
|
|
171
|
|
|
/** |
|
172
|
|
|
* @param array $row |
|
173
|
|
|
* @param array $can_receive_pm_list |
|
174
|
|
|
* @param array $permanently_banned_users |
|
175
|
|
|
* @return bool |
|
176
|
|
|
*/ |
|
177
|
8 |
|
protected function can_receive_pm(array $row, array $can_receive_pm_list, array $permanently_banned_users) |
|
178
|
|
|
{ |
|
179
|
|
|
return ( |
|
180
|
|
|
// They must be a "normal" user |
|
181
|
8 |
|
$row['user_type'] != USER_IGNORE && |
|
182
|
|
|
|
|
183
|
|
|
// They must not be deactivated by the administrator |
|
184
|
8 |
|
($row['user_type'] != USER_INACTIVE || $row['user_inactive_reason'] != INACTIVE_MANUAL) && |
|
185
|
|
|
|
|
186
|
|
|
// They must be able to read PMs |
|
187
|
8 |
|
in_array($row['user_id'], $can_receive_pm_list) && |
|
188
|
|
|
|
|
189
|
|
|
// They must not be permanently banned |
|
190
|
8 |
|
!in_array($row['user_id'], $permanently_banned_users) && |
|
191
|
|
|
|
|
192
|
|
|
// They must allow users to contact via PM |
|
193
|
8 |
|
(($this->auth->acl_gets('a_', 'm_') || $this->auth->acl_getf_global('m_')) || $row['allow_pm']) |
|
194
|
8 |
|
); |
|
195
|
|
|
} |
|
196
|
|
|
|
|
197
|
|
|
/** |
|
198
|
|
|
* Get the list of users who can receive private messages |
|
199
|
|
|
* |
|
200
|
|
|
* @param array $user_ids |
|
201
|
|
|
* @return array |
|
202
|
|
|
*/ |
|
203
|
8 |
|
protected function get_can_receive_pm_list(array $user_ids) |
|
204
|
|
|
{ |
|
205
|
8 |
|
$can_receive_pm_list = $this->auth->acl_get_list($user_ids, 'u_readpm'); |
|
206
|
8 |
|
return (empty($can_receive_pm_list) || !isset($can_receive_pm_list[0]['u_readpm'])) ? array() : $can_receive_pm_list[0]['u_readpm']; |
|
207
|
|
|
} |
|
208
|
|
|
|
|
209
|
|
|
/** |
|
210
|
|
|
* Get the list of permanently banned users |
|
211
|
|
|
* |
|
212
|
|
|
* @param array $user_ids |
|
213
|
|
|
* @return array |
|
214
|
|
|
*/ |
|
215
|
8 |
|
protected function get_banned_users_list(array $user_ids) |
|
216
|
|
|
{ |
|
217
|
8 |
|
if (!function_exists('phpbb_get_banned_user_ids')) |
|
218
|
8 |
|
{ |
|
219
|
1 |
|
include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext); |
|
220
|
1 |
|
} |
|
221
|
|
|
|
|
222
|
8 |
|
return phpbb_get_banned_user_ids($user_ids, false); |
|
223
|
|
|
} |
|
224
|
|
|
} |
|
225
|
|
|
|