Passed
Push — master ( 39c203...ca1205 )
by Michael
02:01
created

index.php (1 issue)

Labels
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
//global $pathIcon16;
24
25
global $xoopsModule;
26
27
$pathIcon16    = \Xmf\Module\Admin::iconUrl('', 16);
28
29
30
	
31
$memberHandler = xoops_getHandler('member');
32
    $total = $memberHandler->getUserCount( new Criteria( 'level', 0, '>' ) );
0 ignored issues
show
The method getUserCount() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler. ( Ignorable by Annotation )

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

32
    $total = $memberHandler->/** @scrutinizer ignore-call */ getUserCount( new Criteria( 'level', 0, '>' ) );
Loading history...
33
34
    $iamadmin = $xoopsUserIsAdmin;
35
$myts     = \MyTextSanitizer::getInstance();
36
$criteria = new \CriteriaCompo();
37
38
$criteria->add(new \Criteria('level', 0, '>'));
39
$validsort = ['uname', 'name', 'last_login', 'user_regdate', 'posts'];
40
$sort      = (!in_array($helper->getModule()->getInfo('sortmembers'), $validsort)) ? 'uname' : $helper->getModule()->getInfo('sortmembers');
41
    
42
	$order = 'ASC';
43
$temp  = $helper->getModule()->getInfo('membersorder');
44
if (isset($temp) && 'DESC' == $temp) {
45
        $order = 'DESC';
46
    }
47
    $limit = \Xmf\Request::getInt('limit', 20, 'POST');
48
if (0 == $limit || $limit > 50) {
49
        $limit = 50;
50
    }
51
52
    $start         = \Xmf\Request::getInt('start', 0, 'POST');
53
    $memberHandler = xoops_getHandler('member');
54
    $total         = $memberHandler->getUserCount($criteria);
55
	$xoopsTpl->assign( 'totalmember', $total );
56
57
if (0 == $total) {
58
    } elseif ( $start < $total ) {
59
        if ( $iamadmin ) {
60
            $xoopsTpl->assign( 'is_admin', true );
61
        }
62
        $criteria->setSort( $sort );
63
        $criteria->setOrder( $order );
64
        $criteria->setStart( $start );
65
        $criteria->setLimit( $limit );
66
        $foundusers = $memberHandler->getUsers($criteria, true);
67
        foreach ( array_keys( $foundusers ) as $j ) {
68
            $userdata['avatar']   = $foundusers[$j]->getVar('user_avatar') ? '<img src="' . XOOPS_UPLOAD_URL . '/' . $foundusers[$j]->getVar('user_avatar') . '" alt="">' : '&nbsp;';
69
        $userdata['realname'] = $foundusers[$j]->getVar('name') ?: '&nbsp;';
70
        $userdata['name']     = $foundusers[$j]->getVar('uname');
71
        $userdata['id']       = $foundusers[$j]->getVar('uid');
72
        if (1 == $foundusers[$j]->getVar('user_viewemail') || $iamadmin) {
73
                $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>';
74
            } else {
75
            $userdata['email'] = '&nbsp;';
76
            }
77
            if ( $xoopsUser ) {
78
            $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>';
79
            } else {
80
            $userdata['pmlink'] = '&nbsp;';
81
            }
82
        if ('' != $foundusers[$j]->getVar('url', 'e')) {
83
                $userdata['website'] = '<a href="' . $foundusers[$j]->getVar('url', 'e') . '" target="_blank"><img src="' . XOOPS_URL . '/images/icons/www.gif" border="0" alt="' . _VISITWEBSITE . '"></a>';
84
            } else {
85
            $userdata['website'] = '&nbsp;';
86
            }
87
        $userdata['registerdate'] = formatTimestamp($foundusers[$j]->getVar('user_regdate'), 's');
88
        if (0 != $foundusers[$j]->getVar('last_login')) {
89
            $userdata['lastlogin'] = formatTimestamp($foundusers[$j]->getVar('last_login'), 'm');
90
            } else {
91
            $userdata['lastlogin'] = '&nbsp;';
92
            }
93
        $userdata['posts'] = $foundusers[$j]->getVar('posts');
94
            if ( $iamadmin ) {
95
                $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 . "'>"
96
97
                                         . '</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>';
98
            }
99
        $xoopsTpl->append('users', $userdata);
100
        }
101
102
        $totalpages = ceil( $total / $limit );
103
        if ( $totalpages > 1 ) {
104
            $hiddenform = '<form name="findnext" action="index.php" method="post">';
105
            foreach ( $_POST as $k => $v ) {
106
                $hiddenform .= '<input type="hidden" name="' . $myts->htmlSpecialChars($k) . '" value="' . $myts->previewTarea($v) . '">';
107
            }
108
            if ( !isset( $_POST['limit'] ) ) {
109
                $hiddenform .= '<input type="hidden" name="limit" value="' . $limit . '">';
110
            }
111
            if ( !isset( $_POST['start'] ) ) {
112
                $hiddenform .= '<input type="hidden" name="start" value="' . $start . '">';
113
            }
114
            $prev = $start - $limit;
115
            if ( $start - $limit >= 0 ) {
116
            $hiddenform .= '<a href="#0" onclick="javascript:document.findnext.start.value=' . $prev . ';document.findnext.submit();">' . _MD_XOOPSMEMBERS_PREVIOUS . '</a>&nbsp;';
117
            }
118
            $counter = 1;
119
            $currentpage = ( $start + $limit ) / $limit;
120
            while ( $counter <= $totalpages ) {
121
                if ( $counter == $currentpage ) {
122
                    $hiddenform .= '<b>' . $counter . '</b> ';
123
            } elseif (($counter > $currentpage - 4 && $counter < $currentpage + 4) || 1 == $counter || $counter == $totalpages) {
124
                    if ( $counter == $totalpages && $currentpage < $totalpages-4 ) {
125
                        $hiddenform .= '... ';
126
                    }
127
                    $hiddenform .= '<a href="#' . $counter . '" onclick="javascript:document.findnext.start.value=' . ( $counter-1 ) * $limit . ';document.findnext.submit();">' . $counter . '</a> ';
128
                if (1 == $counter && $currentpage > 5) {
129
                        $hiddenform .= '... ';
130
                    }
131
                }
132
                $counter++;
133
            }
134
            $next = $start + $limit;
135
            if ( $total > $next ) {
136
            $hiddenform .= '&nbsp;<a href="#' . $total . '" onclick="javascript:document.findnext.start.value=' . $next . ';document.findnext.submit();">' . _MD_XOOPSMEMBERS_NEXT . '</a>';
137
            }
138
            $hiddenform .= '</form>';
139
            $xoopsTpl->assign( 'pagenav', $hiddenform );
140
        $xoopsTpl->assign('lang_numfound', sprintf(_MD_XOOPSMEMBERS_USERSFOUND, $total));
141
        }
142
    }
143
144
include 'footer.php';
145
include_once XOOPS_ROOT_PATH . '/footer.php';
146
exit();
147
148
/**
149
 * xoops_Criteria()
150
 *
151
 * @param        $criteria
152
 * @param string $name
153
 * @param string $ret
154
 * @param string $match
155
 * @return void
156
 */
157
function xoops_Criteria(&$criteria, $name = '', $ret = '', $match = '')
158
{
159
    global $criteria;
160
161
    switch ( $match ) {
162
        case XOOPS_MATCH_START:
163
            $criteria->add(new \Criteria($name, $ret . '%', 'LIKE'));
164
            break;
165
        case XOOPS_MATCH_END:
166
            $criteria->add(new \Criteria($name, '%' . $ret . '%', 'LIKE'));
167
            break;
168
        case XOOPS_MATCH_EQUAL:
169
            $criteria->add(new \Criteria($name, $ret));
170
            break;
171
        case XOOPS_MATCH_CONTAIN:
172
            $criteria->add(new \Criteria($name, '%' . $ret . '%', 'LIKE'));
173
            break;
174
    }
175
}
176