source: temp/test-xoops.ec-cube.net/html/modules/system/admin/users/users.php @ 405

Revision 405, 10.3 KB checked in by root, 20 years ago (diff)
Line 
1<?php
2// $Id: users.php,v 1.4 2005/08/03 12:40:00 onokazu Exp $
3//  ------------------------------------------------------------------------ //
4//                XOOPS - PHP Content Management System                      //
5//                    Copyright (c) 2000 XOOPS.org                           //
6//                       <http://www.xoops.org/>                             //
7//  ------------------------------------------------------------------------ //
8//  This program is free software; you can redistribute it and/or modify     //
9//  it under the terms of the GNU General Public License as published by     //
10//  the Free Software Foundation; either version 2 of the License, or        //
11//  (at your option) any later version.                                      //
12//                                                                           //
13//  You may not change or alter any portion of this comment or credits       //
14//  of supporting developers from this source code or any supporting         //
15//  source code which is considered copyrighted (c) material of the          //
16//  original comment or credit authors.                                      //
17//                                                                           //
18//  This program is distributed in the hope that it will be useful,          //
19//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
20//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
21//  GNU General Public License for more details.                             //
22//                                                                           //
23//  You should have received a copy of the GNU General Public License        //
24//  along with this program; if not, write to the Free Software              //
25//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
26//  ------------------------------------------------------------------------ //
27// Author: Kazumi Ono (AKA onokazu)                                          //
28// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ //
29// Project: The XOOPS Project                                                //
30// ------------------------------------------------------------------------- //
31
32if ( !is_object($xoopsUser) || !is_object($xoopsModule) || !$xoopsUser->isAdmin($xoopsModule->mid()) ) {
33    exit("Access Denied");
34}
35/*********************************************************/
36/* Users Functions                                       */
37/*********************************************************/
38include_once XOOPS_ROOT_PATH."/class/xoopslists.php";
39include_once XOOPS_ROOT_PATH."/class/xoopsformloader.php";
40
41/**
42 * @brief display error message & exit (Tentative)
43 */
44function system_users_error($message)
45{
46    xoops_cp_header();
47    xoops_error($message);
48    xoops_cp_footer();
49    exit();
50}
51
52function displayUsers()
53{
54    global $xoopsDB, $xoopsConfig, $xoopsModule;
55    $userstart = isset($_GET['userstart']) ? intval($_GET['userstart']) : 0;
56    xoops_cp_header();
57    $member_handler =& xoops_gethandler('member');
58    $usercount = $member_handler->getUserCount();
59    $nav = new XoopsPageNav($usercount, 200, $userstart, "userstart", "fct=users");
60    $editform = new XoopsThemeForm(_AM_EDEUSER, "edituser", "admin.php", 'GET');
61    $user_select = new XoopsFormSelect('', "uid");
62    $criteria = new CriteriaCompo();
63    $criteria->setSort('uname');
64    $criteria->setOrder('ASC');
65    $criteria->setLimit(200);
66    $criteria->setStart($userstart);
67    $user_select->addOptionArray($member_handler->getUserList($criteria));
68    $user_select_tray = new XoopsFormElementTray(_AM_NICKNAME, "<br />");
69    $user_select_tray->addElement($user_select);
70    $user_select_nav = new XoopsFormLabel('', $nav->renderNav(4));
71    $user_select_tray->addElement($user_select_nav);
72    $op_select = new XoopsFormSelect("", "op");
73    $op_select->addOptionArray(array("modifyUser"=>_AM_MODIFYUSER, "delUser"=>_AM_DELUSER));
74    $submit_button = new XoopsFormButton("", "submit", _AM_GO, "submit");
75    $fct_hidden = new XoopsFormHidden("fct", "users");
76    $editform->addElement($user_select_tray);
77    $editform->addElement($op_select);
78    $editform->addElement($submit_button);
79    $editform->addElement($fct_hidden);
80    $editform->display();
81
82    echo "<br />\n";
83    $uid_value = "";
84    $uname_value = "";
85    $name_value = "";
86    $email_value = "";
87    $email_cbox_value = 0;
88    $url_value = "";
89//  $avatar_value = "blank.gif";
90//  $theme_value = $xoopsConfig['default_theme'];
91    $timezone_value = $xoopsConfig['default_TZ'];
92    $icq_value = "";
93    $aim_value = "";
94    $yim_value = "";
95    $msnm_value = "";
96    $location_value = "";
97    $occ_value = "";
98    $interest_value = "";
99    $sig_value = "";
100    $sig_cbox_value = 0;
101    $umode_value = $xoopsConfig['com_mode'];
102    $uorder_value = $xoopsConfig['com_order'];
103    // RMV-NOTIFY
104    include_once XOOPS_ROOT_PATH . '/include/notification_constants.php';
105    $notify_method_value = XOOPS_NOTIFICATION_METHOD_PM;
106    $notify_mode_value = XOOPS_NOTIFICATION_MODE_SENDALWAYS;
107    $bio_value = "";
108    $rank_value = 0;
109    $mailok_value = 0;
110    $op_value = "addUser";
111    $form_title = _AM_ADDUSER;
112    $form_isedit = false;
113    $groups = array(XOOPS_GROUP_USERS);
114    include XOOPS_ROOT_PATH."/modules/system/admin/users/userform.php";
115        xoops_cp_footer();
116}
117
118function modifyUser($user)
119{
120    global $xoopsDB, $xoopsConfig, $xoopsModule;
121    xoops_cp_header();
122    $member_handler =& xoops_gethandler('member');
123    $user =& $member_handler->getUser($user);
124    if (is_object($user)) {
125        if (!$user->isActive()) {
126            xoops_token_confirm(array('fct' => 'users', 'op' => 'reactivate', 'uid' => $user->getVar('uid')), 'admin.php', _AM_NOTACTIVE);
127            xoops_cp_footer();
128            exit();
129        }
130        $uid_value = $user->getVar("uid");
131        $uname_value = $user->getVar("uname", "E");
132        $name_value = $user->getVar("name", "E");
133        $email_value = $user->getVar("email", "E");
134        $email_cbox_value = $user->getVar("user_viewemail") ? 1 : 0;
135        $url_value = $user->getVar("url", "E");
136//      $avatar_value = $user->getVar("user_avatar");
137        $temp = $user->getVar("theme");
138//      $theme_value = empty($temp) ? $xoopsConfig['default_theme'] : $temp;
139        $timezone_value = $user->getVar("timezone_offset");
140        $icq_value = $user->getVar("user_icq", "E");
141        $aim_value = $user->getVar("user_aim", "E");
142        $yim_value = $user->getVar("user_yim", "E");
143        $msnm_value = $user->getVar("user_msnm", "E");
144        $location_value = $user->getVar("user_from", "E");
145        $occ_value = $user->getVar("user_occ", "E");
146        $interest_value = $user->getVar("user_intrest", "E");
147        $sig_value = $user->getVar("user_sig", "E");
148        $sig_cbox_value = ($user->getVar("attachsig") == 1) ? 1 : 0;
149        $umode_value = $user->getVar("umode");
150        $uorder_value = $user->getVar("uorder");
151        // RMV-NOTIFY
152        $notify_method_value = $user->getVar("notify_method");
153        $notify_mode_value = $user->getVar("notify_mode");
154        $bio_value = $user->getVar("bio", "E");
155        $rank_value = $user->rank(false);
156        $mailok_value = $user->getVar('user_mailok', 'E');
157        $op_value = "updateUser";
158        $form_title = _AM_UPDATEUSER.": ".$user->getVar("uname");
159        $form_isedit = true;
160        $groups = array_values($user->getGroups());
161
162        $token = XoopsMultiTokenHandler::quickCreate('users_synchronize');
163
164        include XOOPS_ROOT_PATH."/modules/system/admin/users/userform.php";
165        echo "<br /><b>"._AM_USERPOST."</b><br /><br />\n";
166        echo "<table>\n";
167        echo "<tr><td>"._AM_COMMENTS."</td><td>".$user->getVar("posts")."</td></tr>\n";
168        echo "</table>\n";
169        echo "<br />"._AM_PTBBTSDIYT."<br />\n";
170        echo "<form action=\"admin.php\" method=\"post\">\n";
171        echo $token->getHtml();
172        echo "<input type=\"hidden\" name=\"id\" value=\"".$user->getVar("uid")."\" />";
173        echo "<input type=\"hidden\" name=\"type\" value=\"user\" />\n";
174        echo "<input type=\"hidden\" name=\"fct\" value=\"users\" />\n";
175        echo "<input type=\"hidden\" name=\"op\" value=\"synchronize\" />\n";
176        echo "<input type=\"submit\" value=\""._AM_SYNCHRONIZE."\" />\n";
177        echo "</form>\n";
178    } else {
179        echo "<h4 style='text-align:left;'>";
180        echo _AM_USERDONEXIT;
181        echo "</h4>";
182    }
183    xoops_cp_footer();
184}
185
186function synchronize($id, $type)
187{
188    global $xoopsDB;
189    switch($type) {
190    case 'user':
191        $id = intval($id);
192        // Array of tables from which to count 'posts'
193        $tables = array();
194        // Count comments (approved only: com_status == XOOPS_COMMENT_ACTIVE)
195        include_once XOOPS_ROOT_PATH . '/include/comment_constants.php';
196        $tables[] = array ('table_name' => 'xoopscomments', 'uid_column' => 'com_uid', 'criteria' => new Criteria('com_status', XOOPS_COMMENT_ACTIVE));
197        // Count forum posts
198        $tables[] = array ('table_name' => 'bb_posts', 'uid_column' => 'uid');
199
200        $total_posts = 0;
201        foreach ($tables as $table) {
202            $criteria = new CriteriaCompo();
203            $criteria->add (new Criteria($table['uid_column'], $id));
204            if (!empty($table['criteria'])) {
205                $criteria->add ($table['criteria']);
206            }
207            $sql = "SELECT COUNT(*) AS total FROM ".$xoopsDB->prefix($table['table_name']) . ' ' . $criteria->renderWhere();
208            if ( $result = $xoopsDB->query($sql) ) {
209                if ($row = $xoopsDB->fetchArray($result)) {
210                    $total_posts = $total_posts + $row['total'];
211                }
212            }
213        }
214        $sql = "UPDATE ".$xoopsDB->prefix("users")." SET posts = $total_posts WHERE uid = $id";
215        if ( !$result = $xoopsDB->query($sql) ) {
216            exit(sprintf(_AM_CNUUSER %s ,$id));
217        }
218        break;
219    case 'all users':
220        $sql = "SELECT uid FROM ".$xoopsDB->prefix("users")."";
221        if ( !$result = $xoopsDB->query($sql) ) {
222            exit(_AM_CNGUSERID);
223        }
224        while ($row = $xoopsDB->fetchArray($result)) {
225            $id = $row['uid'];
226            synchronize($id, "user");
227        }
228        break;
229    default:
230        break;
231    }
232    redirect_header("admin.php?fct=users&amp;op=modifyUser&amp;uid=".$id,1,_AM_DBUPDATED);
233    exit();
234}
235?>
Note: See TracBrowser for help on using the repository browser.