XOOPS RMCommon Utilities  2.1.8.91RC
 All Classes Namespaces Files Functions Variables
users.php
Go to the documentation of this file.
1 <?php
2 // $Id: users.php 902 2012-01-03 07:09:16Z i.bitcero $
3 // --------------------------------------------------------------
4 // EXM System
5 // Content Management System
6 // Author: BitC3R0 <bitc3r0@gmail.com>
7 // Email: bitc3r0@gmail.com
8 // License: GPL 2.0
9 // --------------------------------------------------------------
10 
11 include '../../../mainfile.php';
12 include_once XOOPS_ROOT_PATH.'/modules/rmcommon/loader.php';
13 
14 // Deactivate the logger
15 error_reporting(0);
16 $xoopsLogger->activated = false;
17 
18 // Check Security settings
19 if (!$xoopsSecurity->check()){
20  _e('Sorry, you are not allowed to view this page','rmcommon');
21  die();
22 }
23 
24 $token = $xoopsSecurity->createToken();
25 
26 $tpl = new RMTemplate();
27 $db = XoopsDatabaseFactory::getDatabaseConnection();
28 
29 $type = 0;
30 $s = '';
31 $kw = '';
32 $ord = 2;
33 $all = false;
34 
35 foreach($_REQUEST as $k => $v){
36  $$k = $v;
37 }
38 
39 if (!isset($field) || $field==''){
40  _e('Sorry, you are not allowed to view this page','rmcommon');
41  die();
42 }
43 
44 $field = addslashes($field);
45 $kw = addSlashes($kw);
46 
47 if (is_string($s) && $s!=''){
48  $selected = explode(',',$s);
49 } elseif (is_array($s)) {
50  $selected = $s;
51 } else {
52  $selected = array();
53 }
54 
55 $selected_string = implode(',',$selected);
56 
57 $sql = "SELECT COUNT(*) FROM ".$db->prefix("users")." WHERE level>0";
58 if ($kw!=''){
59  $sql .= " AND (uname LIKE '%$kw%' OR name LIKE '%$kw%')";
60 }
61 
62 list($num) = $db->fetchRow($db->query($sql));
63 
64 $page = isset($pag) ? $pag : 1;
65 $limit = isset($limit) && $limit>0 ? $limit : 36;
66 
67 $tpages = ceil($num / $limit);
69 if($num % $limit > 0) $tpages++;
70 
71 $start = $num<=0 ? 0 : ($page - 1) * $limit;
72 
73 $nav = new RMPageNav($num, $limit, $page, 4);
74 $nav->target_url('javascript:usersField.goto_page({PAGE_NUM}, '.$type.');');
75 
76 $sql = str_replace('COUNT(*)','uid, uname', $sql);
77 switch($ord){
78  case '0':
79  $sql .= " ORDER BY user_regdate";
80  break;
81  case '1':
82  $sql .= " ORDER BY uname";
83  break;
84  default:
85  $sql .= " ORDER BY uid";
86  break;
87 }
88 $sql .= " LIMIT $start,$limit";
89 //$sql = "SELECT uid, uname FROM ".$db->prefix("users")." WHERE level>0 LIMIT $start,$limit";
90 $result = $db->query($sql);
91 
92 $users = array();
93 if ($all){
94  $users[] = array('id'=>0,'name'=>__('All','rmcommon'),'check'=>in_array(0, $selected));
95 }
96 
97 while ($row = $db->fetchArray($result)){
98  $users[] = array('id'=>$row['uid'],'name'=>$row['uname'],'check'=>in_array($row['uid'], $selected));
99 }
100 
101 $selecteds = array();
102 if (is_array($selected) && count($selected)>0){
103  $sql = "SELECT uid,uname FROM ".$db->prefix("users")." WHERE level>0 AND uid IN (".implode(',',$selected).")";
104  $result = $db->query($sql);
105  while ($row = $db->fetchArray($result)){
106  $selecteds[] = array('id'=>$row['uid'],'name'=>$row['uname'],'check'=>true);
107  }
108 
109 }
110 
111 $field_type = $type ? 'checkbox' : 'radio';
112 
113 $nav->render(false);
114 
115 include RMTemplate::get()->get_template("form_users.php", 'module','rmcommon');