-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.php
116 lines (102 loc) · 5.34 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php
/*
* You may not change or alter any portion of this comment or credits
* of supporting developers from this source code or any supporting source code
* which is considered copyrighted (c) material of the original comment or credit authors.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
/**
* SmallWorld
*
* @package \XoopsModules\Smallworld
* @license GNU GPL (https://www.gnu.org/licenses/gpl-2.0.html/)
* @copyright The XOOPS Project (https://xoops.org)
* @copyright 2011 Culex
* @author Michael Albertsen (http://culex.dk) <culex@culex.dk>
* @link https://github.com/XoopsModules25x/smallworld
* @since 1.0
*/
use XoopsModules\Smallworld;
use XoopsModules\Smallworld\Constants;
require_once __DIR__ . '/header.php';
/** @var \XoopsModules\Smallworld\Helper $helper */
require_once $helper->path('include/functions.php');
require_once $helper->path('include/arrays.php');
if ($GLOBALS['xoopsUser'] instanceof \XoopsUser) {
$GLOBALS['xoopsOption']['template_main'] = 'smallworld_index.tpl';
} elseif (((!$GLOBALS['xoopsUser'] instanceof \XoopsUser)) || Constants::HAS_ACCESS == $set['access']) {
$GLOBALS['xoopsOption']['template_main'] = 'smallworld_publicindex.tpl';
} else {
redirect_header(XOOPS_URL . '/user.php', Constants::REDIRECT_DELAY_MEDIUM, _NOPERM);
}
require_once XOOPS_ROOT_PATH . '/header.php';
$set = smallworld_checkPrivateOrPublic();
if (Constants::HAS_ACCESS == $set['access']) {
$id = ($GLOBALS['xoopsUser'] instanceof \XoopsUser) ? $GLOBALS['xoopsUser']->uid() : Constants::DEFAULT_UID;
$user = new \XoopsUser($id); //creates Guest XOOPS user if not current XOOPS user
// Check if inspected userid -> redirect to userprofile and show admin countdown
$inspect = smallworld_isInspected($id);
if ('yes' === $inspect['inspect']) {
$helper->redirect('userprofile.php?username=' . $GLOBALS['xoopsUser']->getVar('uname'), Constants::REDIRECT_DELAY_NONE);
}
$GLOBALS['xoopsTpl']->assign('ownerofpage', $id);
$GLOBALS['xoopsTpl']->assign('isadminuser', ($helper->isUserAdmin() ? 'YES' : 'NO'));
// Create form for private settings
$form = new Smallworld\Form();
//$usersettings = $form->usersettings($id, $selected = null);
$GLOBALS['xoopsTpl']->assign('usersetting', $form->usersettings($id));
$username = $user->uname();
$profile = $helper->getHandler('SwUser')->checkIfProfile($id);
if (Constants::PROFILE_HAS_BOTH <= $profile) {
$profileObj = new Smallworld\Profile();
$profileObj->showUser($id);
$menu_startpage = "<a href='" . $helper->url('publicindex.php') . "'><img id='menuimg' src='" . $helper->url('assets/images/highrise.png') . "'>" . _SMALLWORLD_STARTPAGE . '</a>';
$menu_home = "<a href='" . $helper->url('index.php') . "'><img id='menuimg' src='" . $helper->url('assets/images/house.png') . "'>" . _SMALLWORLD_HOME . '</a>';
$menu_profile = "<a href='" . $helper->url('userprofile.php?username=' . $username) . "'><img id='menuimg' src='" . $helper->url('assets/images/user_silhouette.png') . "'>" . _SMALLWORLD_PROFILEINDEX . '</a>';
$menu_gallery = "<a href='" . $helper->url('galleryshow.php?username=' . $username) . "'><img id='menuimg' src='" . $helper->url('assets/images/picture.png') . "'>" . _SMALLWORLD_GALLERY . '</a>';
$menu_friends = "<a href='" . $helper->url('friends.php?username=' . $username) . "'><img id='menuimg' src='" . $helper->url('assets/images/group.png') . "'>" . _SMALLWORLD_FRIENDSPAGE . '</a>';
$wall = new Smallworld\WallUpdates();
// Follow array here
$followers = smallworld_array_flatten($wall->getFollowers($id), 0);
$updatesarray = $wall->Updates(0, $id, $followers);
$GLOBALS['xoopsTpl']->assign(
[
'menu_startpage' => $menu_startpage,
'menu_home' => $menu_home,
'menu_profile' => $menu_profile,
'menu_friends' => $menu_friends,
'menu_gallery' => $menu_gallery,
]
);
} else {
$wall = new Smallworld\PublicWallUpdates();
$pub = smallworld_checkUserPubPostPerm();
$updatesarray = $wall->Updates(0, $pub);
}
//Get friends invitations
$check = new Smallworld\User();
$getInvitations = $GLOBALS['xoopsUser'] ? $check->getRequests($id) : 0;
$wall->parsePubArray($updatesarray, $id);
$GLOBALS['xoopsTpl']->assign(
[
'myusername' => $username,
'pagename' => 'index',
'check' => $profile,
'friendinvitations' => $getInvitations,
'access' => $set['access'],
]
);
}
if (Constants::PROFILE_XOOPS_ONLY == $profile && Constants::NO_ACCESS == $set['access']) {
$helper->redirect('register.php');
}
// if ($profile == Constants::PROFILE_XOOPS_ONLY && $set['access'] <= Constants::HAS_ACCESS) {
// $helper->redirect('register.php');
// }
//if (Constants::PROFILE_NONE == $profile && Constants::NO_ACCESS == $set['access']) {
// redirect_header(XOOPS_URL . "/user.php", Constants::REDIRECT_DELAY_MEDIUM, _NOPERM);
//}
require_once XOOPS_ROOT_PATH . '/footer.php';