Passed
Pull Request — master (#81)
by Michael
03:00
created

index.php (9 issues)

1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 You may not change or alter any portion of this comment or credits
7
 of supporting developers from this source code or any supporting source code
8
 which is considered copyrighted (c) material of the original comment or credit authors.
9
10
 This program is distributed in the hope that it will be useful,
11
 but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
*/
14
15
/**
16
 * @category        Module
17
 * @package         yogurt
18
 * @copyright       {@link https://xoops.org/ XOOPS Project}
19
 * @license         GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
20
 * @author          Marcello Brandão aka  Suico, Mamba, LioMJ  <https://xoops.org>
21
 */
22
23
use Xmf\Request;
24
use XoopsModules\Yogurt;
25
use XoopsModules\Yogurt\IndexController;
26
27
/**
28
 * Xoops header
29
 */
30
$GLOBALS['xoopsOption']['template_main'] = 'yogurt_index.tpl';
31
require __DIR__ . '/header.php';
32
33
$helper->loadLanguage('user');
34
35
$controller = new IndexController($xoopsDB, $xoopsUser);
36
/**
37
 * Fetching numbers of groups friends videos pictures etc...
38
 */
39
$nbSections = $controller->getNumbersSections();
40
41
$uid = $controller->uidOwner;
42
43
/* @var  XoopsGroupPermHandler $grouppermHandler */
44
$grouppermHandler = xoops_getHandler('groupperm');
45
$groups        = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : [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 (1 == $GLOBALS['xoopsConfigUser']['self_delete']) {
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 $memberHandler */
67
    $memberHandler = xoops_getHandler('member');
68
    $thisUser       = $memberHandler->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
    // Redirect if current user is not allowed to access the user's profile based on group permission
88
    $groups_basic             = [XOOPS_GROUP_ADMIN, XOOPS_GROUP_USERS, XOOPS_GROUP_ANONYMOUS];
89
    $groups_thisUser          = $thisUser->getGroups();
90
    $groups_thisUser_nonbasic = array_diff($groups_thisUser, $groups_basic);
91
    $groups_xoopsUser         = $groups;
92
    /* @var  XoopsGroupPermHandler $grouppermHandler */
93
    $grouppermHandler     = xoops_getHandler('groupperm');
94
    $groups_accessible = $grouppermHandler->getItemIds('profile_access', $groups_xoopsUser, $GLOBALS['xoopsModule']->getVar('mid'));
95
96
    $rejected = false;
97
    if ($thisUser->isAdmin()) {
98
        $rejected = !in_array(XOOPS_GROUP_ADMIN, $groups_accessible);
99
    } 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...
100
        $rejected = !array_intersect($groups_thisUser_nonbasic, $groups_accessible);
101
    } else {
102
        $rejected = !in_array(XOOPS_GROUP_USERS, $groups_accessible);
103
    }
104
105
    if ($rejected) {
106
        // redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['xoopsModule']->getVar('dirname', 'n'), 3, _NOPERM);
107
    }
108
109
    if (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isAdmin()) {
110
        //disable cache
111
        $GLOBALS['xoopsConfig']['module_cache'][$GLOBALS['xoopsModule']->getVar('mid')] = 0;
112
    }
113
    $GLOBALS['xoopsTpl']->assign('user_ownpage', false);
114
}
115
116
$GLOBALS['xoopsTpl']->assign('user_uid', $thisUser->getVar('uid'));
117
if (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isAdmin()) {
118
    $GLOBALS['xoopsTpl']->assign('lang_editprofile', _US_EDITPROFILE);
119
    $GLOBALS['xoopsTpl']->assign('lang_deleteaccount', _US_DELACCOUNT);
120
    $GLOBALS['xoopsTpl']->assign('userlevel', $thisUser->isActive());
121
}
122
123
// Dynamic User Profiles
124
$thisUsergroups     = $thisUser->getGroups();
125
$visibility_handler = xoops_getModuleHandler('visibility');
126
//search for visible Fields or null for none
127
$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

127
$field_ids_visible = $visibility_handler->/** @scrutinizer ignore-call */ getVisibleFields($thisUsergroups, $groups);
Loading history...
128
129
$profile_handler = xoops_getModuleHandler('profile');
130
$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

130
$fields          = $profile_handler->/** @scrutinizer ignore-call */ loadFields();
Loading history...
131
$cat_handler     = xoops_getModuleHandler('category');
132
$cat_crit        = new CriteriaCompo();
133
$cat_crit->setSort('cat_weight');
134
$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

134
$cats = $cat_handler->/** @scrutinizer ignore-call */ getObjects($cat_crit, true, false);
Loading history...
135
unset($cat_crit);
136
137
$avatar = '';
138
if ($thisUser->getVar('user_avatar') && 'blank.gif' !== $thisUser->getVar('user_avatar')) {
139
    $avatar = XOOPS_UPLOAD_URL . '/' . $thisUser->getVar('user_avatar');
140
}
141
142
foreach (array_keys($cats) as $i) {
143
    $categories[$i] = $cats[$i];
144
}
145
146
$profile_handler = xoops_getModuleHandler('profile');
147
$profile         = $profile_handler->get($thisUser->getVar('uid'));
148
// Add dynamic fields
149
foreach (array_keys($fields) as $i) {
150
    //If field is not visible, skip
151
    //if ( $field_ids_visible && !in_array($fields[$i]->getVar('field_id'), $field_ids_visible) ) continue;
152
    if (!in_array($fields[$i]->getVar('field_id'), $field_ids_visible)) {
153
        continue;
154
    }
155
    $cat_id = $fields[$i]->getVar('cat_id');
156
    $value  = $fields[$i]->getOutputValue($thisUser, $profile);
157
    if (is_array($value)) {
158
        $value = implode('<br>', array_values($value));
159
    }
160
    if ($value) {
161
        $categories[$cat_id]['fields'][] = ['title' => $fields[$i]->getVar('field_title'), 'value' => $value];
162
        $weights[$cat_id][]              = $fields[$i]->getVar('cat_id');
163
    }
164
}
165
166
$GLOBALS['xoopsTpl']->assign('categories', $categories);
167
// Dynamic user profiles end
168
169
$mainvideocode = '';
170
$mainvideodesc = '';
171
172
//require_once __DIR__ . '/class/yogurt_controller.php';
173
//if (!@ require_once XOOPS_ROOT_PATH . '/language/' . $GLOBALS['xoopsConfig']['language'] . '/user.php') {
174
//    require_once XOOPS_ROOT_PATH . '/language/english/user.php';
175
//}
176
177
/**
178
 * This variable define the beginning of the navigation must be
179
 * set here so all calls to database will take this into account
180
 */
181
$start = Request::getInt(
182
    'start',
183
    0,
184
    'GET'
185
);
186
187
/**
188
 * Criteria for mainvideo
189
 */
190
$criteriaUidVideo   = new Criteria('uid_owner', $controller->uidOwner);
191
$criteria_mainvideo = new Criteria('main_video', '1');
192
$criteria_video     = new CriteriaCompo($criteria_mainvideo);
193
$criteria_video->add($criteriaUidVideo);
194
195
if ((isset($nbSections['nbVideos']) && $nbSections['nbVideos'] > 0) && ($videos = $controller->videosFactory->getObjects($criteria_video))) {
196
    $mainvideocode = $videos[0]->getVar('youtube_code');
197
    $mainvideodesc = $videos[0]->getVar('video_desc');
198
}
199
200
/**
201
 * Groups
202
 */
203
$criteria_groups = new Criteria('rel_user_uid', $controller->uidOwner);
204
$groups          = $controller->relgroupusersFactory->getGroups(8, $criteria_groups);
205
206
/**
207
 * Visitors
208
 */
209
$controller->visitorsFactory->purgeVisits();
210
211
if (0 === $controller->isAnonym) {
212
    /**
213
     * Fetching last visitors
214
     */
215
    if ($controller->uidOwner !== $xoopsUser->getVar('uid')) {
216
        $visitor_now = $controller->visitorsFactory->create();
217
        $visitor_now->setVar('uid_owner', $controller->uidOwner);
218
        $visitor_now->setVar('uid_visitor', $xoopsUser->getVar('uid'));
219
        $visitor_now->setVar('uname_visitor', $xoopsUser->getVar('uname'));
220
        $controller->visitorsFactory->insert2($visitor_now);
221
    }
222
    $criteria_visitors = new Criteria('uid_owner', $controller->uidOwner);
223
    //$criteria_visitors->setLimit(5);
224
    $visitorsObjectArray = $controller->visitorsFactory->getObjects(
225
        $criteria_visitors
226
    );
227
228
    /**
229
     * Lets populate an array with the data from visitors
230
     */
231
    $i             = 0;
232
    $visitorsArray = [];
233
    if (is_array($visitorsObjectArray) && count($visitorsObjectArray) > 0) {
234
        foreach ($visitorsObjectArray as $visitor) {
235
            if (null !== $visitor) {
236
                $indice                 = $visitor->getVar('uid_visitor', 's');
237
                $visitorsArray[$indice] = $visitor->getVar('uname_visitor', 's');
238
239
                $i++;
240
            }
241
        }
242
    }
243
244
    $xoopsTpl->assign('visitors', $visitorsArray);
245
    $xoopsTpl->assign('lang_visitors', _MD_YOGURT_VISITORS);
246
    /*    $criteria_deletevisitors = new criteria('uid_owner',$uid);
247
        $criteria_deletevisitors->setStart(5);
248
249
        print_r($criteria_deletevisitors);
250
        $visitorsFactory->deleteAll($criteria_deletevisitors, true);
251
    */
252
}
253
254
$avatar = $controller->owner->getVar('user_avatar');
255
256
$memberHandler = xoops_getHandler('member');
257
$thisUser      = $memberHandler->getUser($controller->uidOwner);
0 ignored issues
show
The method getUser() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsAvatarHandler or XoopsPersistableObjectHandler. ( Ignorable by Annotation )

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

257
$thisUser      = $memberHandler->/** @scrutinizer ignore-call */ getUser($controller->uidOwner);
Loading history...
258
$myts          = MyTextSanitizer::getInstance();
259
260
//navbar
261
$xoopsTpl->assign('lang_mysection', _MD_YOGURT_MYPROFILE);
262
$xoopsTpl->assign('section_name', _MD_YOGURT_PROFILE);
263
264
//$xoopsTpl->assign('path_yogurt_uploads',$helper->getConfig('link_path_upload'));
265
266
//groups
267
$xoopsTpl->assign('groups', $groups);
268
if (isset($nbSections['nbGroups']) && $nbSections['nbGroups'] <= 0) {
269
    $xoopsTpl->assign('lang_nogroupsyet', _MD_YOGURT_NOGROUPSYET);
270
}
271
$xoopsTpl->assign('lang_viewallgroups', _MD_YOGURT_ALLGROUPS);
272
273
//Avatar and Main
274
$xoopsTpl->assign('avatar_url', $avatar);
275
$xoopsTpl->assign('lang_selectavatar', _MD_YOGURT_SELECTAVATAR);
276
$xoopsTpl->assign('lang_selectmainvideo', _MD_YOGURT_SELECTMAINVIDEO);
277
$xoopsTpl->assign('lang_noavatar', _MD_YOGURT_NOAVATARYET);
278
$xoopsTpl->assign('lang_nomainvideo', _MD_YOGURT_NOMAINVIDEOYET);
279
$xoopsTpl->assign('lang_featuredvideo', _MD_YOGURT_VIDEO_FEATURED);
280
$xoopsTpl->assign('lang_viewallvideos', _MD_YOGURT_ALLVIDEOS);
281
282
if (isset($nbSections['nbVideos']) && $nbSections['nbVideos'] > 0) {
283
    $xoopsTpl->assign('mainvideocode', $mainvideocode);
284
    $xoopsTpl->assign('mainvideodesc', $mainvideodesc);
285
    $xoopsTpl->assign(
286
        'width',
287
        $helper->getConfig('width_maintube')
288
    ); // Falta configurar o tamnho do main nas configs e alterar no template
289
    $xoopsTpl->assign(
290
        'height',
291
        $helper->getConfig('height_maintube')
292
    );
293
}
294
295
/**
296
 * Friends
297
 */
298
if ($xoopsUser) {
299
    $controller = new Yogurt\FriendsController($xoopsDB, $xoopsUser);
300
301
    $friendrequest = 0;
302
    if (1 === $controller->isOwner) {
303
        $criteria_uidfriendrequest = new Criteria('friendrequestto_uid', $controller->uidOwner);
304
        $newFriendrequest          = $controller->friendrequestFactory->getObjects($criteria_uidfriendrequest);
305
        if ($newFriendrequest) {
306
            $countFriendrequest     = count($newFriendrequest);
307
            $friendrequesterHandler = xoops_getHandler('member');
308
            $friendrequester        = $friendrequesterHandler->getUser($newFriendrequest[0]->getVar('friendrequester_uid'));
309
            $friendrequester_uid    = $friendrequester->getVar('uid');
310
            $friendrequester_uname  = $friendrequester->getVar('uname');
311
            $friendrequester_avatar = $friendrequester->getVar('user_avatar');
312
            $friendrequest_id       = $newFriendrequest[0]->getVar('friendreq_id');
313
            $friendrequest          = 1;
314
        }
315
    }
316
317
    //requests to become friend
318
    if (1 === $friendrequest) {
319
        $xoopsTpl->assign('lang_youhavexfriendrequests', sprintf(_MD_YOGURT_YOUHAVEXFRIENDREQUESTS, $countFriendrequest));
320
        $xoopsTpl->assign('friendrequester_uid', $friendrequester_uid);
321
        $xoopsTpl->assign('friendrequester_uname', $friendrequester_uname);
322
        $xoopsTpl->assign('friendrequester_avatar', $friendrequester_avatar);
323
        $xoopsTpl->assign('friendrequest', $friendrequest);
324
        $xoopsTpl->assign('friendrequest_id', $friendrequest_id);
325
        $xoopsTpl->assign('lang_rejected', _MD_YOGURT_UNKNOWN_REJECTING);
326
        $xoopsTpl->assign('lang_accepted', _MD_YOGURT_UNKNOWN_ACCEPTING);
327
        $xoopsTpl->assign('lang_acquaintance', _MD_YOGURT_AQUAITANCE);
328
        $xoopsTpl->assign('lang_friend', _MD_YOGURT_FRIEND);
329
        $xoopsTpl->assign('lang_bestfriend', _MD_YOGURT_BESTFRIEND);
330
        $linkedpetioner = '<a href="index.php?uid=' . $friendrequester_uid . '">' . $friendrequester_uname . '</a>';
331
        $xoopsTpl->assign('lang_askingfriend', sprintf(_MD_YOGURT_ASKINGFRIEND, $linkedpetioner));
332
    }
333
}
334
335
$xoopsTpl->assign('lang_askusertobefriend', _MD_YOGURT_ASKBEFRIEND);
336
$xoopsTpl->assign('lang_addfriend', _MD_YOGURT_ADDFRIEND);
337
$xoopsTpl->assign('lang_friendrequestpending', _MD_YOGURT_FRIENDREQUEST_PENDING);
338
$xoopsTpl->assign('lang_myfriend', _MD_YOGURT_MYFRIEND);
339
$xoopsTpl->assign('lang_friendrequestsent', _MD_YOGURT_FRIENDREQUEST_SENT);
340
$xoopsTpl->assign('lang_acceptfriend', _MD_YOGURT_FRIEND_ACCEPT);
341
$xoopsTpl->assign('lang_rejectfriend', _MD_YOGURT_FRIEND_REJECT);
342
343
$criteria_friends = new Criteria('friend1_uid', $controller->uidOwner);
344
$friends          = $controller->friendshipsFactory->getFriends(8, $criteria_friends);
345
$xoopsTpl->assign('friends', $friends);
346
$xoopsTpl->assign('lang_friendstitle', sprintf(_MD_YOGURT_FRIENDSTITLE, $controller->nameOwner));
0 ignored issues
show
It seems like $controller->nameOwner can also be of type array and array; however, parameter $args of sprintf() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

346
$xoopsTpl->assign('lang_friendstitle', sprintf(_MD_YOGURT_FRIENDSTITLE, /** @scrutinizer ignore-type */ $controller->nameOwner));
Loading history...
347
$xoopsTpl->assign('lang_viewallfriends', _MD_YOGURT_ALLFRIENDS);
348
$xoopsTpl->assign('lang_nofriendsyet', _MD_YOGURT_NOFRIENDSYET);
349
350
//search
351
$xoopsTpl->assign('lang_usercontributions', _MD_YOGURT_USER_CONTRIBUTIONS);
352
353
//Profile
354
$xoopsTpl->assign('lang_detailsinfo', _MD_YOGURT_USER_DETAILS);
355
$xoopsTpl->assign('lang_contactinfo', _MD_YOGURT_CONTACTINFO);
356
//$xoopsTpl->assign('path_yogurt_uploads',$helper->getConfig('link_path_upload'));
357
$xoopsTpl->assign(
358
    'lang_max_countPicture',
359
    sprintf(_MD_YOGURT_YOUCANHAVE, $helper->getConfig('countPicture'))
360
);
361
$xoopsTpl->assign('lang_delete', _MD_YOGURT_DELETE);
362
$xoopsTpl->assign('lang_editdesc', _MD_YOGURT_EDIT_DESC);
363
$xoopsTpl->assign('lang_visitors', _MD_YOGURT_VISITORS);
364
$xoopsTpl->assign('lang_profilevisitors', _MD_YOGURT_PROFILEVISITORS);
365
$xoopsTpl->assign('lang_editprofile', _MD_YOGURT_EDITPROFILE);
366
367
$xoopsTpl->assign('user_uname', $thisUser->getVar('uname'));
368
$xoopsTpl->assign('user_realname', $thisUser->getVar('name'));
369
$xoopsTpl->assign('lang_uname', _US_NICKNAME);
370
$xoopsTpl->assign('lang_website', _US_WEBSITE);
371
$userwebsite = '' !== $thisUser->getVar('url', 'E') ? '<a href="' . $thisUser->getVar(
372
        'url',
373
        'E'
374
    ) . '" target="_blank">' . $thisUser->getVar(
375
        'url'
376
    ) . '</a>' : '';
377
$xoopsTpl->assign('user_websiteurl', $userwebsite);
378
$xoopsTpl->assign('lang_email', _US_EMAIL);
379
$xoopsTpl->assign('lang_privmsg', _US_PM);
380
$xoopsTpl->assign('lang_location', _US_LOCATION);
381
$xoopsTpl->assign('user_location', $thisUser->getVar('user_from'));
382
$xoopsTpl->assign('lang_occupation', _US_OCCUPATION);
383
$xoopsTpl->assign('user_occupation', $thisUser->getVar('user_occ'));
384
$xoopsTpl->assign('lang_interest', _US_INTEREST);
385
$xoopsTpl->assign('user_interest', $thisUser->getVar('user_intrest'));
386
$xoopsTpl->assign('lang_extrainfo', _US_EXTRAINFO);
387
$var = $thisUser->getVar('bio', 'N');
388
$xoopsTpl->assign('user_extrainfo', $myts->displayTarea($var, 0, 1, 1));
389
$xoopsTpl->assign('lang_statistics', _US_STATISTICS);
390
$xoopsTpl->assign('lang_membersince', _US_MEMBERSINCE);
391
$var = $thisUser->getVar('user_regdate');
392
$xoopsTpl->assign('user_joindate', formatTimestamp($var, 's'));
393
$xoopsTpl->assign('lang_rank', _US_RANK);
394
$xoopsTpl->assign('lang_posts', _US_POSTS);
395
$xoopsTpl->assign('lang_basicInfo', _US_BASICINFO);
396
$xoopsTpl->assign('lang_more', _US_MOREABOUT);
397
$xoopsTpl->assign('lang_myinfo', _US_MYINFO);
398
$xoopsTpl->assign('user_posts', $thisUser->getVar('posts'));
399
$xoopsTpl->assign('lang_lastlogin', _US_LASTLOGIN);
400
$date = $thisUser->getVar('last_login');
401
if (!empty($date)) {
402
    $xoopsTpl->assign('user_lastlogin', formatTimestamp($date, 'm'));
403
}
404
$xoopsTpl->assign('lang_notregistered', _US_NOTREGISTERED);
405
406
$xoopsTpl->assign('lang_signature', _US_SIGNATURE);
407
$var = $thisUser->getVar('user_sig', 'N');
408
$xoopsTpl->assign('user_signature', $myts->displayTarea($var, 0, 1, 1));
409
410
$xoopsTpl->assign('user_viewemail', $thisUser->getVar('user_viewemail', 'E'));
411
if (1 === $thisUser->getVar('user_viewemail')) {
412
    $xoopsTpl->assign('user_email', $thisUser->getVar('email', 'E'));
413
} else {
414
    $xoopsTpl->assign('user_email', '&nbsp;');
415
}
416
417
$xoopsTpl->assign('user_onlinestatus', $thisUser->isOnline());
418
$xoopsTpl->assign('lang_onlinestatus', _MD_YOGURT_ONLINESTATUS);
419
$xoopsTpl->assign('uname', $thisUser->getVar('uname'));
420
$xoopsTpl->assign('lang_realname', _US_REALNAME);
421
$xoopsTpl->assign('name', $thisUser->getVar('name'));
422
423
$gpermHandler  = xoops_getHandler('groupperm');
424
$groups        = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
425
$moduleHandler = xoops_getHandler('module');
426
$criteria      = new CriteriaCompo(new Criteria('hassearch', 1));
427
$criteria->add(new Criteria('isactive', 1));
428
$mids = array_keys($moduleHandler->getList($criteria));
0 ignored issues
show
The method getList() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsModuleHandler or XoopsImageHandler or XoopsRankHandler or XoopsCommentHandler or XoopsTplsetHandler or XoopsAvatarHandler or XoopsBlockHandler or XoopsImagesetHandler or XoopsPersistableObjectHandler or XoopsImagecategoryHandler. ( Ignorable by Annotation )

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

428
$mids = array_keys($moduleHandler->/** @scrutinizer ignore-call */ getList($criteria));
Loading history...
429
430
//user rank
431
$userrank = $thisUser->rank();
432
if ($userrank['image']) {
433
    $xoopsTpl->assign('user_rankimage', '<img src="' . XOOPS_UPLOAD_URL . '/' . $userrank['image'] . '" alt="">');
434
}
435
$xoopsTpl->assign('user_ranktitle', $userrank['title']);
436
437
foreach ($mids as $mid) {
438
    if ($gpermHandler->checkRight('module_read', $mid, $groups)) {
0 ignored issues
show
The method checkRight() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsGroupPermHandler or XoopsPersistableObjectHandler. ( Ignorable by Annotation )

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

438
    if ($gpermHandler->/** @scrutinizer ignore-call */ checkRight('module_read', $mid, $groups)) {
Loading history...
439
        $module   = $moduleHandler->get($mid);
440
        $user_uid = $thisUser->getVar('uid');
441
        $results  = $module->search('', '', 5, 0, $user_uid);
0 ignored issues
show
The method search() does not exist on XoopsObject. It seems like you code against a sub-type of XoopsObject such as XoopsModule. ( Ignorable by Annotation )

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

441
        /** @scrutinizer ignore-call */ 
442
        $results  = $module->search('', '', 5, 0, $user_uid);
Loading history...
442
        if (is_array($results)) {
443
            $count = count($results);
444
        }
445
        if (is_array($results) && $count > 0) {
446
            for ($i = 0; $i < $count; $i++) {
447
                if (isset($results[$i]['image']) && '' !== $results[$i]['image']) {
448
                    $results[$i]['image'] = 'modules/' . $module->getVar('dirname') . '/' . $results[$i]['image'];
449
                } else {
450
                    $results[$i]['image'] = 'images/icons/posticon2.gif';
451
                }
452
453
                if (!preg_match("#^http[s]*:\/\/#i", $results[$i]['link'])) {
454
                    $results[$i]['link'] = 'modules/' . $module->getVar('dirname') . '/' . $results[$i]['link'];
455
                }
456
457
                $results[$i]['title'] = $myts->htmlSpecialChars($results[$i]['title']);
458
                $results[$i]['time']  = $results[$i]['time'] ? formatTimestamp($results[$i]['time']) : '';
459
            }
460
            if (5 === $count) {
461
                $showall_link = '<a href="../../search.php?action=showallbyuser&amp;mid=' . $mid . '&amp;uid=' . $thisUser->getVar(
462
                        'uid'
463
                    ) . '">' . _US_SHOWALL . '</a>';
464
            } else {
465
                $showall_link = '';
466
            }
467
            $xoopsTpl->append(
468
                'modules',
469
                [
470
                    'name'         => $module->getVar('name'),
471
                    'results'      => $results,
472
                    'showall_link' => $showall_link,
473
                ]
474
            );
475
        }
476
        unset($module);
477
    }
478
}
479
480
require __DIR__ . '/footer.php';
481
require dirname(__DIR__, 2) . '/footer.php';
482