1
|
|
|
<?php namespace Xoopsmodules\smallworld; |
2
|
|
|
/** |
3
|
|
|
* You may not change or alter any portion of this comment or credits |
4
|
|
|
* of supporting developers from this source code or any supporting source code |
5
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
6
|
|
|
* |
7
|
|
|
* This program is distributed in the hope that it will be useful, |
8
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
9
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* SmallWorld |
14
|
|
|
* |
15
|
|
|
* @copyright The XOOPS Project (https://xoops.org) |
16
|
|
|
* @copyright 2011 Culex |
17
|
|
|
* @license GNU GPL (http://www.gnu.org/licenses/gpl-2.0.html/) |
18
|
|
|
* @package SmallWorld |
19
|
|
|
* @since 1.0 |
20
|
|
|
* @author Michael Albertsen (http://culex.dk) <[email protected]> |
21
|
|
|
*/ |
22
|
|
|
|
23
|
|
|
//include_once $GLOBALS['xoops']->path('include/common.php'); |
24
|
|
|
|
25
|
|
|
// Moderated and fitted from the tutorial by Srinivas Tamada http://9lessons.info |
26
|
|
|
|
27
|
|
|
class WallUpdates |
28
|
|
|
{ |
29
|
|
|
/** |
30
|
|
|
* @return array |
31
|
|
|
*/ |
32
|
|
|
private function getAdminModerators() |
|
|
|
|
33
|
|
|
{ |
34
|
|
|
global $xoopsDB, $xoopsUser; |
35
|
|
|
$data = []; |
36
|
|
|
$sql = 'SELECT userid |
37
|
|
|
FROM ' . $xoopsDB->prefix('smallworld_user') . ' su |
38
|
|
|
LEFT JOIN ' . $xoopsDB->prefix('groups_users_link') . ' xu ON su.userid = xu.uid |
39
|
|
|
WHERE xu.uid IN (1)'; |
40
|
|
|
$result = $xoopsDB->queryF($sql); |
41
|
|
|
while ($row = $xoopsDB->fetchArray($result)) { |
42
|
|
|
$data[] = $row; |
43
|
|
|
} |
44
|
|
|
return $data; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @param $last |
49
|
|
|
* @param $uid |
50
|
|
|
* @param $followers |
51
|
|
|
* @return array|bool |
|
|
|
|
52
|
|
|
*/ |
53
|
|
View Code Duplication |
public function Updates($last, $uid, $followers) |
|
|
|
|
54
|
|
|
{ |
55
|
|
|
global $xoopsUser, $xoopsDB, $moduleConfig; |
56
|
|
|
$query = ''; |
57
|
|
|
$hm = smallworld_GetModuleOption('msgtoshow'); |
58
|
|
|
$set = smallworld_checkPrivateOrPublic(); |
|
|
|
|
59
|
|
|
$followers = is_array($followers) ? $followers : [$followers]; |
60
|
|
|
$followers = array_unique(Smallworld_array_flatten($followers, 0)); |
61
|
|
|
|
62
|
|
|
$i = 0; |
63
|
|
|
if (0 == $last) { |
64
|
|
|
$query = 'SELECT M.msg_id, M.uid_fk, M.priv, M.message, M.created, U.username FROM ' . $xoopsDB->prefix('smallworld_messages') . ' M, ' . $xoopsDB->prefix('smallworld_user') . " U WHERE M.uid_fk=U.userid AND M.uid_fk='" . $uid . "'"; |
65
|
|
|
} elseif ($last > 0) { |
66
|
|
|
$query = 'SELECT M.msg_id, M.uid_fk, M.priv, M.message, M.created, U.username FROM ' . $xoopsDB->prefix('smallworld_messages') . ' M, ' . $xoopsDB->prefix('smallworld_user') . " U WHERE M.uid_fk=U.userid AND M.uid_fk='" . $uid . "' AND M.msg_id < '" . $last . "'"; |
67
|
|
|
} elseif ('a' === $last) { |
68
|
|
|
$query = 'SELECT M.msg_id, M.uid_fk, M.priv, M.message, M.created, U.username FROM ' . $xoopsDB->prefix('smallworld_messages') . ' M, ' . $xoopsDB->prefix('smallworld_user') . " U WHERE M.uid_fk=U.userid AND M.uid_fk='" . $uid . "'"; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
if (is_array($followers)) { |
72
|
|
|
foreach ($followers as $k => $v) { |
73
|
|
|
if ($last > 0) { |
74
|
|
|
$query .= " OR M.uid_fk=U.userid and M.uid_fk= '" . $v . "' and M.msg_id < '" . $last . "'"; |
75
|
|
|
} elseif (0 == $last) { |
76
|
|
|
$query .= " OR M.uid_fk=U.userid and M.uid_fk= '" . $v . "'"; |
77
|
|
|
} elseif ('a' === $last) { |
78
|
|
|
$query .= " OR M.uid_fk=U.userid and M.uid_fk= '" . $v . "'"; |
79
|
|
|
} |
80
|
|
|
++$i; |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
if (!is_array($followers)) { |
84
|
|
|
$followers = $uid; |
85
|
|
|
if ($last > 0) { |
86
|
|
|
$query .= " OR M.uid_fk=U.userid and M.uid_fk= '" . $followers . "' and M.msg_id < '" . $last . "'"; |
87
|
|
|
} elseif (0 == $last) { |
88
|
|
|
$query .= " OR M.uid_fk=U.userid and M.uid_fk= '" . $followers . "'"; |
89
|
|
|
} elseif ('a' === $last) { |
90
|
|
|
$query .= " OR M.uid_fk=U.userid and M.uid_fk= '" . $followers . "'"; |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
if ($last > 0) { |
95
|
|
|
$query .= ' order by created DESC LIMIT ' . $hm; |
96
|
|
|
} elseif ('a' === $last) { |
97
|
|
|
$query .= ' order by M.msg_id DESC LIMIT ' . $hm; |
98
|
|
|
} else { |
99
|
|
|
$query .= ' order by created DESC LIMIT ' . $hm; |
100
|
|
|
} |
101
|
|
|
$result = $xoopsDB->queryF($query); |
102
|
|
|
$count = $xoopsDB->getRowsNum($result); |
103
|
|
|
if (0 == $count) { |
104
|
|
|
return false; |
105
|
|
|
} else { |
106
|
|
|
while ($row = $xoopsDB->fetchArray($result)) { |
107
|
|
|
$data[] = $row; |
|
|
|
|
108
|
|
|
} |
109
|
|
|
if (!empty($data)) { |
110
|
|
|
return $data; |
111
|
|
|
} |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @Get comments based on msg id |
117
|
|
|
* @param int $msg_id |
118
|
|
|
* @return array |
|
|
|
|
119
|
|
|
*/ |
120
|
|
View Code Duplication |
public function Comments($msg_id) |
|
|
|
|
121
|
|
|
{ |
122
|
|
|
global $xoopsUser, $xoopsDB; |
123
|
|
|
$query = 'SELECT C.msg_id_fk, C.com_id, C.uid_fk, C.comment, C.created, U.username FROM ' . $xoopsDB->prefix('smallworld_comments') . ' C, ' . $xoopsDB->prefix('smallworld_user') . " U WHERE C.uid_fk=U.userid AND C.msg_id_fk='" . $msg_id . "' ORDER BY C.com_id ASC "; |
124
|
|
|
$result = $xoopsDB->queryF($query); |
125
|
|
|
$i = $xoopsDB->getRowsNum($result); |
|
|
|
|
126
|
|
|
while ($row = $xoopsDB->fetchArray($result)) { |
127
|
|
|
$data[] = $row; |
|
|
|
|
128
|
|
|
} |
129
|
|
|
if (!empty($data)) { |
130
|
|
|
return $data; |
131
|
|
|
} |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* @Get user image based on uid |
136
|
|
|
* @param int $uid |
137
|
|
|
* @return string |
138
|
|
|
*/ |
139
|
|
View Code Duplication |
public function Gravatar($uid) |
|
|
|
|
140
|
|
|
{ |
141
|
|
|
global $xoopsUser, $xoopsDB; |
142
|
|
|
$image = ''; |
143
|
|
|
$sql = 'SELECT userimage FROM ' . $xoopsDB->prefix('smallworld_user') . " WHERE userid = '" . $uid . "'"; |
144
|
|
|
$result = $xoopsDB->queryF($sql); |
145
|
|
|
while ($r = $xoopsDB->fetchArray($result)) { |
146
|
|
|
$image = $r['userimage']; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
$image = ('' == $image || 'blank.gif' === $image) ? smallworld_getAvatarLink($uid, $image) : $image; |
150
|
|
|
|
151
|
|
|
$type = [ |
152
|
|
|
1 => 'jpg', |
153
|
|
|
2 => 'jpeg', |
154
|
|
|
3 => 'png', |
155
|
|
|
4 => 'gif' |
156
|
|
|
]; |
157
|
|
|
|
158
|
|
|
$ext = explode('.', $image); |
159
|
|
|
|
160
|
|
|
if (@!in_array(strtolower($ext[1]), $type) || '' == $image) { |
161
|
|
|
$avatar = ''; |
162
|
|
|
} else { |
163
|
|
|
$avatar = $image; |
164
|
|
|
} |
165
|
|
|
return $avatar; |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
/** |
169
|
|
|
* @Insert update |
170
|
|
|
* @param int $uid |
171
|
|
|
* @param string|array $update |
172
|
|
|
* @param int $priv |
173
|
|
|
* @return array|bool |
|
|
|
|
174
|
|
|
*/ |
175
|
|
View Code Duplication |
public function Insert_Update($uid, $update, $priv) |
|
|
|
|
176
|
|
|
{ |
177
|
|
|
global $xoopsUser, $xoopsDB; |
178
|
|
|
$update = Smallworld_sanitize(htmlentities($update, ENT_QUOTES, 'UTF-8')); |
179
|
|
|
$time = time(); |
180
|
|
|
if (!isset($priv)) { |
181
|
|
|
$priv = 0; |
182
|
|
|
} |
183
|
|
|
$query = 'SELECT msg_id,message FROM ' . $xoopsDB->prefix('smallworld_messages') . " WHERE uid_fk='" . $uid . "' ORDER BY msg_id DESC LIMIT 1"; |
184
|
|
|
$result = $xoopsDB->queryF($query); |
185
|
|
|
$row = $xoopsDB->fetchArray($result); |
186
|
|
|
if ($update != $row['message']) { |
187
|
|
|
$query = 'INSERT INTO ' . $xoopsDB->prefix('smallworld_messages') . " (message, uid_fk, priv, created) VALUES ('" . $update . "', '" . $uid . "', '" . $priv . "', '" . $time . "')"; |
188
|
|
|
$result = $xoopsDB->queryF($query); |
|
|
|
|
189
|
|
|
$newquery = 'SELECT M.msg_id, M.uid_fk, M.priv, M.message, M.created, U.username FROM ' . $xoopsDB->prefix('smallworld_messages') . ' M, ' . $xoopsDB->prefix('smallworld_user') . " U WHERE M.uid_fk=U.userid AND M.uid_fk='" . $uid . "' ORDER BY M.msg_id DESC LIMIT 1 "; |
190
|
|
|
$result2 = $xoopsDB->queryF($newquery); |
191
|
|
|
while ($row = $xoopsDB->fetchArray($result2)) { |
192
|
|
|
$data[] = $row; |
|
|
|
|
193
|
|
|
} |
194
|
|
|
$count = $xoopsDB->getRowsNum($result2); |
195
|
|
|
if ($count < 1) { |
196
|
|
|
return false; |
197
|
|
|
} else { |
198
|
|
|
while ($row = $xoopsDB->fetchArray($result2)) { |
199
|
|
|
$data[] = $row; |
|
|
|
|
200
|
|
|
} |
201
|
|
|
if (!empty($data)) { |
202
|
|
|
return $data; |
203
|
|
|
} |
204
|
|
|
} |
205
|
|
|
} |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
/** |
209
|
|
|
* @Insert comment |
210
|
|
|
* @param int $uid |
211
|
|
|
* @param int $msg_id |
212
|
|
|
* @param string|array $comment |
213
|
|
|
* @return string / void |
214
|
|
|
*/ |
215
|
|
View Code Duplication |
public function Insert_Comment($uid, $msg_id, $comment) |
|
|
|
|
216
|
|
|
{ |
217
|
|
|
global $xoopsUser, $xoopsDB; |
218
|
|
|
$comment = Smallworld_sanitize(htmlentities($comment, ENT_QUOTES, 'UTF-8')); |
219
|
|
|
$time = time(); |
220
|
|
|
$query = 'SELECT com_id,comment FROM ' . $xoopsDB->prefix('smallworld_comments') . " WHERE uid_fk='" . $uid . "' AND msg_id_fk='" . $msg_id . "' ORDER BY com_id DESC LIMIT 1 "; |
221
|
|
|
$result = $xoopsDB->fetchArray($query); |
222
|
|
|
if ($comment != $result['comment']) { |
223
|
|
|
$query = 'INSERT INTO ' . $xoopsDB->prefix('smallworld_comments') . " (comment, uid_fk,msg_id_fk,created) VALUES ('" . $comment . "', '" . $uid . "','" . $msg_id . "', '" . $time . "')"; |
224
|
|
|
$result = $xoopsDB->queryF($query); |
|
|
|
|
225
|
|
|
$newquery = 'SELECT C.com_id, C.uid_fk, C.comment, C.msg_id_fk, C.created, U.username FROM ' |
226
|
|
|
. $xoopsDB->prefix('smallworld_comments') |
227
|
|
|
. ' C, ' |
228
|
|
|
. $xoopsDB->prefix('smallworld_user') |
229
|
|
|
. " U WHERE C.uid_fk=U.userid AND C.uid_fk='" |
230
|
|
|
. $uid |
231
|
|
|
. "' AND C.msg_id_fk='" |
232
|
|
|
. $msg_id |
233
|
|
|
. "' ORDER BY C.com_id DESC LIMIT 1 "; |
234
|
|
|
$result2 = $xoopsDB->queryF($newquery); |
235
|
|
|
while ($row = $xoopsDB->fetchArray($result2)) { |
236
|
|
|
$data[0] = $row; |
|
|
|
|
237
|
|
|
} |
238
|
|
|
return $data[0]; |
|
|
|
|
239
|
|
|
} else { |
240
|
|
|
return false; |
|
|
|
|
241
|
|
|
} |
242
|
|
|
} |
243
|
|
|
|
244
|
|
|
/** |
245
|
|
|
* @Get array of users followers |
246
|
|
|
* @param int $me |
247
|
|
|
* @return array |
|
|
|
|
248
|
|
|
*/ |
249
|
|
View Code Duplication |
public function getFollowers($me) |
|
|
|
|
250
|
|
|
{ |
251
|
|
|
global $xoopsDB, $xoopsUser; |
252
|
|
|
$query = 'SELECT you FROM ' . $xoopsDB->prefix('smallworld_followers') . " WHERE me = '" . $me . "'"; |
253
|
|
|
$result = $xoopsDB->queryF($query); |
254
|
|
|
$i = $xoopsDB->getRowsNum($result); |
255
|
|
|
while ($row = $xoopsDB->fetchArray($result)) { |
256
|
|
|
$data[] = $row; |
|
|
|
|
257
|
|
|
} |
258
|
|
|
if (0 == $i) { |
259
|
|
|
$data = [$me]; |
260
|
|
|
} |
261
|
|
|
if (!empty($data)) { |
262
|
|
|
return $data; |
263
|
|
|
} |
264
|
|
|
} |
265
|
|
|
|
266
|
|
|
/** |
267
|
|
|
* @count all votes |
268
|
|
|
* @param int $type |
269
|
|
|
* @param int $val |
270
|
|
|
* @param int $msgid |
271
|
|
|
* @return int |
272
|
|
|
*/ |
273
|
|
|
public function countVotes($type, $val, $msgid) |
|
|
|
|
274
|
|
|
{ |
275
|
|
|
global $xoopsUser, $xoopsDB; |
276
|
|
|
$query = 'Select SUM(' . $val . ') as sum from ' . $xoopsDB->prefix('smallworld_vote') . " where msg_id = '" . $msgid . "' and com_id = '0'"; |
277
|
|
|
$result = $xoopsDB->queryF($query); |
278
|
|
|
while ($row = $xoopsDB->fetchArray($result)) { |
279
|
|
|
$sum = $row['sum']; |
280
|
|
|
} |
281
|
|
|
if ('' == $sum) { |
|
|
|
|
282
|
|
|
$sum = '0'; |
283
|
|
|
} |
284
|
|
|
return $sum; |
285
|
|
|
} |
286
|
|
|
|
287
|
|
|
/** |
288
|
|
|
* @Count comments votes |
289
|
|
|
* @param int $type |
290
|
|
|
* @param int $val |
291
|
|
|
* @param int $comid |
292
|
|
|
* @param int $msgid |
293
|
|
|
* @returns int |
294
|
|
|
*/ |
295
|
|
View Code Duplication |
public function countVotesCom($type, $val, $comid, $msgid) |
|
|
|
|
296
|
|
|
{ |
297
|
|
|
global $xoopsUser, $xoopsDB; |
298
|
|
|
$query = 'Select SUM(' . $val . ') as sum from ' . $xoopsDB->prefix('smallworld_vote') . " where com_id = '" . $comid . "' AND msg_id = '" . $msgid . "'"; |
299
|
|
|
$result = $xoopsDB->queryF($query); |
300
|
|
|
while ($row = $xoopsDB->fetchArray($result)) { |
301
|
|
|
$sum = $row['sum']; |
302
|
|
|
} |
303
|
|
|
if ('' == $sum) { |
|
|
|
|
304
|
|
|
$sum = '0'; |
305
|
|
|
} |
306
|
|
|
return $sum; |
307
|
|
|
} |
308
|
|
|
|
309
|
|
|
/** |
310
|
|
|
* @Check if user is friend |
311
|
|
|
* @param int $userid |
312
|
|
|
* @param string $type |
313
|
|
|
* @param int $comid |
314
|
|
|
* @param int $msgid |
315
|
|
|
* @return int |
316
|
|
|
*/ |
317
|
|
View Code Duplication |
public function HasVoted($userid, $type, $comid, $msgid) |
|
|
|
|
318
|
|
|
{ |
319
|
|
|
global $xoopsUser, $xoopsDB; |
320
|
|
|
if ('msg' === $type) { |
321
|
|
|
$sql = 'SELECT * FROM ' . $xoopsDB->prefix('smallworld_vote') . " WHERE com_id = '0' AND msg_id = '" . $msgid . "' AND user_id = '" . $userid . "'"; |
322
|
|
|
$result = $xoopsDB->queryF($sql); |
323
|
|
|
$i = $xoopsDB->getRowsNum($result); |
324
|
|
|
} else { |
325
|
|
|
$sql = 'SELECT * FROM ' . $xoopsDB->prefix('smallworld_vote') . " WHERE com_id = '" . $comid . "' AND msg_id = '" . $msgid . "' AND user_id = '" . $userid . "'"; |
326
|
|
|
$result = $xoopsDB->queryF($sql); |
327
|
|
|
$i = $xoopsDB->getRowsNum($result); |
328
|
|
|
} |
329
|
|
|
return $i; |
330
|
|
|
} |
331
|
|
|
|
332
|
|
|
/** |
333
|
|
|
* @count messages per user |
334
|
|
|
* @param int $userid |
335
|
|
|
* @return int |
336
|
|
|
*/ |
337
|
|
|
public function CountMsges($userid) |
338
|
|
|
{ |
339
|
|
|
global $xoopsDB; |
340
|
|
|
$sql = 'SELECT (SELECT COUNT(*) FROM ' . $xoopsDB->prefix('smallworld_comments') . " WHERE uid_fk = '" . $userid . "') + (SELECT COUNT(*) FROM " . $xoopsDB->prefix('smallworld_messages') . " WHERE uid_fk = '" . $userid . "')"; |
341
|
|
|
$result = $xoopsDB->queryF($sql); |
342
|
|
|
$sum = $xoopsDB->fetchRow($result); |
343
|
|
|
return $sum[0]; |
344
|
|
|
} |
345
|
|
|
|
346
|
|
|
/** |
347
|
|
|
* @Show permaling updates |
348
|
|
|
* @param int $updid |
349
|
|
|
* @param int $uid |
350
|
|
|
* @param int $ownerID |
351
|
|
|
* @return array|bool |
|
|
|
|
352
|
|
|
*/ |
353
|
|
|
public function UpdatesPermalink($updid, $uid, $ownerID) |
|
|
|
|
354
|
|
|
{ |
355
|
|
|
global $xoopsUser, $xoopsDB, $moduleConfig; |
356
|
|
|
$query = 'SELECT M.msg_id, M.uid_fk, M.message, M.created, M.priv, U.username FROM ' . $xoopsDB->prefix('smallworld_messages') . ' M, ' . $xoopsDB->prefix('smallworld_user') . " U WHERE M.uid_fk=U.userid AND M.uid_fk='" . $ownerID . "'"; |
357
|
|
|
$query .= " AND M.msg_id = '" . $updid . "'"; |
358
|
|
|
$query .= ' order by M.created DESC LIMIT 1'; |
359
|
|
|
$result = $xoopsDB->queryF($query); |
360
|
|
|
$count = $xoopsDB->getRowsNum($result); |
361
|
|
|
if ($count < 1) { |
362
|
|
|
return false; |
363
|
|
|
} else { |
364
|
|
|
while ($row = $xoopsDB->fetchArray($result)) { |
365
|
|
|
$data[] = $row; |
|
|
|
|
366
|
|
|
} |
367
|
|
|
if (!empty($data)) { |
368
|
|
|
return $data; |
369
|
|
|
} |
370
|
|
|
} |
371
|
|
|
} |
372
|
|
|
|
373
|
|
|
/** |
374
|
|
|
* @Get share link |
375
|
|
|
* @param int $updid |
376
|
|
|
* @param int $ownerID |
377
|
|
|
* @return array|bool |
|
|
|
|
378
|
|
|
*/ |
379
|
|
View Code Duplication |
public function UpdatesSharelink($updid, $ownerID) |
|
|
|
|
380
|
|
|
{ |
381
|
|
|
global $xoopsUser, $xoopsDB, $moduleConfig, $xoopsLogger; |
382
|
|
|
$xoopsLogger->activated = false; |
383
|
|
|
//error_reporting(E_ALL); |
384
|
|
|
$query = 'SELECT M.msg_id, M.uid_fk, M.message, M.created, M.priv, U.username FROM ' . $xoopsDB->prefix('smallworld_messages') . ' M, ' . $xoopsDB->prefix('smallworld_user') . " U WHERE M.uid_fk=U.userid AND M.uid_fk='" . $ownerID . "' AND M.priv = 0"; |
385
|
|
|
$query .= " AND M.msg_id = '" . $updid . "'"; |
386
|
|
|
$query .= ' order by created DESC LIMIT 1'; |
387
|
|
|
$result = $xoopsDB->queryF($query); |
388
|
|
|
$count = $xoopsDB->getRowsNum($result); |
389
|
|
|
if ($count < 1) { |
390
|
|
|
return false; |
391
|
|
|
} else { |
392
|
|
|
while ($row = $xoopsDB->fetchArray($result)) { |
393
|
|
|
$data[] = $row; |
|
|
|
|
394
|
|
|
} |
395
|
|
|
if (!empty($data)) { |
396
|
|
|
return $data; |
397
|
|
|
} |
398
|
|
|
} |
399
|
|
|
} |
400
|
|
|
|
401
|
|
|
/** |
402
|
|
|
* @Get sharing link |
403
|
|
|
* @param int $id |
404
|
|
|
* @param int $priv |
405
|
|
|
* @return string |
406
|
|
|
*/ |
407
|
|
View Code Duplication |
public function GetSharing($id, $priv) |
|
|
|
|
408
|
|
|
{ |
409
|
|
|
if (1 != $priv) { |
410
|
|
|
$text = " | <span class='smallworld_share' id='smallworld_share'>"; |
411
|
|
|
$text .= "<a class='share' id='share-page" . $id . "' href='javascript:void(0);'>" . _SMALLWORLD_SHARELINK . '</a></span>'; |
412
|
|
|
} else { |
413
|
|
|
$text = ''; |
414
|
|
|
} |
415
|
|
|
return $text; |
416
|
|
|
} |
417
|
|
|
|
418
|
|
|
/** |
419
|
|
|
* @Get content for sharing div |
420
|
|
|
* @param int $id |
421
|
|
|
* @param int $priv |
422
|
|
|
* @param string $permalink |
423
|
|
|
* @param string $desc |
424
|
|
|
* @param string $username |
425
|
|
|
* @return string |
426
|
|
|
*/ |
427
|
|
View Code Duplication |
public function GetSharingDiv($id, $priv, $permalink, $desc, $username) |
|
|
|
|
428
|
|
|
{ |
429
|
|
|
if (1 != $priv) { |
430
|
|
|
$text = "<div style='display: none;' class='smallworld_bookmarks' id='share-page' name='share-page" . $id . "'>"; |
431
|
|
|
$text .= "<span name='share-page" . $id . "' rel1='" . $desc . "' rel2= '" . $username . "' rel=" . $permalink . " id='basicBookmark' title='" . _SMALLWORLD_SHAREBOX_TITLE . "'>"; |
432
|
|
|
$text .= '</span></div>'; |
433
|
|
|
} else { |
434
|
|
|
$text = ''; |
435
|
|
|
} |
436
|
|
|
return $text; |
437
|
|
|
} |
438
|
|
|
|
439
|
|
|
/** |
440
|
|
|
* @Parse update and comments array to template for public updates |
441
|
|
|
* @param array $updatesarray |
442
|
|
|
* @param int $id |
443
|
|
|
* @return void |
444
|
|
|
*/ |
445
|
|
View Code Duplication |
public function ParsePubArray($updatesarray, $id) |
|
|
|
|
446
|
|
|
{ |
447
|
|
|
global $xoopsUser, $xoopsTpl, $tpl, $xoopsModule, $xoopsConfig; |
448
|
|
|
|
449
|
|
|
$check = new SmallWorldUser; |
450
|
|
|
$dBase = new SmallWorldDB; |
451
|
|
|
$profile = $xoopsUser ? $check->checkIfProfile($id) : 0; |
452
|
|
|
$moduleHandler = xoops_getHandler('module'); |
453
|
|
|
$module = $moduleHandler->getByDirname('smallworld'); |
454
|
|
|
$configHandler = xoops_getHandler('config'); |
455
|
|
|
$moduleConfig = $configHandler->getConfigsByCat(0, $module->getVar('mid')); |
|
|
|
|
456
|
|
|
|
457
|
|
|
$myavatar = $this->Gravatar($id); |
458
|
|
|
$myavatarlink = smallworld_getAvatarLink($id, $myavatar); |
459
|
|
|
$myavatar_size = smallworld_getImageSize(80, 100, $myavatarlink); |
|
|
|
|
460
|
|
|
$myavatar_highwide = smallworld_imageResize($myavatar_size[0], $myavatar_size[1], 35); |
461
|
|
|
|
462
|
|
|
$xoopsTpl->assign('myavatar', $myavatar); |
463
|
|
|
$xoopsTpl->assign('myavatarlink', $myavatarlink); |
464
|
|
|
$xoopsTpl->assign('myavatar_highwide', $myavatar_highwide); |
465
|
|
|
|
466
|
|
|
if (!empty($updatesarray)) { |
467
|
|
|
foreach ($updatesarray as $data) { |
468
|
|
|
|
469
|
|
|
// Is update's user a friend ? |
470
|
|
|
$frU = $check->friendcheck($id, $data['uid_fk']); |
471
|
|
|
|
472
|
|
|
$USW = []; |
473
|
|
|
$USW['posts'] = 0; |
474
|
|
|
$USW['comments'] = 0; |
475
|
|
|
|
476
|
|
|
if ($xoopsUser) { |
477
|
|
|
if ($xoopsUser->isAdmin($xoopsModule->getVar('mid')) || $data['uid_fk'] == $id) { |
478
|
|
|
$USW['posts'] = 1; |
479
|
|
|
$USW['comments'] = 1; |
480
|
|
|
$frU[0] = 2; |
481
|
|
|
} else { |
482
|
|
|
$USW = json_decode($dBase->GetSettings($data['uid_fk']), true); |
483
|
|
|
} |
484
|
|
|
} |
485
|
|
|
|
486
|
|
|
if (!$xoopsUser) { |
487
|
|
|
$USW = json_decode($dBase->GetSettings($data['uid_fk']), true); |
488
|
|
|
} |
489
|
|
|
|
490
|
|
|
$wm['msg_id'] = $data['msg_id']; |
|
|
|
|
491
|
|
|
$wm['orimessage'] = (1 == $USW['posts'] || $profile >= 2) ? str_replace(["\r", "\n"], '', Smallworld_stripWordsKeepUrl($data['message'])) : ''; |
|
|
|
|
492
|
|
|
$wm['message'] = (1 == $USW['posts'] || $profile >= 2) ? smallworld_tolink(htmlspecialchars_decode($data['message']), $data['uid_fk']) : _SMALLWORLD_MESSAGE_PRIVSETPOSTS; |
493
|
|
|
$wm['message'] = Smallworld_cleanup($wm['message']); |
494
|
|
|
$wm['created'] = smallworld_time_stamp($data['created']); |
495
|
|
|
$wm['username'] = $data['username']; |
496
|
|
|
$wm['uid_fk'] = $data['uid_fk']; |
497
|
|
|
$wm['priv'] = $data['priv']; |
498
|
|
|
$wm['avatar'] = $this->Gravatar($data['uid_fk']); |
499
|
|
|
$wm['avatar_link'] = smallworld_getAvatarLink($data['uid_fk'], $wm['avatar']); |
500
|
|
|
$wm['avatar_size'] = smallworld_getImageSize(80, 100, $wm['avatar_link']); |
|
|
|
|
501
|
|
|
$wm['avatar_highwide'] = smallworld_imageResize($wm['avatar_size'][0], $wm['avatar_size'][1], 50); |
502
|
|
|
$wm['vote_up'] = $this->countVotes('msg', 'up', $data['msg_id']); |
503
|
|
|
$wm['vote_down'] = $this->countVotes('msg', 'down', $data['msg_id']); |
504
|
|
|
$wm['sharelinkurl'] = XOOPS_URL . '/modules/smallworld/smallworldshare.php?ownerid=' . $data['uid_fk']; |
505
|
|
|
$wm['sharelinkurl'] .= '&updid=' . $data['msg_id'] . ''; |
506
|
|
|
$wm['usernameTitle'] = $wm['username'] . _SMALLWORLD_UPDATEONSITEMETA . $xoopsConfig['sitename']; |
507
|
|
|
if (1 == $USW['posts'] || $profile >= 2) { |
508
|
|
|
$wm['sharelink'] = $this->GetSharing($wm['msg_id'], $wm['priv']); |
509
|
|
|
} else { |
510
|
|
|
$wm['sharelink'] = $this->GetSharing($wm['msg_id'], 1); |
511
|
|
|
} |
512
|
|
|
|
513
|
|
|
if (1 == $USW['posts'] || $profile >= 2) { |
514
|
|
|
$wm['sharediv'] = $this->GetSharingDiv($wm['msg_id'], $wm['priv'], $wm['sharelinkurl'], $wm['orimessage'], $wm['usernameTitle']); |
515
|
|
|
} else { |
516
|
|
|
$wm['sharediv'] = $this->GetSharingDiv($wm['msg_id'], 1, $wm['sharelinkurl'], $wm['orimessage'], $wm['usernameTitle']); |
517
|
|
|
} |
518
|
|
|
$wm['linkimage'] = XOOPS_URL . '/modules/smallworld/assets/images/link.png'; |
519
|
|
|
$wm['permalink'] = XOOPS_URL . '/modules/smallworld/permalink.php?ownerid=' . $data['uid_fk'] . '&updid=' . $data['msg_id']; |
520
|
|
|
$wm['commentsarray'] = $this->Comments($data['msg_id']); |
521
|
|
|
|
522
|
|
|
if (2 == $frU[0] || 1 == $USW['posts']) { |
523
|
|
|
$xoopsTpl->append('walldata', $wm); |
524
|
|
|
} |
525
|
|
|
|
526
|
|
|
if (!empty($wm['commentsarray'])) { |
527
|
|
|
foreach ($wm['commentsarray'] as $cdata) { |
528
|
|
|
// Is commentuser a friend ? |
529
|
|
|
$frC = $check->friendcheck($id, $cdata['uid_fk']); |
530
|
|
|
|
531
|
|
|
$USC = []; |
532
|
|
|
$USC['posts'] = 0; |
533
|
|
|
$USC['comments'] = 0; |
534
|
|
|
|
535
|
|
|
if ($xoopsUser) { |
536
|
|
|
if ($xoopsUser->isAdmin($xoopsModule->getVar('mid')) || $cdata['uid_fk'] == $id) { |
537
|
|
|
$USC['posts'] = 1; |
538
|
|
|
$USC['comments'] = 1; |
539
|
|
|
$frC[0] = 2; |
540
|
|
|
} else { |
541
|
|
|
$USC = json_decode($dBase->GetSettings($cdata['uid_fk']), true); |
542
|
|
|
} |
543
|
|
|
} |
544
|
|
|
|
545
|
|
|
if (!$xoopsUser) { |
546
|
|
|
$USC = json_decode($dBase->GetSettings($cdata['uid_fk']), true); |
547
|
|
|
} |
548
|
|
|
|
549
|
|
|
$wc['msg_id_fk'] = $cdata['msg_id_fk']; |
|
|
|
|
550
|
|
|
$wc['com_id'] = $cdata['com_id']; |
551
|
|
|
$wc['comment'] = (1 == $USC['comments'] || $profile >= 2) ? smallworld_tolink(htmlspecialchars_decode($cdata['comment']), $cdata['uid_fk']) : _SMALLWORLD_MESSAGE_PRIVSETCOMMENTS; |
552
|
|
|
$wc['comment'] = Smallworld_cleanup($wc['comment']); |
553
|
|
|
$wc['time'] = smallworld_time_stamp($cdata['created']); |
554
|
|
|
$wc['username'] = $cdata['username']; |
555
|
|
|
$wc['uid'] = $cdata['uid_fk']; |
556
|
|
|
$wc['myavatar'] = $this->Gravatar($id); |
557
|
|
|
$wc['myavatar_link'] = $myavatarlink; |
558
|
|
|
$wc['avatar_size'] = smallworld_getImageSize(80, 100, $wc['myavatar_link']); |
|
|
|
|
559
|
|
|
$wc['avatar_highwide'] = smallworld_imageResize($wc['avatar_size'][0], $wc['avatar_size'][1], 35); |
560
|
|
|
$wc['cface'] = $this->Gravatar($cdata['uid_fk']); |
561
|
|
|
$wc['avatar_link'] = smallworld_getAvatarLink($cdata['uid_fk'], $wc['cface']); |
562
|
|
|
$wc['vote_up'] = $this->countVotesCom('com', 'up', $cdata['msg_id_fk'], $cdata['com_id']); |
563
|
|
|
$wc['vote_down'] = $this->countVotesCom('com', 'down', $cdata['msg_id_fk'], $cdata['com_id']); |
564
|
|
|
|
565
|
|
|
if (2 == $frC[0] || 1 == $USC['comments']) { |
566
|
|
|
$xoopsTpl->append('comm', $wc); |
567
|
|
|
} |
568
|
|
|
} |
569
|
|
|
} |
570
|
|
|
} |
571
|
|
|
} |
572
|
|
|
} |
573
|
|
|
} |
574
|
|
|
|