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