|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* |
|
4
|
|
|
* Member Avatar & Status [MAS]. An extension for the phpBB Forum Software package. |
|
5
|
|
|
* |
|
6
|
|
|
* @copyright (c) 2018-2020, Dark❶ [dark1] |
|
7
|
|
|
* @license GNU General Public License, version 2 (GPL-2.0-only) |
|
8
|
|
|
* |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace dark1\memberavatarstatus\core; |
|
12
|
|
|
|
|
13
|
|
|
use phpbb\auth\auth; |
|
14
|
|
|
use phpbb\config\config; |
|
15
|
|
|
use phpbb\language\language; |
|
16
|
|
|
use phpbb\log\log; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Member Avatar & Status Event listener. |
|
20
|
|
|
*/ |
|
21
|
|
|
class memberavatarstatus |
|
22
|
|
|
{ |
|
23
|
|
|
/** @var int No Avatar Size */ |
|
24
|
|
|
const NO_AVATAR_SIZE = 1000; |
|
25
|
|
|
|
|
26
|
|
|
/** @var int Avatar Minimum Size */ |
|
27
|
|
|
const AV_MIN_SZ = 9; |
|
28
|
|
|
|
|
29
|
|
|
/** @var int Avatar Default Size Small */ |
|
30
|
|
|
const AV_DEF_SZ_SML = 20; |
|
31
|
|
|
|
|
32
|
|
|
/** @var int Avatar Default Size Big */ |
|
33
|
|
|
const AV_DEF_SZ_BIG = 50; |
|
34
|
|
|
|
|
35
|
|
|
/** @var int Avatar Maximum Size Small */ |
|
36
|
|
|
const AV_MAX_SZ_SML = 99; |
|
37
|
|
|
|
|
38
|
|
|
/** @var int Avatar Maximum Size Big */ |
|
39
|
|
|
const AV_MAX_SZ_BIG = 999; |
|
40
|
|
|
|
|
41
|
|
|
/** @var int Color Default Offline */ |
|
42
|
|
|
const COL_DEF_OFF = '000000'; |
|
43
|
|
|
|
|
44
|
|
|
/** @var int Color Default Online */ |
|
45
|
|
|
const COL_DEF_ON = '00FF00'; |
|
46
|
|
|
|
|
47
|
|
|
/** @var \phpbb\auth\auth */ |
|
48
|
|
|
protected $auth; |
|
49
|
|
|
|
|
50
|
|
|
/** @var \phpbb\config\config */ |
|
51
|
|
|
protected $config; |
|
52
|
|
|
|
|
53
|
|
|
/** @var \phpbb\language\language */ |
|
54
|
|
|
protected $language; |
|
55
|
|
|
|
|
56
|
|
|
/** @var \phpbb\log\log */ |
|
57
|
|
|
protected $phpbb_log; |
|
58
|
|
|
|
|
59
|
|
|
/** @var string */ |
|
60
|
|
|
protected $phpbb_root_path; |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Constructor for listener |
|
64
|
|
|
* |
|
65
|
|
|
* @param \phpbb\auth\auth $auth phpBB auth |
|
66
|
|
|
* @param \phpbb\config\config $config phpBB config |
|
67
|
|
|
* @param \phpbb\language\language $language phpBB language |
|
68
|
|
|
* @param \phpbb\log\log $phpbb_log phpBB log |
|
69
|
|
|
* @param string $phpbb_root_path phpBB root_path |
|
70
|
|
|
* @access public |
|
71
|
|
|
*/ |
|
72
|
|
|
public function __construct(auth $auth, config $config, language $language, log $phpbb_log, $phpbb_root_path) |
|
73
|
|
|
{ |
|
74
|
|
|
$this->auth = $auth; |
|
75
|
|
|
$this->config = $config; |
|
76
|
|
|
$this->language = $language; |
|
77
|
|
|
$this->phpbb_log = $phpbb_log; |
|
78
|
|
|
$this->phpbb_root_path = $phpbb_root_path; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
|
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* MAS Get No Avatar IMG |
|
85
|
|
|
* |
|
86
|
|
|
* @param void |
|
87
|
|
|
* @return string String with No Avatar IMG |
|
88
|
|
|
* @access public |
|
89
|
|
|
*/ |
|
90
|
|
|
public function mas_get_no_avatar_img() |
|
91
|
|
|
{ |
|
92
|
|
|
$avatar_row = array( |
|
93
|
|
|
'avatar' => append_sid($this->phpbb_root_path . 'ext/dark1/memberavatarstatus/image/avatar.png'), |
|
94
|
|
|
'avatar_type' => AVATAR_REMOTE, |
|
95
|
|
|
'avatar_width' => self::NO_AVATAR_SIZE, |
|
96
|
|
|
'avatar_height' => self::NO_AVATAR_SIZE, |
|
97
|
|
|
); |
|
98
|
|
|
return str_replace( |
|
99
|
|
|
'" />', |
|
100
|
|
|
'" title="' . $this->language->lang('MAS_NO_AVATAR_TEXT') . '" />', |
|
101
|
|
|
phpbb_get_user_avatar($avatar_row, $this->language->lang('MAS_NO_AVATAR_TEXT'), true) |
|
102
|
|
|
); |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
|
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* MAS Get Config Avatar |
|
109
|
|
|
* |
|
110
|
|
|
* @param string $config_key takes Config Key String |
|
111
|
|
|
* @return bool Bool with Avatar Enable |
|
112
|
|
|
* @access public |
|
113
|
|
|
*/ |
|
114
|
|
|
public function mas_get_config_avatar($config_key) |
|
115
|
|
|
{ |
|
116
|
|
|
// Check if Avatar is Enabled. |
|
117
|
|
|
return (bool) ($this->config['allow_avatar'] && $this->config['dark1_mas_avatar'] && $this->config[$config_key]); |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
|
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* MAS Get Config Online |
|
124
|
|
|
* |
|
125
|
|
|
* @param string $config_key takes Config Key String |
|
126
|
|
|
* @return bool Bool with Online Enable |
|
127
|
|
|
* @access public |
|
128
|
|
|
*/ |
|
129
|
|
|
public function mas_get_config_online($config_key) |
|
130
|
|
|
{ |
|
131
|
|
|
// Check if Online is Enabled. |
|
132
|
|
|
return (bool) ($this->config['load_onlinetrack'] && $this->config['dark1_mas_online'] && $this->config[$config_key]); |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
|
|
136
|
|
|
|
|
137
|
|
|
/** |
|
138
|
|
|
* MAS Get Config Online/Offline Color |
|
139
|
|
|
* |
|
140
|
|
|
* @param string $key takes `on/off` String |
|
141
|
|
|
* @param string $color takes Hex Color String |
|
142
|
|
|
* @return string String with Hex Color |
|
143
|
|
|
* @access public |
|
144
|
|
|
*/ |
|
145
|
|
|
public function mas_config_color($key, $color) |
|
146
|
|
|
{ |
|
147
|
|
|
// Check if Color is in Hexadecimal else Default. |
|
148
|
|
|
if (!preg_match('/^([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/', $color)) |
|
149
|
|
|
{ |
|
150
|
|
|
$color = (strtoupper($key) === 'ON') ? self::COL_DEF_ON : self::COL_DEF_OFF ; |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
return $color; |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
|
|
157
|
|
|
|
|
158
|
|
|
/** |
|
159
|
|
|
* MAS Get Config Online/Offline Color |
|
160
|
|
|
* |
|
161
|
|
|
* @param string $key takes `on/off` String |
|
162
|
|
|
* @return string String with Hex Color |
|
163
|
|
|
* @access public |
|
164
|
|
|
*/ |
|
165
|
|
|
public function mas_get_config_color($key) |
|
166
|
|
|
{ |
|
167
|
|
|
return $this->mas_config_color($key, $this->config['dark1_mas_col_' . $key]); |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
|
|
|
171
|
|
|
|
|
172
|
|
|
/** |
|
173
|
|
|
* MAS Get Avatar SQL Query |
|
174
|
|
|
* |
|
175
|
|
|
* @param array $sql_ary takes SQL Array |
|
176
|
|
|
* @param string $config_key takes Config Key String |
|
177
|
|
|
* @param string $sql_uid Specifies User ID to be Matched with. |
|
178
|
|
|
* @param string $sql_obj Specifies SQL Object |
|
179
|
|
|
* @param string $prefix Specifies the prefix to be Set in SQL Select |
|
180
|
|
|
* @param string $lj_on_ex Specifies the Left Join On Extra SQL Query |
|
181
|
|
|
* @return array Array of data |
|
182
|
|
|
* @access public |
|
183
|
|
|
*/ |
|
184
|
|
|
public function mas_avatar_sql_query($sql_ary, $config_key, $sql_uid, $sql_obj, $prefix, $lj_on_ex) |
|
185
|
|
|
{ |
|
186
|
|
|
$config_key .= '_av'; |
|
187
|
|
|
$prefix .= ($prefix != '') ? '_' : ''; |
|
188
|
|
|
|
|
189
|
|
|
if ($this->mas_get_config_avatar($config_key)) |
|
190
|
|
|
{ |
|
191
|
|
|
$sql_ary['SELECT'] .= ', ' . $sql_obj . '.user_avatar as ' . $prefix . 'avatar, ' . $sql_obj . '.user_avatar_type as ' . $prefix . 'avatar_type, ' . $sql_obj . '.user_avatar_width as ' . $prefix . 'avatar_width, ' . $sql_obj . '.user_avatar_height as ' . $prefix . 'avatar_height'; |
|
192
|
|
|
$sql_ary['LEFT_JOIN'][] = array( |
|
193
|
|
|
'FROM' => array(USERS_TABLE => $sql_obj), |
|
194
|
|
|
'ON' => $sql_uid . ' = ' . $sql_obj . '.user_id' . $lj_on_ex, |
|
195
|
|
|
); |
|
196
|
|
|
} |
|
197
|
|
|
|
|
198
|
|
|
return $sql_ary; |
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
|
|
|
|
202
|
|
|
|
|
203
|
|
|
/** |
|
204
|
|
|
* MAS Get Avatar Size |
|
205
|
|
|
* |
|
206
|
|
|
* @param int $av_sz takes Avatar Size |
|
207
|
|
|
* @param int $av_default_sz Specifies Default Size in px |
|
208
|
|
|
* @param int $av_max_sz Specifies Avatar MAX Size in px |
|
209
|
|
|
* @return int Integer with Avatar Size in px |
|
210
|
|
|
* @access public |
|
211
|
|
|
*/ |
|
212
|
|
|
public function mas_get_avatar_size($av_sz, $av_default_sz = self::AV_DEF_SZ_SML, $av_max_sz = self::AV_MAX_SZ_SML) |
|
213
|
|
|
{ |
|
214
|
|
|
// $av_sz , Need to set this between self::AV_MIN_SZ to $av_max_sz Only , Default is $av_default_sz. |
|
215
|
|
|
if ($av_sz < self::AV_MIN_SZ || $av_sz > $av_max_sz) |
|
216
|
|
|
{ |
|
217
|
|
|
$av_sz = $av_default_sz; |
|
218
|
|
|
} |
|
219
|
|
|
return (int) $av_sz; |
|
220
|
|
|
} |
|
221
|
|
|
|
|
222
|
|
|
|
|
223
|
|
|
|
|
224
|
|
|
/** |
|
225
|
|
|
* MAS Get Config Avatar Size |
|
226
|
|
|
* |
|
227
|
|
|
* @param string $config_key takes Config Key String |
|
228
|
|
|
* @param int $av_default_sz Specifies Default Size in px |
|
229
|
|
|
* @param int $av_max_sz Specifies Avatar MAX Size in px |
|
230
|
|
|
* @return int Integer with Avatar Size in px |
|
231
|
|
|
* @access public |
|
232
|
|
|
*/ |
|
233
|
|
|
public function mas_get_config_avatar_size($config_key, $av_default_sz = self::AV_DEF_SZ_SML, $av_max_sz = self::AV_MAX_SZ_SML) |
|
234
|
|
|
{ |
|
235
|
|
|
|
|
236
|
|
|
// config -> dark1_mas_XX_sz , Need to set this between self::AV_MIN_SZ to $av_max_sz Only , Default is $av_default_sz. |
|
237
|
|
|
$av_sz = $this->mas_get_avatar_size((int) $this->config[$config_key], $av_default_sz, $av_max_sz); |
|
238
|
|
|
|
|
239
|
|
|
// Check if correction is done then set it. |
|
240
|
|
|
if ($av_sz != $this->config[$config_key]) |
|
241
|
|
|
{ |
|
242
|
|
|
$this->config->set($config_key, $av_sz); |
|
243
|
|
|
$this->phpbb_log->add('admin', '', '', 'MAS_LOG_CONFIG', time(), array($config_key, $this->language->lang('MAS_ERR_AV_SIZE'), $av_default_sz)); |
|
244
|
|
|
} |
|
245
|
|
|
return (int) $this->config[$config_key]; |
|
246
|
|
|
} |
|
247
|
|
|
|
|
248
|
|
|
|
|
249
|
|
|
|
|
250
|
|
|
/** |
|
251
|
|
|
* MAS Get Avatar |
|
252
|
|
|
* |
|
253
|
|
|
* @param string $config_key takes Config Key String |
|
254
|
|
|
* @param string $prefix Specifies the prefix to be Searched in the $row |
|
255
|
|
|
* @param array $row is array of data |
|
256
|
|
|
* @return string String with Avatar Data |
|
257
|
|
|
* @access public |
|
258
|
|
|
*/ |
|
259
|
|
|
public function mas_get_avatar($config_key, $prefix, $row) |
|
260
|
|
|
{ |
|
261
|
|
|
$avatar = ''; |
|
262
|
|
|
$config_key .= '_av'; |
|
263
|
|
|
$prefix .= ($prefix != '') ? '_' : ''; |
|
264
|
|
|
|
|
265
|
|
|
if ($this->mas_get_config_avatar($config_key)) |
|
266
|
|
|
{ |
|
267
|
|
|
// $avatar_row |
|
268
|
|
|
$avatar_row = array( |
|
269
|
|
|
'avatar' => $row[$prefix . 'avatar'], |
|
270
|
|
|
'avatar_type' => $row[$prefix . 'avatar_type'], |
|
271
|
|
|
'avatar_width' => $row[$prefix . 'avatar_width'], |
|
272
|
|
|
'avatar_height' => $row[$prefix . 'avatar_height'], |
|
273
|
|
|
); |
|
274
|
|
|
$avatar = phpbb_get_user_avatar($avatar_row); |
|
275
|
|
|
} |
|
276
|
|
|
|
|
277
|
|
|
return $avatar; |
|
278
|
|
|
} |
|
279
|
|
|
|
|
280
|
|
|
|
|
281
|
|
|
|
|
282
|
|
|
/** |
|
283
|
|
|
* MAS Get Online SQL Query |
|
284
|
|
|
* |
|
285
|
|
|
* @param array $sql_ary takes SQL Array |
|
286
|
|
|
* @param string $config_key takes Config Key String |
|
287
|
|
|
* @param string $sql_uid Specifies User ID to be Matched with. |
|
288
|
|
|
* @param string $sql_obj Specifies SQL Object |
|
289
|
|
|
* @param string $prefix Specifies the prefix to be Set in SQL Select |
|
290
|
|
|
* @param string $lj_on_ex Specifies the Left Join On Extra SQL Query |
|
291
|
|
|
* @param string $group_by Specifies the Group By SQL Query |
|
292
|
|
|
* @return array Array of data |
|
293
|
|
|
* @access public |
|
294
|
|
|
*/ |
|
295
|
|
|
public function mas_online_sql_query($sql_ary, $config_key, $sql_uid, $sql_obj, $prefix, $lj_on_ex, $group_by) |
|
296
|
|
|
{ |
|
297
|
|
|
$config_key .= '_ol'; |
|
298
|
|
|
$prefix .= ($prefix != '') ? '_' : ''; |
|
299
|
|
|
|
|
300
|
|
|
if ($this->mas_get_config_online($config_key)) |
|
301
|
|
|
{ |
|
302
|
|
|
$sql_ary['SELECT'] .= ', MAX(' . $sql_obj . '.session_time) as ' . $prefix . 'session_time, MIN(' . $sql_obj . '.session_viewonline) as ' . $prefix . 'session_viewonline'; |
|
303
|
|
|
$sql_ary['LEFT_JOIN'][] = array( |
|
304
|
|
|
'FROM' => array(SESSIONS_TABLE => $sql_obj), |
|
305
|
|
|
'ON' => $sql_uid . ' = ' . $sql_obj . '.session_user_id AND ' . $sql_obj . '.session_time >= ' . (time() - ($this->config['load_online_time'] * 60)) . ' AND ' . $sql_obj . '.session_user_id <> ' . ANONYMOUS . $lj_on_ex, |
|
306
|
|
|
); |
|
307
|
|
|
|
|
308
|
|
|
if ($group_by != '') |
|
309
|
|
|
{ |
|
310
|
|
|
$sql_ary['GROUP_BY'] = (isset($sql_ary['GROUP_BY']) && !empty($sql_ary['GROUP_BY'])) ? $sql_ary['GROUP_BY'] . ', '.$group_by : $group_by; |
|
311
|
|
|
} |
|
312
|
|
|
} |
|
313
|
|
|
|
|
314
|
|
|
return $sql_ary; |
|
315
|
|
|
} |
|
316
|
|
|
|
|
317
|
|
|
|
|
318
|
|
|
|
|
319
|
|
|
/** |
|
320
|
|
|
* MAS Get Online Status |
|
321
|
|
|
* |
|
322
|
|
|
* @param array $online_row takes user details to find Online Status |
|
323
|
|
|
* @return bool Bool Online Status |
|
324
|
|
|
* @access public |
|
325
|
|
|
*/ |
|
326
|
|
|
public function mas_get_online_status($online_row) |
|
327
|
|
|
{ |
|
328
|
|
|
$online = false; |
|
329
|
|
|
|
|
330
|
|
|
if ($this->mas_get_config_online('dark1_mas_online')) |
|
331
|
|
|
{ |
|
332
|
|
|
$online = (time() - ($this->config['load_online_time'] * 60) < $online_row['session_time'] && ((isset($online_row['session_viewonline']) && $online_row['session_viewonline']) || $this->auth->acl_get('u_viewonline'))) ? true : false; |
|
333
|
|
|
} |
|
334
|
|
|
|
|
335
|
|
|
return (bool) $online; |
|
336
|
|
|
} |
|
337
|
|
|
|
|
338
|
|
|
|
|
339
|
|
|
|
|
340
|
|
|
/** |
|
341
|
|
|
* MAS Get Online |
|
342
|
|
|
* |
|
343
|
|
|
* @param string $config_key takes Config Key String |
|
344
|
|
|
* @param string $prefix Specifies the prefix to be Searched in the $row |
|
345
|
|
|
* @param array $row is array of data |
|
346
|
|
|
* @return string String with Online Data |
|
347
|
|
|
* @access public |
|
348
|
|
|
*/ |
|
349
|
|
|
public function mas_get_online($config_key, $prefix, $row) |
|
350
|
|
|
{ |
|
351
|
|
|
$online = ''; |
|
352
|
|
|
$config_key .= '_ol'; |
|
353
|
|
|
$prefix .= ($prefix != '') ? '_' : ''; |
|
354
|
|
|
|
|
355
|
|
|
if ($this->mas_get_config_online($config_key)) |
|
356
|
|
|
{ |
|
357
|
|
|
$online_row = array( |
|
358
|
|
|
'session_time' => $row[$prefix . 'session_time'], |
|
359
|
|
|
'session_viewonline' => $row[$prefix . 'session_viewonline'], |
|
360
|
|
|
); |
|
361
|
|
|
$online = $this->mas_get_online_status($online_row); |
|
362
|
|
|
} |
|
363
|
|
|
|
|
364
|
|
|
return $online; |
|
365
|
|
|
} |
|
366
|
|
|
|
|
367
|
|
|
|
|
368
|
|
|
|
|
369
|
|
|
/** |
|
370
|
|
|
* MAS Get converted simple SQL strings in array |
|
371
|
|
|
* |
|
372
|
|
|
* @param array $sql_ary takes SQL Array |
|
373
|
|
|
* @return array Array of data |
|
374
|
|
|
* @access public |
|
375
|
|
|
*/ |
|
376
|
|
|
public function mas_convert_sql($sql_ary) |
|
377
|
|
|
{ |
|
378
|
|
|
$sql_select = $sql_ary['SELECT']; |
|
379
|
|
|
$sql_from = ''; |
|
380
|
|
|
$sql_where = ''; |
|
381
|
|
|
|
|
382
|
|
|
if (!empty($sql_ary['LEFT_JOIN'])) |
|
383
|
|
|
{ |
|
384
|
|
|
foreach ($sql_ary['LEFT_JOIN'] as $join) |
|
385
|
|
|
{ |
|
386
|
|
|
if (!empty($join)) |
|
387
|
|
|
{ |
|
388
|
|
|
$sql_from .= ' LEFT JOIN ' . key($join['FROM']) . ' ' . current($join['FROM']) . ' ON (' . $join['ON'] . ')'; |
|
389
|
|
|
} |
|
390
|
|
|
} |
|
391
|
|
|
} |
|
392
|
|
|
|
|
393
|
|
|
if (!empty($sql_ary['GROUP_BY'])) |
|
394
|
|
|
{ |
|
395
|
|
|
$sql_where = ' GROUP BY ' . $sql_ary['GROUP_BY']; |
|
396
|
|
|
} |
|
397
|
|
|
|
|
398
|
|
|
return array( |
|
399
|
|
|
'sql_select' => $sql_select, |
|
400
|
|
|
'sql_from' => $sql_from, |
|
401
|
|
|
'sql_where' => $sql_where, |
|
402
|
|
|
); |
|
403
|
|
|
} |
|
404
|
|
|
|
|
405
|
|
|
|
|
406
|
|
|
|
|
407
|
|
|
// Following Functions Will be Deprecated in future when Style Template Events are created. |
|
408
|
|
|
|
|
409
|
|
|
|
|
410
|
|
|
|
|
411
|
|
|
/** |
|
412
|
|
|
* MAS Get Avatar IMG |
|
413
|
|
|
* |
|
414
|
|
|
* @param string $avatar takes User Avatar IMG |
|
415
|
|
|
* @param int $avatar_size Specifies Avatar Size in px |
|
416
|
|
|
* @return string String with Wrapped User Avatar IMG |
|
417
|
|
|
* @access public |
|
418
|
|
|
* |
|
419
|
|
|
* Will be Deprecated in future when Style Template Events are created. |
|
420
|
|
|
*/ |
|
421
|
|
|
public function mas_get_avatar_img($avatar, $avatar_size = self::AV_DEF_SZ_SML) |
|
422
|
|
|
{ |
|
423
|
|
|
$start_avatar = '<div class="mas-avatar" style="width: ' . $avatar_size . 'px; height: ' . $avatar_size . 'px;">'; |
|
424
|
|
|
$end_avatar = '</div>'; |
|
425
|
|
|
return $start_avatar . (($avatar) ? $avatar : $this->mas_get_no_avatar_img()) . $end_avatar; |
|
426
|
|
|
} |
|
427
|
|
|
|
|
428
|
|
|
|
|
429
|
|
|
|
|
430
|
|
|
/** |
|
431
|
|
|
* MAS Get Online Status DOT |
|
432
|
|
|
* |
|
433
|
|
|
* @param string $online takes User Online Status |
|
434
|
|
|
* @return string String with Wrapped User Online Status |
|
435
|
|
|
* @access public |
|
436
|
|
|
* |
|
437
|
|
|
* Will be Deprecated in future when Style Template Events are created. |
|
438
|
|
|
*/ |
|
439
|
|
|
public function mas_get_online_status_dot($online) |
|
440
|
|
|
{ |
|
441
|
|
|
$online_text = $this->language->lang('ONLINE'); |
|
442
|
|
|
$offline_text = $this->language->lang('OFFLINE'); |
|
443
|
|
|
$start_online = ' ' . '<div class="mas-wrap-status' . ($online ? ' mas-status-online' : '') . '">'; |
|
444
|
|
|
$end_online = '</div>'; |
|
445
|
|
|
$online_dot = '<span class="mas-status-dot mas-color" title="' . ($online ? $online_text : $offline_text) . '"/>'; |
|
446
|
|
|
return $start_online . $online_dot . $end_online; |
|
447
|
|
|
} |
|
448
|
|
|
|
|
449
|
|
|
|
|
450
|
|
|
|
|
451
|
|
|
/** |
|
452
|
|
|
* MAS Get UserName Wrap |
|
453
|
|
|
* |
|
454
|
|
|
* @param string $username takes UserName |
|
455
|
|
|
* @param string $config_key takes Config Key String |
|
456
|
|
|
* @param string $avatar takes User Avatar IMG |
|
457
|
|
|
* @param string $online takes User Online Status |
|
458
|
|
|
* @return string String with Wrapped Main & UserName |
|
459
|
|
|
* @access public |
|
460
|
|
|
* |
|
461
|
|
|
* Will be Deprecated in future when Style Template Events are created. |
|
462
|
|
|
*/ |
|
463
|
|
|
public function mas_get_username_wrap($username, $config_key, $avatar, $online) |
|
464
|
|
|
{ |
|
465
|
|
|
$start_wrap = '<div class="mas-wrap">'; |
|
466
|
|
|
$start_username = '<div class="mas-username">'; |
|
467
|
|
|
$end_tag = '</div>'; |
|
468
|
|
|
$avatar_test = $this->mas_get_config_avatar($config_key . '_av'); |
|
469
|
|
|
$online_test = $this->mas_get_config_online($config_key . '_ol'); |
|
470
|
|
|
$avatar_wrap = ($avatar_test) ? $this->mas_get_avatar_img($avatar, (int) $this->config[$config_key . '_av_sz']) : ''; |
|
471
|
|
|
$online_wrap = ($online_test) ? $this->mas_get_online_status_dot($online) : ''; |
|
472
|
|
|
return ($avatar_test || $online_test) ? ($start_wrap . $avatar_wrap . $start_username . $username . $end_tag . $online_wrap . $end_tag) : $username; |
|
473
|
|
|
} |
|
474
|
|
|
|
|
475
|
|
|
} |
|
476
|
|
|
|