Passed
Push — master ( 7c9d88...a7d412 )
by Michael
03:18 queued 10s
created

index.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
/*
5
 You may not change or alter any portion of this comment or credits
6
 of supporting developers from this source code or any supporting source code
7
 which is considered copyrighted (c) material of the original comment or credit authors.
8
9
 This program is distributed in the hope that it will be useful,
10
 but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
*/
13
14
/**
15
 * @category        Module
16
 * @package         suico
17
 * @copyright       {@link https://xoops.org/ XOOPS Project}
18
 * @license         GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
19
 * @author          Marcello Brandão aka  Suico, Mamba, LioMJ  <https://xoops.org>
20
 */
21
22
use Xmf\Request;
23
use XoopsModules\Suico;
24
use XoopsModules\Suico\IndexController;
25
26
/**
27
 * Xoops header
28
 */
29
$GLOBALS['xoopsOption']['template_main'] = 'suico_index.tpl';
30
require __DIR__ . '/header.php';
31
$helper->loadLanguage('user');
32
$controller = new IndexController($xoopsDB, $xoopsUser);
33
/**
34
 * Fetching numbers of groups friends videos pictures etc...
35
 */
36
$nbSections = $controller->getNumbersSections();
37
$uid        = $controller->uidOwner;
38
$categories = [];
39
/* @var  \XoopsGroupPermHandler $grouppermHandler */
40
$grouppermHandler = xoops_getHandler('groupperm');
41
$groups           = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : [XOOPS_GROUP_ANONYMOUS];
42
if (is_object($GLOBALS['xoopsUser']) && $uid == $GLOBALS['xoopsUser']->getVar('uid')) {
43
    //disable cache
44
    $GLOBALS['xoopsConfig']['module_cache'][$GLOBALS['xoopsModule']->getVar('mid')] = 0;
45
    include $GLOBALS['xoops']->path('header.php');
46
    /* @var XoopsConfigHandler $configHandler */
47
    $configHandler             = xoops_getHandler('config');
48
    $GLOBALS['xoopsConfigUser'] = $configHandler->getConfigsByCat(XOOPS_CONF_USER);
49
    $GLOBALS['xoopsTpl']->assign('user_ownpage', true);
50
    if (1 == $GLOBALS['xoopsConfigUser']['self_delete']) {
51
        $GLOBALS['xoopsTpl']->assign('user_candelete', true);
52
        $GLOBALS['xoopsTpl']->assign('lang_deleteaccount', _US_DELACCOUNT);
53
    } else {
54
        $GLOBALS['xoopsTpl']->assign('user_candelete', false);
55
    }
56
    $GLOBALS['xoopsTpl']->assign('user_changeemail', $GLOBALS['xoopsConfigUser']['allow_chgmail']);
57
    $thisUser = &$GLOBALS['xoopsUser'];
58
} else {
59
    /* @var XoopsMemberHandler $memberHandler */
60
    $memberHandler = xoops_getHandler('member');
61
    $thisUser      = $memberHandler->getUser($uid);
62
    // Redirect if not a user or not active and the current user is not admin
63
    if (!is_object($thisUser) || (!$thisUser->isActive() && (!$GLOBALS['xoopsUser'] || !$GLOBALS['xoopsUser']->isAdmin()))) {
64
        redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['xoopsModule']->getVar('dirname', 'n'), 3, _US_SELECTNG);
65
    }
66
    /**
67
     * Access permission check
68
     *
69
     * Note:
70
     * "thisUser" refers to the user whose profile will be accessed; "xoopsUser" refers to the current user $GLOBALS['xoopsUser']
71
     * "Basic Groups" refer to XOOPS_GROUP_ADMIN, XOOPS_GROUP_USERS and XOOPS_GROUP_ANONYMOUS;
72
     * "Non Basic Groups" refer to all other custom groups
73
     *
74
     * 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
75
     * 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
76
     * 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
77
     */
78
    // Redirect if current user is not allowed to access the user's profile based on group permission
79
    $groups_basic             = [XOOPS_GROUP_ADMIN, XOOPS_GROUP_USERS, XOOPS_GROUP_ANONYMOUS];
80
    $groups_thisUser          = $thisUser->getGroups();
81
    $groups_thisUser_nonbasic = array_diff($groups_thisUser, $groups_basic);
82
    $groups_xoopsUser         = $groups;
83
    /* @var  XoopsGroupPermHandler $grouppermHandler */
84
    $grouppermHandler  = xoops_getHandler('groupperm');
85
    $groups_accessible = $grouppermHandler->getItemIds('profile_access', $groups_xoopsUser, $helper->getModule()->getVar('mid'));
86
    $rejected = false;
87
    if ($thisUser->isAdmin()) {
88
        $rejected = !in_array(XOOPS_GROUP_ADMIN, $groups_accessible);
89
    } elseif ($groups_thisUser_nonbasic) {
90
        $rejected = !array_intersect($groups_thisUser_nonbasic, $groups_accessible);
91
    } else {
92
        $rejected = !in_array(XOOPS_GROUP_USERS, $groups_accessible);
93
    }
94
    if ($rejected) {
95
        // redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['xoopsModule']->getVar('dirname', 'n'), 3, _NOPERM);
96
    }
97
    if (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isAdmin()) {
98
        //disable cache
99
        $GLOBALS['xoopsConfig']['module_cache'][$GLOBALS['xoopsModule']->getVar('mid')] = 0;
100
    }
101
    $GLOBALS['xoopsTpl']->assign('user_ownpage', false);
102
}
103
$GLOBALS['xoopsTpl']->assign('user_uid', $thisUser->getVar('uid'));
104
if (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isAdmin()) {
105
    $GLOBALS['xoopsTpl']->assign('lang_editprofile', _US_EDITPROFILE);
106
    $GLOBALS['xoopsTpl']->assign('lang_deleteaccount', _US_DELACCOUNT);
107
    $GLOBALS['xoopsTpl']->assign('userlevel', $thisUser->isActive());
108
}
109
// Dynamic User Profiles
110
$thisUsergroups     = $thisUser->getGroups();
111
$visibilityHandler = $helper->getHandler('Visibility');
112
//search for visible Fields or null for none
113
$field_ids_visible = $visibilityHandler->getVisibleFields($thisUsergroups, $groups);
114
$profileHandler = $helper->getHandler('Profile');
115
$fields          = $profileHandler->loadFields();
116
$categoryHandler     = $helper->getHandler('Category');
117
$categoryCriteria        = new CriteriaCompo();
118
$categoryCriteria->setSort('cat_weight');
119
$cats = $categoryHandler->getObjects($categoryCriteria, true, false);
120
unset($categoryCriteria);
121
$avatar = '';
122
if ($thisUser->getVar('user_avatar') && 'blank.gif' !== $thisUser->getVar('user_avatar')) {
123
    $avatar = XOOPS_UPLOAD_URL . '/' . $thisUser->getVar('user_avatar');
124
}
125
foreach (array_keys($cats) as $i) {
126
    $categories[$i] = $cats[$i];
127
}
128
$profileHandler = $helper->getHandler('Profile');
129
$profile         = $profileHandler->get($thisUser->getVar('uid'));
130
// Add dynamic fields
131
foreach (array_keys($fields) as $i) {
132
    //If field is not visible, skip
133
    //if ( $field_ids_visible && !in_array($fields[$i]->getVar('field_id'), $field_ids_visible) ) continue;
134
    if (!in_array($fields[$i]->getVar('field_id'), $field_ids_visible)) {
135
        continue;
136
    }
137
    $cat_id = $fields[$i]->getVar('cat_id');
138
    $value  = $fields[$i]->getOutputValue($thisUser, $profile);
139
    if (is_array($value)) {
140
        $value = implode('<br>', array_values($value));
141
    }
142
    if ($value) {
143
        $categories[$cat_id]['fields'][] = ['title' => $fields[$i]->getVar('field_title'), 'value' => $value];
144
        $weights[$cat_id][]              = $fields[$i]->getVar('cat_id');
145
    }
146
}
147
$GLOBALS['xoopsTpl']->assign('categories', $categories);
148
// Dynamic user profiles end
149
$featuredvideocode = '';
150
$featuredvideotitle = '';
151
$featuredvideodesc = '';
152
//require_once __DIR__ . '/class/suico_controller.php';
153
//if (!@ require_once XOOPS_ROOT_PATH . '/language/' . $GLOBALS['xoopsConfig']['language'] . '/user.php') {
154
//    require_once XOOPS_ROOT_PATH . '/language/english/user.php';
155
//}
156
/**
157
 * This variable define the beginning of the navigation must be
158
 * set here so all calls to database will take this into account
159
 */
160
$start = Request::getInt('start', 0, 'GET');
161
/**
162
 * Criteria for featuredvideo
163
 */
164
$criteriaUidVideo   = new Criteria('uid_owner', $controller->uidOwner);
165
$criteria_featuredvideo = new Criteria('featured_video', '1');
166
$criteria_video     = new CriteriaCompo($criteria_featuredvideo);
167
$criteria_video->add($criteriaUidVideo);
168
if ((isset($nbSections['countVideos']) && $nbSections['countVideos'] > 0) && ($videos = $controller->videosFactory->getObjects($criteria_video))) {
169
    $featuredvideocode = $videos[0]->getVar('youtube_code');
170
	$featuredvideotitle = $videos[0]->getVar('video_title');
171
    $featuredvideodesc = $videos[0]->getVar('video_desc');
172
}
173
/**
174
 * Groups
175
 */
176
$criteria_groups = new Criteria('rel_user_uid', $controller->uidOwner);
177
$groups          = $controller->relgroupusersFactory->getGroups(8, $criteria_groups);
178
/**
179
 * Visitors
180
 */
181
$controller->visitorsFactory->purgeVisits();
182
if (0 === $controller->isAnonym) {
183
    /**
184
     * Fetching last visitors
185
     */
186
    if ($controller->uidOwner !== $xoopsUser->getVar('uid')) {
187
        $visitor_now = $controller->visitorsFactory->create();
188
        $visitor_now->setVar('uid_owner', $controller->uidOwner);
189
        $visitor_now->setVar('uid_visitor', $xoopsUser->getVar('uid'));
190
        $visitor_now->setVar('uname_visitor', $xoopsUser->getVar('uname'));
191
        $controller->visitorsFactory->insert2($visitor_now);
192
    }
193
    $criteria_visitors = new Criteria('uid_owner', $controller->uidOwner);
194
    //$criteria_visitors->setLimit(5);
195
    $visitorsObjectArray = $controller->visitorsFactory->getObjects(
196
        $criteria_visitors
197
    );
198
    /**
199
     * Lets populate an array with the data from visitors
200
     */
201
    $i             = 0;
202
    $visitorsArray = [];
203
    if (is_array($visitorsObjectArray) && count($visitorsObjectArray) > 0) {
204
        foreach ($visitorsObjectArray as $visitor) {
205
            if (null !== $visitor) {
206
                $indice                 = $visitor->getVar('uid_visitor', 's');
207
                $visitorsArray[$indice] = $visitor->getVar('uname_visitor', 's');
208
                $i++;
209
            }
210
        }
211
    }
212
    $xoopsTpl->assign('visitors', $visitorsArray);
213
    $xoopsTpl->assign('lang_visitors', _MD_SUICO_VISITORS);
214
    /*    $criteria_deletevisitors = new criteria('uid_owner',$uid);
215
        $criteria_deletevisitors->setStart(5);
216
217
        print_r($criteria_deletevisitors);
218
        $visitorsFactory->deleteAll($criteria_deletevisitors, true);
219
    */
220
}
221
$avatar = $controller->owner->getVar('user_avatar');
222
$memberHandler = xoops_getHandler('member');
223
$thisUser      = $memberHandler->getUser($controller->uidOwner);
224
$myts          = MyTextSanitizer::getInstance();
225
//navbar
226
$xoopsTpl->assign('lang_mysection', _MD_SUICO_MYPROFILE);
227
$xoopsTpl->assign('section_name', _MD_SUICO_PROFILE);
228
//$xoopsTpl->assign('path_suico_uploads',$helper->getConfig('link_path_upload'));
229
//groups
230
$xoopsTpl->assign('groups', $groups);
231
if (isset($nbSections['countGroups']) && $nbSections['countGroups'] <= 0) {
232
    $xoopsTpl->assign('lang_nogroupsyet', _MD_SUICO_NOGROUPSYET);
233
}
234
$xoopsTpl->assign('lang_viewallgroups', _MD_SUICO_ALLGROUPS);
235
//Avatar and Main
236
$xoopsTpl->assign('avatar_url', $avatar);
237
$xoopsTpl->assign('lang_selectavatar', _MD_SUICO_SELECTAVATAR);
238
$xoopsTpl->assign('lang_selectfeaturedvideo', _MD_SUICO_SELECTFEATUREDVIDEO);
239
$xoopsTpl->assign('lang_noavatar', _MD_SUICO_NOAVATARYET);
240
$xoopsTpl->assign('lang_nofeaturedvideo', _MD_SUICO_NOFEATUREDVIDEOYET);
241
$xoopsTpl->assign('lang_featuredvideo', _MD_SUICO_VIDEO_FEATURED);
242
$xoopsTpl->assign('lang_viewallvideos', _MD_SUICO_ALLVIDEOS);
243
if (isset($nbSections['countGroups']) && $nbSections['countGroups'] > 0) {
244
    $xoopsTpl->assign('featuredvideocode', $featuredvideocode);
245
    $xoopsTpl->assign('featuredvideodesc', $featuredvideodesc);
246
	$xoopsTpl->assign('featuredvideotitle', $featuredvideotitle);
247
    $xoopsTpl->assign(
248
        'width',
249
        $helper->getConfig('width_maintube')
250
    ); // Falta configurar o tamnho do main nas configs e alterar no template
251
    $xoopsTpl->assign(
252
        'height',
253
        $helper->getConfig('height_maintube')
254
    );
255
}
256
/**
257
 * Friends
258
 */
259
$friendController = new Suico\FriendsController($xoopsDB, $xoopsUser);
260
if ($xoopsUser) {
261
    $friendrequest = 0;
262
    if (1 === $friendController->isOwner) {
263
        $criteria_uidfriendrequest = new Criteria('friendrequestto_uid', $friendController->uidOwner);
264
        $newFriendrequest          = $friendController->friendrequestFactory->getObjects($criteria_uidfriendrequest);
265
        if ($newFriendrequest) {
266
            $countFriendrequest     = count($newFriendrequest);
267
            $memberHandler = xoops_getHandler('member');
268
            $friendrequester        = $memberHandler->getUser($newFriendrequest[0]->getVar('friendrequester_uid'));
269
            $friendrequester_uid    = $friendrequester->getVar('uid');
270
            $friendrequester_uname  = $friendrequester->getVar('uname');
271
            $friendrequester_avatar = $friendrequester->getVar('user_avatar');
272
            $friendrequest_id       = $newFriendrequest[0]->getVar('friendreq_id');
273
            $friendrequest          = 1;
274
        }
275
    }
276
    //requests to become friend
277
    if (1 === $friendrequest) {
278
        $xoopsTpl->assign('lang_you_have_x_friendrequests', sprintf(_MD_SUICO_YOU_HAVE_X_FRIENDREQUESTS, $countFriendrequest));
279
        $xoopsTpl->assign('friendrequester_uid', $friendrequester_uid);
280
        $xoopsTpl->assign('friendrequester_uname', $friendrequester_uname);
281
        $xoopsTpl->assign('friendrequester_avatar', $friendrequester_avatar);
282
        $xoopsTpl->assign('friendrequest', $friendrequest);
283
        $xoopsTpl->assign('friendrequest_id', $friendrequest_id);
284
        $xoopsTpl->assign('lang_rejected', _MD_SUICO_UNKNOWN_REJECTING);
285
        $xoopsTpl->assign('lang_accepted', _MD_SUICO_UNKNOWN_ACCEPTING);
286
        $xoopsTpl->assign('lang_acquaintance', _MD_SUICO_AQUAITANCE);
287
        $xoopsTpl->assign('lang_friend', _MD_SUICO_FRIEND);
288
        $xoopsTpl->assign('lang_bestfriend', _MD_SUICO_BESTFRIEND);
289
        $linkedpetioner = '<a href="index.php?uid=' . $friendrequester_uid . '">' . $friendrequester_uname . '</a>';
290
        $xoopsTpl->assign('lang_askingfriend', sprintf(_MD_SUICO_ASKINGFRIEND, $linkedpetioner));
291
    }
292
}
293
$xoopsTpl->assign('lang_askusertobefriend', _MD_SUICO_ASKBEFRIEND);
294
$xoopsTpl->assign('lang_addfriend', _MD_SUICO_ADDFRIEND);
295
$xoopsTpl->assign('lang_friendrequestpending', _MD_SUICO_FRIENDREQUEST_PENDING);
296
$xoopsTpl->assign('lang_myfriend', _MD_SUICO_MYFRIEND);
297
$xoopsTpl->assign('lang_friendrequestsent', _MD_SUICO_FRIENDREQUEST_SENT);
298
$xoopsTpl->assign('lang_acceptfriend', _MD_SUICO_FRIEND_ACCEPT);
299
$xoopsTpl->assign('lang_rejectfriend', _MD_SUICO_FRIEND_REJECT);
300
$criteria_friends = new Criteria('friend1_uid', $friendController->uidOwner);
301
$friends          = $friendController->friendshipsFactory->getFriends(8, $criteria_friends);
302
$xoopsTpl->assign('friends', $friends);
303
$xoopsTpl->assign('lang_friendstitle', sprintf(_MD_SUICO_FRIENDSTITLE, $friendController->nameOwner));
0 ignored issues
show
It seems like $friendController->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

303
$xoopsTpl->assign('lang_friendstitle', sprintf(_MD_SUICO_FRIENDSTITLE, /** @scrutinizer ignore-type */ $friendController->nameOwner));
Loading history...
304
$xoopsTpl->assign('lang_viewallfriends', _MD_SUICO_ALLFRIENDS);
305
$xoopsTpl->assign('lang_nofriendsyet', _MD_SUICO_NOFRIENDSYET);
306
//search
307
$xoopsTpl->assign('lang_usercontributions', _MD_SUICO_USER_CONTRIBUTIONS);
308
//Profile
309
$xoopsTpl->assign('lang_detailsinfo', _MD_SUICO_USER_DETAILS);
310
$xoopsTpl->assign('lang_contactinfo', _MD_SUICO_CONTACTINFO);
311
//$xoopsTpl->assign('path_suico_uploads',$helper->getConfig('link_path_upload'));
312
$xoopsTpl->assign(
313
    'lang_max_countPicture',
314
    sprintf(_MD_SUICO_YOUCANHAVE, $helper->getConfig('countPicture'))
315
);
316
$xoopsTpl->assign('lang_delete', _MD_SUICO_DELETE);
317
$xoopsTpl->assign('lang_visitors', _MD_SUICO_VISITORS);
318
$xoopsTpl->assign('lang_profilevisitors', _MD_SUICO_PROFILEVISITORS);
319
$xoopsTpl->assign('lang_editprofile', _MD_SUICO_EDITPROFILE);
320
$xoopsTpl->assign('user_uname', $thisUser->getVar('uname'));
321
$xoopsTpl->assign('user_realname', $thisUser->getVar('name'));
322
$xoopsTpl->assign('lang_uname', _US_NICKNAME);
323
$xoopsTpl->assign('lang_website', _US_WEBSITE);
324
$userwebsite = '' !== $thisUser->getVar('url', 'E') ? '<a href="' . $thisUser->getVar(
325
        'url',
326
        'E'
327
    ) . '" target="_blank">' . $thisUser->getVar(
328
        'url'
329
    ) . '</a>' : '';
330
$xoopsTpl->assign('user_websiteurl', $userwebsite);
331
$xoopsTpl->assign('lang_email', _US_EMAIL);
332
$xoopsTpl->assign('lang_privmsg', _US_PM);
333
$xoopsTpl->assign('lang_location', _US_LOCATION);
334
$xoopsTpl->assign('user_location', $thisUser->getVar('user_from'));
335
$xoopsTpl->assign('lang_occupation', _US_OCCUPATION);
336
$xoopsTpl->assign('user_occupation', $thisUser->getVar('user_occ'));
337
$xoopsTpl->assign('lang_interest', _US_INTEREST);
338
$xoopsTpl->assign('user_interest', $thisUser->getVar('user_intrest'));
339
$xoopsTpl->assign('lang_extrainfo', _US_EXTRAINFO);
340
$var = $thisUser->getVar('bio', 'N');
341
$xoopsTpl->assign('user_extrainfo', $myts->displayTarea($var, 0, 1, 1));
342
$xoopsTpl->assign('lang_statistics', _US_STATISTICS);
343
$xoopsTpl->assign('lang_membersince', _US_MEMBERSINCE);
344
$var = $thisUser->getVar('user_regdate');
345
$xoopsTpl->assign('user_joindate', formatTimestamp($var, 's'));
346
$xoopsTpl->assign('lang_rank', _US_RANK);
347
$xoopsTpl->assign('lang_posts', _US_POSTS);
348
$xoopsTpl->assign('lang_basicInfo', _US_BASICINFO);
349
$xoopsTpl->assign('lang_more', _US_MOREABOUT);
350
$xoopsTpl->assign('lang_myinfo', _US_MYINFO);
351
$xoopsTpl->assign('user_posts', $thisUser->getVar('posts'));
352
$xoopsTpl->assign('lang_lastlogin', _US_LASTLOGIN);
353
$date = $thisUser->getVar('last_login');
354
if (!empty($date)) {
355
    $xoopsTpl->assign('user_lastlogin', formatTimestamp($date, 'm'));
356
}
357
$xoopsTpl->assign('lang_notregistered', _US_NOTREGISTERED);
358
$xoopsTpl->assign('lang_signature', _US_SIGNATURE);
359
$var = $thisUser->getVar('user_sig', 'N');
360
$xoopsTpl->assign('user_signature', $myts->displayTarea($var, 0, 1, 1));
361
$xoopsTpl->assign('user_viewemail', $thisUser->getVar('user_viewemail', 'E'));
362
if (1 === $thisUser->getVar('user_viewemail')) {
363
    $xoopsTpl->assign('user_email', $thisUser->getVar('email', 'E'));
364
} else {
365
    $xoopsTpl->assign('user_email', '&nbsp;');
366
}
367
$xoopsTpl->assign('user_onlinestatus', $thisUser->isOnline());
368
$xoopsTpl->assign('lang_onlinestatus', _MD_SUICO_ONLINESTATUS);
369
$xoopsTpl->assign('uname', $thisUser->getVar('uname'));
370
$xoopsTpl->assign('lang_realname', _US_REALNAME);
371
$xoopsTpl->assign('name', $thisUser->getVar('name'));
372
$gpermHandler  = xoops_getHandler('groupperm');
373
$groups        = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
374
$moduleHandler = xoops_getHandler('module');
375
$criteria      = new CriteriaCompo(new Criteria('hassearch', 1));
376
$criteria->add(new Criteria('isactive', 1));
377
$mids = array_keys($moduleHandler->getList($criteria));
378
//user rank
379
$userrank = $thisUser->rank();
380
if ($userrank['image']) {
381
    $xoopsTpl->assign('user_rankimage', '<img src="' . XOOPS_UPLOAD_URL . '/' . $userrank['image'] . '" alt="">');
382
}
383
$xoopsTpl->assign('user_ranktitle', $userrank['title']);
384
foreach ($mids as $mid) {
385
    if ($gpermHandler->checkRight('module_read', $mid, $groups)) {
386
        $module   = $moduleHandler->get($mid);
387
        $user_uid = $thisUser->getVar('uid');
388
        $results  = $module->search('', '', 5, 0, $user_uid);
389
        if (is_array($results)) {
390
            $count = count($results);
391
        }
392
        if (is_array($results) && $count > 0) {
393
            for ($i = 0; $i < $count; $i++) {
394
                if (isset($results[$i]['image']) && '' !== $results[$i]['image']) {
395
                    $results[$i]['image'] = 'modules/' . $module->getVar('dirname') . '/' . $results[$i]['image'];
396
                } else {
397
                    $results[$i]['image'] = 'images/icons/posticon2.gif';
398
                }
399
                if (!preg_match("#^http[s]*:\/\/#i", $results[$i]['link'])) {
400
                    $results[$i]['link'] = 'modules/' . $module->getVar('dirname') . '/' . $results[$i]['link'];
401
                }
402
                $results[$i]['title'] = $myts->htmlSpecialChars($results[$i]['title']);
403
                $results[$i]['time']  = $results[$i]['time'] ? formatTimestamp($results[$i]['time']) : '';
404
            }
405
            if (5 === $count) {
406
                $showall_link = '<a href="../../search.php?action=showallbyuser&amp;mid=' . $mid . '&amp;uid=' . $thisUser->getVar(
407
                        'uid'
408
                    ) . '">' . _US_SHOWALL . '</a>';
409
            } else {
410
                $showall_link = '';
411
            }
412
            $xoopsTpl->append(
413
                'modules',
414
                [
415
                    'name'         => $module->getVar('name'),
416
                    'results'      => $results,
417
                    'showall_link' => $showall_link,
418
                ]
419
            );
420
        }
421
        unset($module);
422
    }
423
}
424
require __DIR__ . '/footer.php';
425
require dirname(__DIR__, 2) . '/footer.php';
426