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 Xmf\Request; |
25
|
|
|
use XoopsModules\Smallworld; |
26
|
|
|
use XoopsModules\Smallworld\Constants; |
27
|
|
|
|
28
|
|
|
require_once __DIR__ . '/header.php'; |
29
|
|
|
|
30
|
|
|
$GLOBALS['xoopsOption']['template_main'] = 'smallworld_galleryshow.tpl'; |
31
|
|
|
require_once XOOPS_ROOT_PATH . '/header.php'; |
32
|
|
|
|
33
|
|
|
/** @var \XoopsModules\Smallworld\Helper $helper */ |
34
|
|
|
require_once $helper->path('include/functions.php'); |
35
|
|
|
|
36
|
|
|
$GLOBALS['xoopsLogger']->activated = false; |
37
|
|
|
|
38
|
|
|
$admin = $helper->isUserAdmin() ? true: false; |
39
|
|
|
|
40
|
|
|
if ($GLOBALS['xoopsUser'] && ($GLOBALS['xoopsUser'] instanceof \XoopsUser)) { |
41
|
|
|
/** @var \XoopsModules\Smallworld\SwUserHandler $swUserHandler */ |
42
|
|
|
$swUserHandler = $helper->getHandler('SwUser'); |
43
|
|
|
$id = $GLOBALS['xoopsUser']->uid(); |
44
|
|
|
$check = new Smallworld\User(); |
45
|
|
|
$image = new Smallworld\Images; |
46
|
|
|
$username = Request::getString('username', '', 'GET'); |
47
|
|
|
$userId = $swUserHandler->getByName($username); // gets id of user which profile you want to see |
48
|
|
|
//$userId = smallworld_isset_or($_GET['username']); // gets id of user which profile you want to see |
49
|
|
|
$userisfriend = $check->friendcheck($id, $userId); |
50
|
|
|
|
51
|
|
|
$tpl_admin = $admin ? 'YES' : 'NO'; |
52
|
|
|
$GLOBALS['xoopsTpl']->assign('isadminuser', $tpl_admin); |
53
|
|
|
|
54
|
|
|
// Check if inspected userid -> redirect to userprofile and show admin countdown |
55
|
|
|
$inspect = smallworld_isInspected($id); |
56
|
|
View Code Duplication |
if ('yes' === $inspect['inspect']) { |
|
|
|
|
57
|
|
|
$helper->redirect('userprofile.php?username=' . $GLOBALS['xoopsUser']->uname(), Constants::REDIRECT_DELAY_SHORT, _SMALLWORLD_INSPEC_usermsg); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
$profile = $swUserHandler->checkIfProfile($id); |
61
|
|
|
if ($profile >= Constants::PROFILE_HAS_BOTH || 2 == $userisfriend[0] || true === $admin) { |
62
|
|
|
$myusername = $GLOBALS['xoopsUser']->uname(); |
63
|
|
|
$countimages = $image->count($userId); |
64
|
|
|
//$gallery = $image->viewalbum ($id, $user=$GLOBALS['xoopsUser']->getVar('uid')); |
65
|
|
|
$gallery = $image->viewalbum($id, $userId); |
66
|
|
|
$GLOBALS['xoopsTpl']->assign([ |
67
|
|
|
'countimages' => $countimages, |
68
|
|
|
'userisfriend' => $userisfriend[0], |
69
|
|
|
'gallery' => $gallery, |
70
|
|
|
'closealbum' => _SMALLWORLD_ALBUMTITLETEXT, |
71
|
|
|
'username' => $username, |
72
|
|
|
'myusername' => $myusername, |
73
|
|
|
'gallerytitleheader' => _SMALLWORLD_TITLEHEADER, |
74
|
|
|
'check' => 1 |
75
|
|
|
]); |
76
|
|
|
} elseif (Constants::PROFILE_NONE == $profile) { |
77
|
|
|
$check->chkUser(); |
78
|
|
|
} else { |
79
|
|
|
$helper->redirect('userprofile.php?username=' . $GLOBALS['xoopsUser']->uname(), Constants::REDIRECT_DELAY_SHORT, _NOPERM); |
80
|
|
|
} |
81
|
|
|
} else { |
82
|
|
|
redirect_header(XOOPS_URL . '/user.php', Constants::REDIRECT_DELAY_SHORT, _NOPERM); |
83
|
|
|
} |
84
|
|
|
require_once XOOPS_ROOT_PATH . '/footer.php'; |
85
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.