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