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