Passed
Push — master ( 40d48e...d37b2b )
by Michael
33s queued 12s
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
if ('datatables1' == $xoopsModuleConfig['indextemplate'] || 'datatables2' == $xoopsModuleConfig['indextemplate']) {
28
	$xoTheme->addStylesheet(XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/assets/css/jquery.dataTables.css');
29
	$xoTheme->addScript(XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/assets/js/jquery.dataTables.js');
30
}
31
if ('datatables2' == $xoopsModuleConfig['indextemplate']) {
32
	$xoTheme->addStylesheet(XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/assets/css/dataTables.alphabetSearch.css');
33
	$xoTheme->addScript(XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/assets/js/dataTables.alphabetSearch.js');
34
}
35
36
/** @var \XoopsMemberHandler $memberHandler */
37
$memberHandler = xoops_getHandler('member');
38
$total         = $memberHandler->getUserCount(new \Criteria('level', 0, '>'));
39
40
$iamadmin = $xoopsUserIsAdmin;
41
$myts     = \MyTextSanitizer::getInstance();
42
$criteria = new \CriteriaCompo();
43
44
$criteria->add(new \Criteria('level', 0, '>'));
45
$validsort = ['uname', 'name', 'last_login', 'user_regdate', 'posts'];
46
//$sort      = (!in_array($helper->getModule()->getInfo('sortmembers'), $validsort)) ? 'uname' : $helper->getModule()->getInfo('sortmembers');
47
//temp solution
48
$sort = (!in_array($xoopsModuleConfig['sortmembers'], $validsort ) ) ? 'uname' : $xoopsModuleConfig['sortmembers'];
49
    
50
$order = 'ASC';
51
//$temp  = $helper->getModule()->getInfo('membersorder');
52
//temp solution
53
if ( isset($xoopsModuleConfig['membersorder']) && $xoopsModuleConfig['membersorder'] == 'DESC' ) {
54
//if (isset($temp) && 'DESC' == $temp) {
55
    $order = 'DESC';
56
}
57
58
if ('normal' == $xoopsModuleConfig['indextemplate']) {
59
//temp solution
60
$limit = (!empty($xoopsModuleConfig['membersperpage'])) ? intval($xoopsModuleConfig['membersperpage']) : 20;
61
//$limit = \Xmf\Request::getInt('limit', 20, 'POST');
62
if (0 == $limit || $limit > 50) {
63
    $limit = 50;
64
}
65
}
66
$start = \Xmf\Request::getInt('start', 0, 'POST');
67
$total = $memberHandler->getUserCount($criteria);
68
$xoopsTpl->assign('totalmember', $total);
69
70
//Show last member
71
$result = $GLOBALS['xoopsDB']->query('SELECT uid, uname FROM ' . $GLOBALS['xoopsDB']->prefix('users') . ' WHERE level > 0 ORDER BY uid DESC', 1, 0);
72
list($latestuid, $latestuser) = $GLOBALS['xoopsDB']->fetchRow($result);
73
$xoopsTpl->assign('latestmember', " <a href='" . XOOPS_URL . '/userinfo.php?uid=' . $latestuid . "'>" . $latestuser . '</a>');
74
$xoopsTpl->assign('welcomemessage', $xoopsModuleConfig['welcomemessage']);
75
76
if (0 == $total) {
77
} elseif ($start < $total) {
78
    if ($iamadmin) {
79
        $xoopsTpl->assign('is_admin', true);
80
    }
81
    $criteria->setSort($sort);
82
    $criteria->setOrder($order);
83
    $criteria->setStart($start);
84
    if ('normal' == $xoopsModuleConfig['indextemplate']) {
85
    $criteria->setLimit($limit); }
86
    $foundusers = $memberHandler->getUsers($criteria, true);
87
    foreach (array_keys($foundusers) as $j) {
88
        $userdata['avatar']   = $foundusers[$j]->getVar('user_avatar');
89
        $userdata['realname'] = $foundusers[$j]->getVar('name');
90
        $userdata['name']     = $foundusers[$j]->getVar('uname');
91
        $userdata['id']       = $foundusers[$j]->getVar('uid');
92
        if (1 == $foundusers[$j]->getVar('user_viewemail') || $iamadmin) {
93
            $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>';
94
        }
95
        if ($xoopsUser) {
96
            $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>';
97
        } 
98
        if ('' != $foundusers[$j]->getVar('url', 'e')) {
99
            $userdata['website'] = '<a href="' . $foundusers[$j]->getVar('url', 'e') . '" target="_blank"><img src="' . XOOPS_URL . '/images/icons/www.gif" border="0" alt="' . _VISITWEBSITE . '"></a>';
100
        }
101
        $userdata['registerdate'] = formatTimestamp($foundusers[$j]->getVar('user_regdate'), 's');
102
        if (0 != $foundusers[$j]->getVar('last_login')) {
103
            $userdata['lastlogin'] = formatTimestamp($foundusers[$j]->getVar('last_login'), 'm');
104
        } else {
105
            $userdata['lastlogin'] = _MD_XOOPSMEMBERS_NEVERLOGIN;
106
        }
107
        $userdata['posts'] = $foundusers[$j]->getVar('posts');
108
        if ($iamadmin) {
109
            $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 . "'>"
110
111
                                     . '</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>';
112
        }
113
		
114
		$userdata['location']       = $foundusers[$j]->getVar('user_from');
115
		$userdata['occupation']     = $foundusers[$j]->getVar('user_occ');
116
		$userdata['interest']       = $foundusers[$j]->getVar('user_intrest');
117
        $xoopsTpl->append('users', $userdata);
118
    }
119
  if ('normal' == $xoopsModuleConfig['indextemplate']) {
120
    $totalpages = ceil($total / $limit);
121
    if ($totalpages > 1) {
122
        $hiddenform = '<form name="findnext" action="index.php" method="post">';
123
        foreach ($_POST as $k => $v) {
124
            $hiddenform .= '<input type="hidden" name="' . $myts->htmlSpecialChars($k) . '" value="' . $myts->previewTarea($v) . '">';
125
        }
126
        if (!isset($_POST['limit'])) {
127
            $hiddenform .= '<input type="hidden" name="limit" value="' . $limit . '">';
128
        }
129
        if (!isset($_POST['start'])) {
130
            $hiddenform .= '<input type="hidden" name="start" value="' . $start . '">';
131
        }
132
        $prev = $start - $limit;
133
        if ($start - $limit >= 0) {
134
            $hiddenform .= '<a href="#0" onclick="javascript:document.findnext.start.value=' . $prev . ';document.findnext.submit();">' . _MD_XOOPSMEMBERS_PREVIOUS . '</a>&nbsp;';
135
        }
136
        $counter     = 1;
137
        $currentpage = ($start + $limit) / $limit;
138
        while ($counter <= $totalpages) {
139
            if ($counter == $currentpage) {
140
                $hiddenform .= '<b>' . $counter . '</b> ';
141
            } elseif (($counter > $currentpage - 4 && $counter < $currentpage + 4) || 1 == $counter || $counter == $totalpages) {
142
                if ($counter == $totalpages && $currentpage < $totalpages - 4) {
143
                    $hiddenform .= '... ';
144
                }
145
                $hiddenform .= '<a href="#' . $counter . '" onclick="javascript:document.findnext.start.value=' . ($counter - 1) * $limit . ';document.findnext.submit();">' . $counter . '</a> ';
146
                if (1 == $counter && $currentpage > 5) {
147
                    $hiddenform .= '... ';
148
                }
149
            }
150
            $counter++;
151
        }
152
        $next = $start + $limit;
153
        if ($total > $next) {
154
            $hiddenform .= '&nbsp;<a href="#' . $total . '" onclick="javascript:document.findnext.start.value=' . $next . ';document.findnext.submit();">' . _MD_XOOPSMEMBERS_NEXT . '</a>';
155
        }
156
        $hiddenform .= '</form>';
157
        $xoopsTpl->assign('pagenav', $hiddenform);
158
        $xoopsTpl->assign('lang_numfound', sprintf(_MD_XOOPSMEMBERS_USERSFOUND, $total));
159
    }
160
  }
161
}
162
163
require __DIR__ . '/footer.php';
164
require_once XOOPS_ROOT_PATH . '/footer.php';
165
exit();
166
167
/**
168
 * xoops_Criteria()
169
 *
170
 * @param \CriteriaCompo       $criteria
171
 * @param string $name
172
 * @param string $ret
173
 * @param string $match
174
 * @return void
175
 */
176
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

176
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...
177
{
178
    global $criteria;
179
180
    switch ($match) {
181
        case XOOPS_MATCH_START:
182
            $criteria->add(new \Criteria($name, $ret . '%', 'LIKE'));
183
            break;
184
        case XOOPS_MATCH_END:
185
            $criteria->add(new \Criteria($name, '%' . $ret . '%', 'LIKE'));
186
            break;
187
        case XOOPS_MATCH_EQUAL:
188
            $criteria->add(new \Criteria($name, $ret));
189
            break;
190
        case XOOPS_MATCH_CONTAIN:
191
            $criteria->add(new \Criteria($name, '%' . $ret . '%', 'LIKE'));
192
            break;
193
    }
194
}
195