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
|
|
|
* @package \XoopsModules\Smallworld |
16
|
|
|
* @license GNU GPL (https://www.gnu.org/licenses/gpl-2.0.html/) |
17
|
|
|
* @copyright The XOOPS Project (https://xoops.org) |
18
|
|
|
* @copyright 2011 Culex |
19
|
|
|
* @author Michael Albertsen (http://culex.dk) <[email protected]> |
20
|
|
|
* @link https://github.com/XoopsModules25x/smallworld |
21
|
|
|
* @since 1.0 |
22
|
|
|
*/ |
23
|
|
|
|
24
|
|
|
use XoopsModules\Smallworld; |
25
|
|
|
use XoopsModules\Smallworld\Constants; |
26
|
|
|
|
27
|
|
|
require_once __DIR__ . '/header.php'; |
28
|
|
|
|
29
|
|
|
/** @var \XoopsModules\Smallworld\Helper $helper */ |
30
|
|
|
require_once $helper->path('include/functions.php'); |
31
|
|
|
require_once $helper->path('include/arrays.php'); |
32
|
|
|
|
33
|
|
|
if ($GLOBALS['xoopsUser'] instanceof \XoopsUser) { |
34
|
|
|
$GLOBALS['xoopsOption']['template_main'] = 'smallworld_index.tpl'; |
35
|
|
|
} elseif (((!$GLOBALS['xoopsUser'] instanceof \XoopsUser)) || Constants::HAS_ACCESS == $set['access']) { |
36
|
|
|
$GLOBALS['xoopsOption']['template_main'] = 'smallworld_publicindex.tpl'; |
37
|
|
|
} else { |
38
|
|
|
redirect_header(XOOPS_URL . '/user.php', Constants::REDIRECT_DELAY_MEDIUM, _NOPERM); |
39
|
|
|
} |
40
|
|
|
require_once XOOPS_ROOT_PATH . '/header.php'; |
41
|
|
|
|
42
|
|
|
$set = smallworld_checkPrivateOrPublic(); |
43
|
|
|
|
44
|
|
|
if (Constants::HAS_ACCESS == $set['access']) { |
45
|
|
|
$id = ($GLOBALS['xoopsUser'] instanceof \XoopsUser) ? $GLOBALS['xoopsUser']->uid() : Constants::DEFAULT_UID; |
46
|
|
|
$user = new \XoopsUser($id); //creates Guest XOOPS user if not current XOOPS user |
47
|
|
|
|
48
|
|
|
// Check if inspected userid -> redirect to userprofile and show admin countdown |
49
|
|
|
$inspect = smallworld_isInspected($id); |
50
|
|
View Code Duplication |
if ('yes' === $inspect['inspect']) { |
51
|
|
|
$helper->redirect('userprofile.php?username=' . $GLOBALS['xoopsUser']->getVar('uname'), Constants::REDIRECT_DELAY_NONE); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
$GLOBALS['xoopsTpl']->assign('ownerofpage', $id); |
55
|
|
|
$GLOBALS['xoopsTpl']->assign('isadminuser', ($helper->isUserAdmin() ? 'YES' : 'NO')); |
56
|
|
|
|
57
|
|
|
// Create form for private settings |
58
|
|
|
$form = new Smallworld\Form(); |
59
|
|
|
//$usersettings = $form->usersettings($id, $selected = null); |
60
|
|
|
$GLOBALS['xoopsTpl']->assign('usersetting', $form->usersettings($id)); |
61
|
|
|
$username = $user->uname(); |
62
|
|
|
$profile = $helper->getHandler('SwUser')->checkIfProfile($id); |
63
|
|
|
if (Constants::PROFILE_HAS_BOTH <= $profile) { |
64
|
|
|
$profileObj = new Smallworld\Profile(); |
65
|
|
|
$profileObj->showUser($id); |
66
|
|
|
$menu_startpage = "<a href='" . $helper->url('publicindex.php') . "'><img id='menuimg' src='" . $helper->url('assets/images/highrise.png') . "'>" . _SMALLWORLD_STARTPAGE . '</a>'; |
67
|
|
|
$menu_home = "<a href='" . $helper->url('index.php') . "'><img id='menuimg' src='" . $helper->url('assets/images/house.png') . "'>" . _SMALLWORLD_HOME . '</a>'; |
68
|
|
|
$menu_profile = "<a href='" . $helper->url('userprofile.php?username=' . $username) . "'><img id='menuimg' src='" . $helper->url('assets/images/user_silhouette.png') . "'>" . _SMALLWORLD_PROFILEINDEX . '</a>'; |
69
|
|
|
$menu_gallery = "<a href='" . $helper->url('galleryshow.php?username=' . $username) . "'><img id='menuimg' src='" . $helper->url('assets/images/picture.png') . "'>" . _SMALLWORLD_GALLERY . '</a>'; |
70
|
|
|
$menu_friends = "<a href='" . $helper->url('friends.php?username=' . $username) . "'><img id='menuimg' src='" . $helper->url('assets/images/group.png') . "'>" . _SMALLWORLD_FRIENDSPAGE . '</a>'; |
71
|
|
|
$wall = new Smallworld\WallUpdates(); |
72
|
|
|
// Follow array here |
73
|
|
|
$followers = smallworld_array_flatten($wall->getFollowers($id), 0); |
74
|
|
|
$updatesarray = $wall->Updates(0, $id, $followers); |
75
|
|
|
$GLOBALS['xoopsTpl']->assign( |
76
|
|
|
[ |
77
|
|
|
'menu_startpage' => $menu_startpage, |
78
|
|
|
'menu_home' => $menu_home, |
79
|
|
|
'menu_profile' => $menu_profile, |
80
|
|
|
'menu_friends' => $menu_friends, |
81
|
|
|
'menu_gallery' => $menu_gallery, |
82
|
|
|
] |
83
|
|
|
); |
84
|
|
|
} else { |
85
|
|
|
$wall = new Smallworld\PublicWallUpdates(); |
86
|
|
|
$pub = smallworld_checkUserPubPostPerm(); |
87
|
|
|
$updatesarray = $wall->Updates(0, $pub); |
|
|
|
|
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
//Get friends invitations |
91
|
|
|
$check = new Smallworld\User(); |
92
|
|
|
$getInvitations = $GLOBALS['xoopsUser'] ? $check->getRequests($id) : 0; |
93
|
|
|
$wall->parsePubArray($updatesarray, $id); |
|
|
|
|
94
|
|
|
$GLOBALS['xoopsTpl']->assign( |
95
|
|
|
[ |
96
|
|
|
'myusername' => $username, |
97
|
|
|
'pagename' => 'index', |
98
|
|
|
'check' => $profile, |
99
|
|
|
'friendinvitations' => $getInvitations, |
100
|
|
|
'access' => $set['access'], |
101
|
|
|
] |
102
|
|
|
); |
103
|
|
|
} |
104
|
|
|
if (Constants::PROFILE_XOOPS_ONLY == $profile && Constants::NO_ACCESS == $set['access']) { |
105
|
|
|
$helper->redirect('register.php'); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
// if ($profile == Constants::PROFILE_XOOPS_ONLY && $set['access'] <= Constants::HAS_ACCESS) { |
109
|
|
|
// $helper->redirect('register.php'); |
110
|
|
|
// } |
111
|
|
|
|
112
|
|
|
//if (Constants::PROFILE_NONE == $profile && Constants::NO_ACCESS == $set['access']) { |
113
|
|
|
// redirect_header(XOOPS_URL . "/user.php", Constants::REDIRECT_DELAY_MEDIUM, _NOPERM); |
114
|
|
|
//} |
115
|
|
|
|
116
|
|
|
require_once XOOPS_ROOT_PATH . '/footer.php'; |
117
|
|
|
|
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.