Passed
Push — master ( 69391f...d59484 )
by Michael
01:59
created
Severity
1
<?php
2
3
/**
4
 * Xoops Members Module
5
 *
6
 * You may not change or alter any portion of this comment or credits
7
 * of supporting developers from this source code or any supporting source code
8
 * which is considered copyrighted (c) material of the original comment or credit authors.
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
 * @copyright XOOPS Project (https://xoops.org)
14
 * @license   http://www.fsf.org/copyleft/gpl.html GNU public license
15
 * @package   Xoops Members
16
 * @since     2.3.0
17
 * @author    onokazu
18
 * @author    John Neill
19
 */
20
21
$xoopsOption['template_main'] = 'xoopsmembers_index.tpl'; 
22
require_once __DIR__ . '/header.php';
23
 
24
//global $pathIcon16;
25
26
global $xoopsModule;
27
28
if ('datatables1' == $xoopsModuleConfig['indextemplate'] || 'datatables2' == $xoopsModuleConfig['indextemplate'] || 'datatables3' == $xoopsModuleConfig['indextemplate']) {
29
	$xoTheme->addStylesheet(XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/assets/css/jquery.dataTables.css');
30
	$xoTheme->addStylesheet(XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/assets/css/responsive.dataTables.min.css');
31
	$xoTheme->addScript(XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/assets/js/jquery.dataTables.js');
32
	$xoTheme->addScript(XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/assets/js/dataTables.responsive.min.js');
33
}
34
if ('datatables3' == $xoopsModuleConfig['indextemplate']) {
35
	$xoTheme->addStylesheet(XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/assets/css/dataTables.alphabetSearch.css');
36
	$xoTheme->addScript(XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/assets/js/dataTables.alphabetSearch.js');
37
		$xoTheme->addStylesheet(XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/assets/css/jquery.dataTables.css');
38
	$xoTheme->addStylesheet(XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/assets/css/responsive.dataTables.min.css');
39
	$xoTheme->addScript(XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/assets/js/jquery.dataTables.js');
40
	$xoTheme->addScript(XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/assets/js/dataTables.responsive.min.js');
41
}
42
43
/** @var \XoopsMemberHandler $memberHandler */
44
$memberHandler = xoops_getHandler('member');
45
$total         = $memberHandler->getUserCount(new \Criteria('level', 0, '>'));
46
47
$iamadmin = $xoopsUserIsAdmin;
48
$myts     = \MyTextSanitizer::getInstance();
49
$criteria = new \CriteriaCompo();
50
51
$criteria->add(new \Criteria('level', 0, '>'));
52
$validsort = ['uname', 'name', 'last_login', 'user_regdate', 'posts'];
53
//$sort      = (!in_array($helper->getModule()->getInfo('sortmembers'), $validsort)) ? 'uname' : $helper->getModule()->getInfo('sortmembers');
54
//temp solution
55
$sort = (!in_array($xoopsModuleConfig['sortmembers'], $validsort ) ) ? 'uname' : $xoopsModuleConfig['sortmembers'];
56
    
57
$order = 'ASC';
58
//$temp  = $helper->getModule()->getInfo('membersorder');
59
//temp solution
60
if ( isset($xoopsModuleConfig['membersorder']) && $xoopsModuleConfig['membersorder'] == 'DESC' ) {
61
//if (isset($temp) && 'DESC' == $temp) {
62
    $order = 'DESC';
63
}
64
65
if ('normal' == $xoopsModuleConfig['indextemplate']) {
66
//temp solution
67
$limit = (!empty($xoopsModuleConfig['membersperpage'])) ? intval($xoopsModuleConfig['membersperpage']) : 20;
68
//$limit = \Xmf\Request::getInt('limit', 20, 'POST');
69
if (0 == $limit || $limit > 50) {
70
    $limit = 50;
71
}
72
}
73
$start = \Xmf\Request::getInt('start', 0, 'POST');
74
$total = $memberHandler->getUserCount($criteria);
75
$xoopsTpl->assign('totalmember', $total);
76
77
//Show last member
78
$result = $GLOBALS['xoopsDB']->query('SELECT uid, uname FROM ' . $GLOBALS['xoopsDB']->prefix('users') . ' WHERE level > 0 ORDER BY uid DESC', 1, 0);
79
list($latestuid, $latestuser) = $GLOBALS['xoopsDB']->fetchRow($result);
80
$xoopsTpl->assign('latestmember', " <a href='" . XOOPS_URL . '/userinfo.php?uid=' . $latestuid . "'>" . $latestuser . '</a>');
81
$xoopsTpl->assign('welcomemessage', $xoopsModuleConfig['welcomemessage']);
82
83
if (0 == $total) {
84
} elseif ($start < $total) {
85
    if ($iamadmin) {
86
        $xoopsTpl->assign('is_admin', true);
87
    }
88
    $criteria->setSort($sort);
89
    $criteria->setOrder($order);
90
    $criteria->setStart($start);
91
    if ('normal' == $xoopsModuleConfig['indextemplate']) {
92
    $criteria->setLimit($limit); }
93
    $foundusers = $memberHandler->getUsers($criteria, true);
94
    foreach (array_keys($foundusers) as $j) {
95
        $userdata['avatar']   = $foundusers[$j]->getVar('user_avatar');
96
        $userdata['realname'] = $foundusers[$j]->getVar('name');
97
        $userdata['name']     = $foundusers[$j]->getVar('uname');
98
        $userdata['id']       = $foundusers[$j]->getVar('uid');
99
        if (1 == $foundusers[$j]->getVar('user_viewemail') || $iamadmin) {
100
            $userdata['email'] = '<a href="mailto:' . $foundusers[$j]->getVar('email') . '"><img src="' . XOOPS_URL . '/images/icons/email.gif" border="0" alt="' . sprintf(_SENDEMAILTO, $foundusers[$j]->getVar('uname', 'e')) . '"></a>';
101
			$userdata['emailaddress'] = $foundusers[$j]->getVar('email');
102
		}
103
        if ($xoopsUser) {
104
			$userdata['pmlink'] = '<a href="javascript:openWithSelfMain(\'' . XOOPS_URL . '/pmlite.php?send2=1&amp;to_userid=' . $foundusers[$j]->getVar('uid') . '\',\'pmlite\',450,370);"><img src="' . XOOPS_URL . '/images/icons/pm.gif" border="0" alt="' . sprintf(_SENDPMTO, $foundusers[$j]->getVar('uname', 'e')) . '"></a>';
105
			$userdata['pm'] = $foundusers[$j]->getVar('uid');
106
		} 
107
        if ('' != $foundusers[$j]->getVar('url', 'e')) {
108
            $userdata['website'] = '<a href="' . $foundusers[$j]->getVar('url', 'e') . '" target="_blank"><img src="' . XOOPS_URL . '/images/icons/www.gif" border="0" alt="' . _VISITWEBSITE . '"></a>';
109
		}
110
		$userdata['url'] = $foundusers[$j]->getVar('url', 'e');
111
		$userdata['registerdate'] = formatTimestamp($foundusers[$j]->getVar('user_regdate'), 's');
112
        if (0 != $foundusers[$j]->getVar('last_login')) {
113
            $userdata['lastlogin'] = formatTimestamp($foundusers[$j]->getVar('last_login'), 'm');
114
        } else {
115
            $userdata['lastlogin'] = _MD_XOOPSMEMBERS_NEVERLOGIN;
116
        }
117
        $userdata['posts'] = $foundusers[$j]->getVar('posts');
118
        if ($iamadmin) {
119
            $userdata['adminlink'] = '<a href="' . XOOPS_URL . '/modules/system/admin.php?fct=users&amp;uid=' . $foundusers[$j]->getVar('uid') . '&amp;op=users_edit">' . '<img src=' . $pathIcon16 . '/edit.png' . " alt='" . _EDIT . "' title='" . _EDIT . "'>"
120
121
                                     . '</a> <a href="' . XOOPS_URL . '/modules/system/admin.php?fct=users&amp;op=users_delete&amp;uid=' . $foundusers[$j]->getVar('uid') . '">' . '<img src=' . $pathIcon16 . '/delete.png' . " alt='" . _DELETE . "' title='" . _DELETE . "'>" . '</a>';
122
        }
123
		
124
		$userdata['location']       = $foundusers[$j]->getVar('user_from');
125
		$userdata['occupation']     = $foundusers[$j]->getVar('user_occ');
126
		$userdata['interest']       = $foundusers[$j]->getVar('user_intrest');
127
		$userdata['extrainfo']      = $foundusers[$j]->getVar('bio');
128
		$userdata['signature']      = $foundusers[$j]->getVar('user_sig');
129
		$userdata['onlinestatus']   = $foundusers[$j]->isOnline();
130
        $userrank = $foundusers[$j]->rank();
131
        if ($userrank['image']) {
132
           $userdata['rankimage']='<img src="' . XOOPS_UPLOAD_URL . '/' . $userrank['image'] . '" alt="">';
133
        }
134
           $userdata['ranktitle']=$userrank['title'];
135
		
136
		$uid=$userdata['id'];
137
        $groups =$member_handler->getGroupsByUser($uid, true); 
138
		$usergroups = array(); 
139
		foreach ($groups as $group) { 
140
		$usergroups[] = $group->getVar('name'); 
141
		}  		
142
		$userdata['groups']= implode(', ', $usergroups);
143
144
        $xoopsTpl->append('users', $userdata);
145
    }
146
  if ('normal' == $xoopsModuleConfig['indextemplate']) {
147
    $totalpages = ceil($total / $limit);
148
    if ($totalpages > 1) {
149
        $hiddenform = '<form name="findnext" action="index.php" method="post">';
150
        foreach ($_POST as $k => $v) {
151
            $hiddenform .= '<input type="hidden" name="' . $myts->htmlSpecialChars($k) . '" value="' . $myts->previewTarea($v) . '">';
152
        }
153
        if (!isset($_POST['limit'])) {
154
            $hiddenform .= '<input type="hidden" name="limit" value="' . $limit . '">';
155
        }
156
        if (!isset($_POST['start'])) {
157
            $hiddenform .= '<input type="hidden" name="start" value="' . $start . '">';
158
        }
159
        $prev = $start - $limit;
160
        if ($start - $limit >= 0) {
161
            $hiddenform .= '<a href="#0" onclick="javascript:document.findnext.start.value=' . $prev . ';document.findnext.submit();">' . _MD_XOOPSMEMBERS_PREVIOUS . '</a>&nbsp;';
162
        }
163
        $counter     = 1;
164
        $currentpage = ($start + $limit) / $limit;
165
        while ($counter <= $totalpages) {
166
            if ($counter == $currentpage) {
167
                $hiddenform .= '<b>' . $counter . '</b> ';
168
            } elseif (($counter > $currentpage - 4 && $counter < $currentpage + 4) || 1 == $counter || $counter == $totalpages) {
169
                if ($counter == $totalpages && $currentpage < $totalpages - 4) {
170
                    $hiddenform .= '... ';
171
                }
172
                $hiddenform .= '<a href="#' . $counter . '" onclick="javascript:document.findnext.start.value=' . ($counter - 1) * $limit . ';document.findnext.submit();">' . $counter . '</a> ';
173
                if (1 == $counter && $currentpage > 5) {
174
                    $hiddenform .= '... ';
175
                }
176
            }
177
            $counter++;
178
        }
179
        $next = $start + $limit;
180
        if ($total > $next) {
181
            $hiddenform .= '&nbsp;<a href="#' . $total . '" onclick="javascript:document.findnext.start.value=' . $next . ';document.findnext.submit();">' . _MD_XOOPSMEMBERS_NEXT . '</a>';
182
        }
183
        $hiddenform .= '</form>';
184
        $xoopsTpl->assign('pagenav', $hiddenform);
185
        $xoopsTpl->assign('lang_numfound', sprintf(_MD_XOOPSMEMBERS_USERSFOUND, $total));
186
    }
187
  }
188
}
189
190
require __DIR__ . '/footer.php';
191
require_once XOOPS_ROOT_PATH . '/footer.php';
192
exit();
193
194
/**
195
 * xoops_Criteria()
196
 *
197
 * @param \CriteriaCompo       $criteria
198
 * @param string $name
199
 * @param string $ret
200
 * @param string $match
201
 * @return void
202
 */
203
function xoops_Criteria(&$criteria, $name = '', $ret = '', $match = '')
0 ignored issues
show
The parameter $criteria is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

203
function xoops_Criteria(/** @scrutinizer ignore-unused */ &$criteria, $name = '', $ret = '', $match = '')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
204
{
205
    global $criteria;
206
207
    switch ($match) {
208
        case XOOPS_MATCH_START:
209
            $criteria->add(new \Criteria($name, $ret . '%', 'LIKE'));
210
            break;
211
        case XOOPS_MATCH_END:
212
            $criteria->add(new \Criteria($name, '%' . $ret . '%', 'LIKE'));
213
            break;
214
        case XOOPS_MATCH_EQUAL:
215
            $criteria->add(new \Criteria($name, $ret));
216
            break;
217
        case XOOPS_MATCH_CONTAIN:
218
            $criteria->add(new \Criteria($name, '%' . $ret . '%', 'LIKE'));
219
            break;
220
    }
221
}
222