-
Notifications
You must be signed in to change notification settings - Fork 5
/
loadmore.php
122 lines (103 loc) · 4.03 KB
/
loadmore.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
117
118
119
120
121
<?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) <[email protected]>
* @link https://github.com/XoopsModules25x/smallworld
* @since 1.0
*/
use Xmf\Request;
use XoopsModules\Smallworld;
use XoopsModules\Smallworld\Constants;
require_once __DIR__ . '/header.php';
require_once XOOPS_ROOT_PATH . '/class/template.php';
/** @var \XoopsModules\Smallworld\Helper $helper */
require_once $helper->path('include/functions.php');
require_once $helper->path('include/arrays.php');
$set = smallworld_checkPrivateOrPublic();
$pub = smallworld_checkUserPubPostPerm();
$hm = smallworld_GetModuleOption('msgtoshow');
$last = $GLOBALS['xoopsDB']->escape($_POST['last']);
$page = $GLOBALS['xoopsDB']->escape($_POST['page']);
$GLOBALS['xoopsLogger']->activated = false;
/* error_reporting(E_ALL); */
//$GLOBALS['xoopsTpl'] = new \XoopsTpl();
//$check = new Smallworld\User();
$id = Constants::DEFAULT_UID;
$username = '';
$profile = Constants::PROFILE_NONE;
$isAdmin = $helper->isUserAdmin();
$tplAdmin= $isAdmin ? 'YES' : 'NO';
/**@var \XoopsModules\Smallworld\SwUserHandler $swUserHandler */
$swUserHandler = $helper->getHandler('SwUser');
if ($GLOBALS['xoopsUser'] && ($GLOBALS['xoopsUser'] instanceof \XoopsUser)) {
$id = $GLOBALS['xoopsUser']->uid();
$username = $GLOBALS['xoopsUser']->uname();
//$profile = $check->checkIfProfile($id);
$profile = $swUserHandler->checkIfProfile($id);
if ($isAdmin) {
$pub = $swUserHandler->allUsers();
/*
$check = new Smallworld\User();
$pub = $check->allUsers();
*/
}
}
$userid = Request::getInt('userid', $id, 'POST');
if (Constants::DEFAULT_UID < $userid && $userid !== $id) {
$xUser = new \XoopsUser($userid);
if ($xUser && ($xUser instanceof \XoopsUser)) {
$id = $userid;
$username = $xUser->uname();
//$profile = $check->checkIfProfile($id);
$profile = $swUserHandler->checkIfProfile($id);
}
}
if (Constants::DEFAULT_UID >= $id || ('publicindex' === $page) && (Constants::HAS_ACCESS == $set['access'])) {
$wall = new Smallworld\PublicWallUpdates();
} else {
$wall = new Smallworld\WallUpdates();
}
if (Constants::DEFAULT_UID >= $id && Constants::HAS_ACCESS == $set['access']) {
$followers = $pub;
} elseif ($id > 0 && Constants::HAS_ACCESS == $set['access'] && 'publicindex' === $page) {
//$pub = $check->allUsers();
$followers = $pub;
} else {
$followers = smallworld_array_flatten($wall->getFollowers($id), 0);
}
$last = Request::getString('last', 'a', 'POST');
switch ($page) {
case ('index'):
$updatesArray = (Constants::DEFAULT_UID < $id) ? $wall->Updates($last, $id, $followers) : $wall->Updates($last, $followers);
break;
case ('profile'):
$updatesArray = (Constants::DEFAULT_UID < $id) ? $wall->Updates($last, $userid, $userid) : $wall->Updates($last, $userid);
break;
case ('publicindex'):
$updatesArray = $wall->Updates($last, $followers);
break;
}
$wall->parsePubArray($updatesArray, $id);
$GLOBALS['xoopsTpl']->assign([
'sCountResp' => count($updatesArray),
'msgtoshow' => $hm,
'myusername' => $username,
'pagename' => $page,
'isadminuser' => $tplAdmin
]);
$tplFileName = (Constants::DEFAULT_UID < $id) ? $helper->path('templates/getmore.tpl') : $helper->path('templates/getmorepublic.tpl');
$GLOBALS['xoopsTpl']->display($tplFileName);