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

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