Passed
Push — master ( 6209eb...36ba5e )
by Michael
51s queued 14s
created

index.php (4 issues)

1
<?php declare(strict_types=1);
2
3
/*
4
 You may not change or alter any portion of this comment or credits
5
 of supporting developers from this source code or any supporting source code
6
 which is considered copyrighted (c) material of the original comment or credit authors.
7
8
 This program is distributed in the hope that it will be useful,
9
 but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
*/
12
13
/**
14
 * @copyright    XOOPS Project https://xoops.org/
15
 * @license      GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
16
 * @author       Marcello Brandão aka  Suico
17
 * @author       XOOPS Development Team
18
 * @since
19
 */
20
21
use Xmf\Request;
22
use XoopsModules\Yogurt;
23
use XoopsModules\Yogurt\IndexController;
24
25
/**
26
 * Xoops header
27
 */
28
$GLOBALS['xoopsOption']['template_main'] = 'yogurt_index.tpl';
29
require __DIR__ . '/header.php';
30
31
$helper->loadLanguage('user');
32
33
$uid = isset($_GET['uid']) ? (int)$_GET['uid'] : 0;
34
if ($uid <= 0) {
35
    if (is_object($GLOBALS['xoopsUser'])) {
36
        $uid = $GLOBALS['xoopsUser']->getVar('uid');
37
    } else {
38
        header('location: ' . XOOPS_URL);
39
        exit();
40
    }
41
}
42
43
/* @var  XoopsGroupPermHandler $gperm_handler */
44
$gperm_handler = xoops_getHandler('groupperm');
45
$groups        = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : array(XOOPS_GROUP_ANONYMOUS);
46
47
if (is_object($GLOBALS['xoopsUser']) && $uid == $GLOBALS['xoopsUser']->getVar('uid')) {
48
    //disable cache
49
    $GLOBALS['xoopsConfig']['module_cache'][$GLOBALS['xoopsModule']->getVar('mid')] = 0;
50
    include $GLOBALS['xoops']->path('header.php');
51
52
    /* @var XoopsConfigHandler $config_handler */
53
    $config_handler             = xoops_getHandler('config');
54
    $GLOBALS['xoopsConfigUser'] = $config_handler->getConfigsByCat(XOOPS_CONF_USER);
55
56
    $GLOBALS['xoopsTpl']->assign('user_ownpage', true);
57
    if ($GLOBALS['xoopsConfigUser']['self_delete'] == 1) {
58
        $GLOBALS['xoopsTpl']->assign('user_candelete', true);
59
        $GLOBALS['xoopsTpl']->assign('lang_deleteaccount', _US_DELACCOUNT);
60
    } else {
61
        $GLOBALS['xoopsTpl']->assign('user_candelete', false);
62
    }
63
	$GLOBALS['xoopsTpl']->assign('user_changeemail', $GLOBALS['xoopsConfigUser']['allow_chgmail']);
64
    $thisUser =& $GLOBALS['xoopsUser'];
65
} else {
66
    /* @var XoopsMemberHandler $member_handler */
67
    $member_handler = xoops_getHandler('member');
68
    $thisUser       = $member_handler->getUser($uid);
69
70
    // Redirect if not a user or not active and the current user is not admin
71
    if (!is_object($thisUser) || (!$thisUser->isActive() && (!$GLOBALS['xoopsUser'] || !$GLOBALS['xoopsUser']->isAdmin()))) {
72
        redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['xoopsModule']->getVar('dirname', 'n'), 3, _US_SELECTNG);
73
    }
74
75
    /**
76
     * Access permission check
77
     *
78
     * Note:
79
     * "thisUser" refers to the user whose profile will be accessed; "xoopsUser" refers to the current user $GLOBALS['xoopsUser']
80
     * "Basic Groups" refer to XOOPS_GROUP_ADMIN, XOOPS_GROUP_USERS and XOOPS_GROUP_ANONYMOUS;
81
     * "Non Basic Groups" refer to all other custom groups
82
     *
83
     * Admin groups: If thisUser belongs to admin groups, the xoopsUser has access if and only if one of xoopsUser's groups is allowed to access admin group; else
84
     * Non basic groups: If thisUser belongs to one or more non basic groups, the xoopsUser has access if and only if one of xoopsUser's groups is allowed to allowed to any of the non basic groups; else
85
     * User group: If thisUser belongs to User group only, the xoopsUser has access if and only if one of his groups is allowed to access User group
86
     *
87
     */
88
    // Redirect if current user is not allowed to access the user's profile based on group permission
89
    $groups_basic             = array(XOOPS_GROUP_ADMIN, XOOPS_GROUP_USERS, XOOPS_GROUP_ANONYMOUS);
90
    $groups_thisUser          = $thisUser->getGroups();
91
    $groups_thisUser_nonbasic = array_diff($groups_thisUser, $groups_basic);
92
    $groups_xoopsUser         = $groups;
93
    /* @var  XoopsGroupPermHandler $gperm_handler */
94
    $gperm_handler            = xoops_getHandler('groupperm');
95
    $groups_accessible        = $gperm_handler->getItemIds('profile_access', $groups_xoopsUser, $GLOBALS['xoopsModule']->getVar('mid'));
96
97
    $rejected = false;
98
    if ($thisUser->isAdmin()) {
99
        $rejected = !in_array(XOOPS_GROUP_ADMIN, $groups_accessible);
100
    } elseif ($groups_thisUser_nonbasic) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $groups_thisUser_nonbasic of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
101
        $rejected = !array_intersect($groups_thisUser_nonbasic, $groups_accessible);
102
    } else {
103
        $rejected = !in_array(XOOPS_GROUP_USERS, $groups_accessible);
104
    }
105
106
    if ($rejected) {
107
        redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['xoopsModule']->getVar('dirname', 'n'), 3, _NOPERM);
108
    }
109
110
    if (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isAdmin()) {
111
        //disable cache
112
        $GLOBALS['xoopsConfig']['module_cache'][$GLOBALS['xoopsModule']->getVar('mid')] = 0;
113
    }
114
    $GLOBALS['xoopsTpl']->assign('user_ownpage', false);
115
}
116
117
$GLOBALS['xoopsTpl']->assign('user_uid', $thisUser->getVar('uid'));
118
if (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isAdmin()) {
119
    $GLOBALS['xoopsTpl']->assign('lang_editprofile', _US_EDITPROFILE);
120
    $GLOBALS['xoopsTpl']->assign('lang_deleteaccount', _US_DELACCOUNT);
121
    $GLOBALS['xoopsTpl']->assign('userlevel', $thisUser->isActive());
122
}
123
124
125
126
// Dynamic User Profiles
127
$thisUsergroups     = $thisUser->getGroups();
128
$visibility_handler = xoops_getModuleHandler('visibility');
129
//search for visible Fields or null for none
130
$field_ids_visible = $visibility_handler->getVisibleFields($thisUsergroups, $groups);
0 ignored issues
show
The method getVisibleFields() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

130
$field_ids_visible = $visibility_handler->/** @scrutinizer ignore-call */ getVisibleFields($thisUsergroups, $groups);
Loading history...
131
132
$profile_handler = xoops_getModuleHandler('profile');
133
$fields          = $profile_handler->loadFields();
0 ignored issues
show
The method loadFields() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

133
$fields          = $profile_handler->/** @scrutinizer ignore-call */ loadFields();
Loading history...
134
$cat_handler     = xoops_getModuleHandler('category');
135
$cat_crit        = new CriteriaCompo();
136
$cat_crit->setSort('cat_weight');
137
$cats = $cat_handler->getObjects($cat_crit, true, false);
0 ignored issues
show
The method getObjects() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of said class. However, the method does not exist in XoopsRankHandler or XoUserHandler. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

137
$cats = $cat_handler->/** @scrutinizer ignore-call */ getObjects($cat_crit, true, false);
Loading history...
138
unset($cat_crit);
139
140
$avatar = '';
141
if ($thisUser->getVar('user_avatar') && 'blank.gif' !== $thisUser->getVar('user_avatar')) {
142
    $avatar = XOOPS_UPLOAD_URL . '/' . $thisUser->getVar('user_avatar');
143
}
144
145
foreach (array_keys($cats) as $i) {
146
    $categories[$i] = $cats[$i];
147
}
148
149
$profile_handler = xoops_getModuleHandler('profile');
150
$profile         = $profile_handler->get($thisUser->getVar('uid'));
151
// Add dynamic fields
152
foreach (array_keys($fields) as $i) {
153
    //If field is not visible, skip
154
    //if ( $field_ids_visible && !in_array($fields[$i]->getVar('field_id'), $field_ids_visible) ) continue;
155
    if (!in_array($fields[$i]->getVar('field_id'), $field_ids_visible)) {
156
        continue;
157
    }
158
    $cat_id = $fields[$i]->getVar('cat_id');
159
    $value  = $fields[$i]->getOutputValue($thisUser, $profile);
160
    if (is_array($value)) {
161
        $value = implode('<br>', array_values($value));
162
    }
163
    if ($value) {
164
        $categories[$cat_id]['fields'][] = array('title' => $fields[$i]->getVar('field_title'), 'value' => $value);
165
        $weights[$cat_id][]              = $fields[$i]->getVar('cat_id');
166
    }
167
}
168
169
$GLOBALS['xoopsTpl']->assign('categories', $categories);
170
// Dynamic user profiles end
171
172
$mainvideocode = '';
173
$mainvideodesc = '';
174
175
//require_once __DIR__ . '/class/yogurt_controller.php';
176
//if (!@ require_once XOOPS_ROOT_PATH . '/language/' . $GLOBALS['xoopsConfig']['language'] . '/user.php') {
177
//    require_once XOOPS_ROOT_PATH . '/language/english/user.php';
178
//}
179
180
$controller = new IndexController($xoopsDB, $xoopsUser);
181
182
/**
183
 * Fetching numbers of groups friends videos pictures etc...
184
 */
185
$nbSections = $controller->getNumbersSections();
186
187
/**
188
 * This variable define the beginning of the navigation must be
189
 * set here so all calls to database will take this into account
190
 */
191
$start = Request::getInt(
192
    'start',
193
    0,
194
    'GET'
195
);
196
197
/**
198
 * Criteria for mainvideo
199
 */
200
$criteria_uidvideo  = new Criteria('uid_owner', $controller->uidOwner);
201
$criteria_mainvideo = new Criteria('main_video', '1');
202
$criteria_video     = new CriteriaCompo($criteria_mainvideo);
203
$criteria_video->add($criteria_uidvideo);
204
205
if ((isset($nbSections['nbVideos']) && $nbSections['nbVideos'] > 0) && ($videos = $controller->videosFactory->getObjects($criteria_video))) {
206
    $mainvideocode = $videos[0]->getVar('youtube_code');
207
    $mainvideodesc = $videos[0]->getVar('video_desc');
208
}
209
210
211
/**
212
 * Groups
213
 */
214
$criteria_groups = new Criteria('rel_user_uid', $controller->uidOwner);
215
$groups          = $controller->relgroupusersFactory->getGroups(8, $criteria_groups);
216
217
/**
218
 * Visitors
219
 */
220
 $controller->visitorsFactory->purgeVisits();
221
 
222
if (0 === $controller->isAnonym) {
223
    /**
224
     * Fectching last visitors
225
     */
226
    if ($controller->uidOwner !== $xoopsUser->getVar('uid')) {
227
        $visitor_now = $controller->visitorsFactory->create();
228
        $visitor_now->setVar('uid_owner', $controller->uidOwner);
229
        $visitor_now->setVar('uid_visitor', $xoopsUser->getVar('uid'));
230
        $visitor_now->setVar('uname_visitor', $xoopsUser->getVar('uname'));
231
        $controller->visitorsFactory->insert2($visitor_now);
232
    }
233
    $criteria_visitors = new Criteria('uid_owner', $controller->uidOwner);
234
    //$criteria_visitors->setLimit(5);
235
    $visitors_object_array = $controller->visitorsFactory->getObjects(
236
        $criteria_visitors
237
    );
238
239
    /**
240
     * Lets populate an array with the dati from visitors
241
     */
242
    $i              = 0;
243
    $visitors_array = [];
244
    foreach ($visitors_object_array as $visitor) {
245
        $indice                  = $visitor->getVar('uid_visitor', 's');
246
        $visitors_array[$indice] = $visitor->getVar('uname_visitor', 's');
247
248
        $i++;
249
    }
250
251
    $xoopsTpl->assign('visitors', $visitors_array);
252
    $xoopsTpl->assign('lang_visitors', _MD_YOGURT_VISITORS);
253
    /*    $criteria_deletevisitors = new criteria('uid_owner',$uid);
254
        $criteria_deletevisitors->setStart(5);
255
256
        print_r($criteria_deletevisitors);
257
        $visitorsFactory->deleteAll($criteria_deletevisitors, true);
258
    */
259
}
260
261
$avatar = $controller->owner->getVar('user_avatar');
262
263
$memberHandler = xoops_getHandler('member');
264
$thisUser      = $memberHandler->getUser($controller->uidOwner);
265
$myts          = MyTextSanitizer::getInstance();
266
267
//navbar
268
$xoopsTpl->assign('lang_mysection', _MD_YOGURT_MYPROFILE);
269
$xoopsTpl->assign('section_name', _MD_YOGURT_PROFILE);
270
271
//$xoopsTpl->assign('path_yogurt_uploads',$helper->getConfig('link_path_upload'));
272
273
//groups
274
$xoopsTpl->assign('groups', $groups);
275
if (isset($nbSections['nbGroups']) && $nbSections['nbGroups'] <= 0) {
276
    $xoopsTpl->assign('lang_nogroupsyet', _MD_YOGURT_NOGROUPSYET);
277
}
278
$xoopsTpl->assign('lang_viewallgroups', _MD_YOGURT_ALLGROUPS);
279
280
//Avatar and Main
281
$xoopsTpl->assign('avatar_url', $avatar);
282
$xoopsTpl->assign('lang_selectavatar', _MD_YOGURT_SELECTAVATAR);
283
$xoopsTpl->assign('lang_selectmainvideo', _MD_YOGURT_SELECTMAINVIDEO);
284
$xoopsTpl->assign('lang_noavatar', _MD_YOGURT_NOAVATARYET);
285
$xoopsTpl->assign('lang_nomainvideo', _MD_YOGURT_NOMAINVIDEOYET);
286
$xoopsTpl->assign('lang_featuredvideo', _MD_YOGURT_VIDEO_FEATURED);
287
$xoopsTpl->assign('lang_viewallvideos', _MD_YOGURT_ALLVIDEOS);
288
289
if (isset($nbSections['nbVideos']) && $nbSections['nbVideos'] > 0) {
290
    $xoopsTpl->assign('mainvideocode', $mainvideocode);
291
    $xoopsTpl->assign('mainvideodesc', $mainvideodesc);
292
    $xoopsTpl->assign(
293
        'width',
294
        $helper->getConfig('width_maintube')
295
    ); // Falta configurar o tamnho do main nas configs e alterar no template
296
    $xoopsTpl->assign(
297
        'height',
298
        $helper->getConfig('height_maintube')
299
    );
300
}
301
302
/**
303
 * Friends
304
 */
305
if ($xoopsUser){
306
307
$controller = new Yogurt\FriendsController($xoopsDB, $xoopsUser);
308
309
$friendrequest = 0;
310
if (1 === $controller->isOwner) {
311
    $criteria_uidfriendrequest = new Criteria('friendrequestto_uid', $controller->uidOwner);
312
    $newFriendrequest          = $controller->friendrequestFactory->getObjects($criteria_uidfriendrequest);
313
    if ($newFriendrequest) {
314
        $nb_friendrequest      = count($newFriendrequest);
315
        $friendrequesterHandler = xoops_getHandler('member');
316
        $friendrequester        = $friendrequesterHandler->getUser($newFriendrequest[0]->getVar('friendrequester_uid'));
317
        $friendrequester_uid    = $friendrequester->getVar('uid');
318
        $friendrequester_uname  = $friendrequester->getVar('uname');
319
        $friendrequester_avatar = $friendrequester->getVar('user_avatar');
320
        $friendrequest_id       = $newFriendrequest[0]->getVar('friendpet_id');
321
        $friendrequest          = 1;
322
    }
323
}
324
 
325
//requests to become friend
326
if (1 === $friendrequest) {
327
	$xoopsTpl->assign('lang_youhavexfriendrequests', sprintf(_MD_YOGURT_YOUHAVEXFRIENDREQUESTS, $nb_friendrequest));
328
    $xoopsTpl->assign('friendrequester_uid', $friendrequester_uid);
329
    $xoopsTpl->assign('friendrequester_uname', $friendrequester_uname);
330
    $xoopsTpl->assign('friendrequester_avatar', $friendrequester_avatar);
331
    $xoopsTpl->assign('friendrequest', $friendrequest);
332
    $xoopsTpl->assign('friendrequest_id', $friendrequest_id);
333
    $xoopsTpl->assign('lang_rejected', _MD_YOGURT_UNKNOWN_REJECTING);
334
    $xoopsTpl->assign('lang_accepted', _MD_YOGURT_UNKNOWN_ACCEPTING);
335
    $xoopsTpl->assign('lang_acquaintance', _MD_YOGURT_AQUAITANCE);
336
    $xoopsTpl->assign('lang_friend', _MD_YOGURT_FRIEND);
337
    $xoopsTpl->assign('lang_bestfriend', _MD_YOGURT_BESTFRIEND);
338
    $linkedpetioner = '<a href="index.php?uid=' . $friendrequester_uid . '">' . $friendrequester_uname . '</a>';
339
    $xoopsTpl->assign('lang_askingfriend', sprintf(_MD_YOGURT_ASKINGFRIEND, $linkedpetioner));
340
}
341
}
342
343
$xoopsTpl->assign('lang_askusertobefriend', _MD_YOGURT_ASKBEFRIEND);
344
$xoopsTpl->assign('lang_addfriend', _MD_YOGURT_ADDFRIEND);
345
$xoopsTpl->assign('lang_friendrequestpending', _MD_YOGURT_FRIENDREQUEST_PENDING);
346
$xoopsTpl->assign('lang_myfriend', _MD_YOGURT_MYFRIEND);
347
$xoopsTpl->assign('lang_friendrequestsent', _MD_YOGURT_FRIENDREQUEST_SENT);
348
$xoopsTpl->assign('lang_acceptfriend', _MD_YOGURT_FRIEND_ACCEPT);
349
$xoopsTpl->assign('lang_rejectfriend', _MD_YOGURT_FRIEND_REJECT);
350
351
$criteria_friends = new Criteria('friend1_uid', $controller->uidOwner);
352
$friends          = $controller->friendshipsFactory->getFriends(8, $criteria_friends);
353
$xoopsTpl->assign('friends', $friends);
354
$xoopsTpl->assign('lang_friendstitle', sprintf(_MD_YOGURT_FRIENDSTITLE, $controller->nameOwner));
355
$xoopsTpl->assign('lang_viewallfriends', _MD_YOGURT_ALLFRIENDS);
356
$xoopsTpl->assign('lang_nofriendsyet', _MD_YOGURT_NOFRIENDSYET);
357
358
359
//search
360
$xoopsTpl->assign('lang_usercontributions', _MD_YOGURT_USER_CONTRIBUTIONS);
361
362
//Profile
363
$xoopsTpl->assign('lang_detailsinfo', _MD_YOGURT_USER_DETAILS);
364
$xoopsTpl->assign('lang_contactinfo', _MD_YOGURT_CONTACTINFO);
365
//$xoopsTpl->assign('path_yogurt_uploads',$helper->getConfig('link_path_upload'));
366
$xoopsTpl->assign(
367
    'lang_max_nb_pict',
368
    sprintf(_MD_YOGURT_YOUCANHAVE, $helper->getConfig('nb_pict'))
369
);
370
$xoopsTpl->assign('lang_delete', _MD_YOGURT_DELETE);
371
$xoopsTpl->assign('lang_editdesc', _MD_YOGURT_EDIT_DESC);
372
$xoopsTpl->assign('lang_visitors', _MD_YOGURT_VISITORS);
373
$xoopsTpl->assign('lang_profilevisitors', _MD_YOGURT_PROFILEVISITORS);
374
$xoopsTpl->assign('lang_editprofile', _MD_YOGURT_EDITPROFILE);
375
376
$xoopsTpl->assign('user_uname', $thisUser->getVar('uname'));
377
$xoopsTpl->assign('user_realname', $thisUser->getVar('name'));
378
$xoopsTpl->assign('lang_uname', _US_NICKNAME);
379
$xoopsTpl->assign('lang_website', _US_WEBSITE);
380
$userwebsite = '' !== $thisUser->getVar('url', 'E') ? '<a href="' . $thisUser->getVar(
381
        'url',
382
        'E'
383
    ) . '" target="_blank">' . $thisUser->getVar(
384
        'url'
385
    ) . '</a>' : '';
386
$xoopsTpl->assign('user_websiteurl', $userwebsite);
387
$xoopsTpl->assign('lang_email', _US_EMAIL);
388
$xoopsTpl->assign('lang_privmsg', _US_PM);
389
$xoopsTpl->assign('lang_location', _US_LOCATION);
390
$xoopsTpl->assign('user_location', $thisUser->getVar('user_from'));
391
$xoopsTpl->assign('lang_occupation', _US_OCCUPATION);
392
$xoopsTpl->assign('user_occupation', $thisUser->getVar('user_occ'));
393
$xoopsTpl->assign('lang_interest', _US_INTEREST);
394
$xoopsTpl->assign('user_interest', $thisUser->getVar('user_intrest'));
395
$xoopsTpl->assign('lang_extrainfo', _US_EXTRAINFO);
396
$var = $thisUser->getVar('bio', 'N');
397
$xoopsTpl->assign('user_extrainfo', $myts->displayTarea($var, 0, 1, 1));
398
$xoopsTpl->assign('lang_statistics', _US_STATISTICS);
399
$xoopsTpl->assign('lang_membersince', _US_MEMBERSINCE);
400
$var = $thisUser->getVar('user_regdate');
401
$xoopsTpl->assign('user_joindate', formatTimestamp($var, 's'));
402
$xoopsTpl->assign('lang_rank', _US_RANK);
403
$xoopsTpl->assign('lang_posts', _US_POSTS);
404
$xoopsTpl->assign('lang_basicInfo', _US_BASICINFO);
405
$xoopsTpl->assign('lang_more', _US_MOREABOUT);
406
$xoopsTpl->assign('lang_myinfo', _US_MYINFO);
407
$xoopsTpl->assign('user_posts', $thisUser->getVar('posts'));
408
$xoopsTpl->assign('lang_lastlogin', _US_LASTLOGIN);
409
$date = $thisUser->getVar('last_login');
410
if (!empty($date)) {
411
    $xoopsTpl->assign('user_lastlogin', formatTimestamp($date, 'm'));
412
}
413
$xoopsTpl->assign('lang_notregistered', _US_NOTREGISTERED);
414
415
$xoopsTpl->assign('lang_signature', _US_SIGNATURE);
416
$var = $thisUser->getVar('user_sig', 'N');
417
$xoopsTpl->assign('user_signature', $myts->displayTarea($var, 0, 1, 1));
418
419
$xoopsTpl->assign('user_viewemail', $thisUser->getVar('user_viewemail', 'E'));
420
if (1 === $thisUser->getVar('user_viewemail')) {
421
    $xoopsTpl->assign('user_email', $thisUser->getVar('email', 'E'));
422
} else {
423
    $xoopsTpl->assign('user_email', '&nbsp;');
424
}
425
426
$xoopsTpl->assign('user_onlinestatus', $thisUser->isOnline());
427
$xoopsTpl->assign('lang_onlinestatus', _MD_YOGURT_ONLINESTATUS);
428
$xoopsTpl->assign('uname', $thisUser->getVar('uname'));
429
$xoopsTpl->assign('lang_realname', _US_REALNAME);
430
$xoopsTpl->assign('name', $thisUser->getVar('name'));
431
432
$gpermHandler  = xoops_getHandler('groupperm');
433
$groups        = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
434
$moduleHandler = xoops_getHandler('module');
435
$criteria      = new CriteriaCompo(new Criteria('hassearch', 1));
436
$criteria->add(new Criteria('isactive', 1));
437
$mids = array_keys($moduleHandler->getList($criteria));
438
439
//user rank
440
$userrank = $thisUser->rank();
441
if ($userrank['image']) {
442
    $xoopsTpl->assign('user_rankimage', '<img src="' . XOOPS_UPLOAD_URL . '/' . $userrank['image'] . '" alt="">');
443
}
444
$xoopsTpl->assign('user_ranktitle', $userrank['title']);
445
446
foreach ($mids as $mid) {
447
    if ($gpermHandler->checkRight('module_read', $mid, $groups)) {
448
        $module   = $moduleHandler->get($mid);
449
        $user_uid = $thisUser->getVar('uid');
450
        $results  = $module->search('', '', 5, 0, $user_uid);
451
        if (is_array($results)) {
452
            $count = count($results);
453
        }
454
        if (is_array($results) && $count > 0) {
455
            for ($i = 0; $i < $count; $i++) {
456
                if (isset($results[$i]['image']) && '' !== $results[$i]['image']) {
457
                    $results[$i]['image'] = 'modules/' . $module->getVar('dirname') . '/' . $results[$i]['image'];
458
                } else {
459
                    $results[$i]['image'] = 'images/icons/posticon2.gif';
460
                }
461
462
                if (!preg_match("#^http[s]*:\/\/#i", $results[$i]['link'])) {
463
                    $results[$i]['link'] = 'modules/' . $module->getVar('dirname') . '/' . $results[$i]['link'];
464
                }
465
466
                $results[$i]['title'] = $myts->htmlSpecialChars($results[$i]['title']);
467
                $results[$i]['time']  = $results[$i]['time'] ? formatTimestamp($results[$i]['time']) : '';
468
            }
469
            if (5 === $count) {
470
                $showall_link = '<a href="../../search.php?action=showallbyuser&amp;mid=' . $mid . '&amp;uid=' . $thisUser->getVar(
471
                        'uid'
472
                    ) . '">' . _US_SHOWALL . '</a>';
473
            } else {
474
                $showall_link = '';
475
            }
476
            $xoopsTpl->append(
477
                'modules',
478
                [
479
                    'name'         => $module->getVar('name'),
480
                    'results'      => $results,
481
                    'showall_link' => $showall_link,
482
                ]
483
            );
484
        }
485
        unset($module);
486
    }
487
}
488
489
490
491
492
require __DIR__ . '/footer.php';
493
require dirname(__DIR__, 2) . '/footer.php';
494