/** * bXpress Forums * A light weight and easy to use XOOPS module to create forums * * Copyright © 2014 Eduardo Cortés https://eduardocortes.mx * ----------------------------------------------------------------- * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ----------------------------------------------------------------- * @package bXpress * @author Eduardo Cortés <*****@*****.**> * @since 1.2 * @license GPL v2 (http://www.gnu.org/licenses/gpl-2.0.html) * @link https://github.com/bitcero/bxpress */ function bxpress_block_users_show($options) { // Add css styles RMTemplate::get()->add_style('bxpress-blocks.min.css', 'bxpress'); $db = XoopsDatabaseFactory::getDatabaseConnection(); $tbu = $db->prefix("users"); $tbp = $db->prefix("mod_bxpress_posts"); $tbl = $db->prefix("mod_bxpress_likes"); if ('active' == $options['type']) { $sql = "SELECT DISTINCT posts.uid, users.uid, users.uname, users.email, users.name,\n (SELECT COUNT(*) FROM {$tbp} WHERE uid = posts.uid) as total,\n (SELECT SUM(likes) FROM {$tbp} WHERE uid = posts.uid ) as likes\n FROM {$tbu} as users, {$tbp} as posts WHERE users.uid = posts.uid ORDER BY total DESC LIMIT 0, {$options['limit']}"; } $result = $db->query($sql); $users = array(); $user = new RMUser(); while ($row = $db->fetchArray($result)) { $user->assignVars($row); $users[] = array('id' => $user->id(), 'name' => '' != $user->name ? $user->name : $user->uname, 'uname' => $user->uname, 'avatar' => RMEvents::get()->run_event("rmcommon.get.avatar", $user->email, 0), 'posts' => $row['total'], 'likes' => $row['likes']); } $block['users'] = $users; return $block; }
/** * Shows all registered users in a list with filter and manage options */ function show_users() { global $xoopsSecurity, $rmTpl; define('RMCSUBLOCATION', 'allusers'); RMTemplate::get()->add_style('users.css', 'rmcommon'); RMTemplate::get()->add_style('js-widgets.css'); //Scripts RMTemplate::get()->add_script('users.js', 'rmcommon', array('directory' => 'include')); RMTemplate::get()->add_script('jquery.checkboxes.js', 'rmcommon', array('directory' => 'include')); RMTemplate::get()->add_head('<script type="text/javascript">var rmcu_select_message = "' . __('You have not selected any user!', 'rmcommon') . '"; var rmcu_message = "' . __('Dou you really wish to delete selected users?', 'rmcommon') . '";</script>'); $form = new RMForm('', '', ''); // Date Field $login1 = new RMFormDate('', 'login1', ''); $login1->addClass('form-control'); $login2 = new RMFormDate('', 'login2', ''); $login2->addClass('form-control'); // Registered Field $register1 = new RMFormDate('', 'registered1', ''); $register1->addClass('form-control'); $register2 = new RMFormDate('', 'registered2', ''); $register2->addClass('form-control'); RMBreadCrumb::get()->add_crumb(__('Users Management', 'rmcommon')); $rmTpl->assign('xoops_pagetitle', __('Users Management', 'rmcommon')); RMFunctions::create_toolbar(); // Show the theme xoops_cp_header(); $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT COUNT(*) FROM " . $db->prefix("users") . " " . formatSQL(); $page = rmc_server_var($_REQUEST, 'pag', 1); $limit = rmc_server_var($_REQUEST, 'limit', 15); $order = rmc_server_var($_GET, 'order', 'uid'); list($num) = $db->fetchRow($db->query($sql)); $tpages = ceil($num / $limit); $page = $page > $tpages ? $tpages : $page; $start = $num <= 0 ? 0 : ($page - 1) * $limit; $nav = new RMPageNav($num, $limit, $page, 5); $nav->target_url('users.php?limit=' . $limit . '&order=' . $order . '&pag={PAGE_NUM}'); $sql = str_replace("COUNT(*)", '*', $sql); $sql .= "ORDER BY {$order} LIMIT {$start}, {$limit}"; $result = $db->query($sql); $users = array(); $t = array(); // Temporary while ($row = $db->fetchArray($result)) { $user = new RMUser(); $user->assignVars($row); $t = $user->getValues(); $t['groups'] = $user->getGroups(); $t = RMEvents::get()->run_event('rmcommon.loading.users.list', $t); $users[] = $t; $t = array(); } $xgh = new XoopsGroupHandler($db); $users = RMEvents::get()->run_event('rmcommon.users.list.loaded', $users); // Users template include RMTemplate::get()->get_template('rmc-users.php', 'module', 'rmcommon'); xoops_cp_footer(); }