| [ Index ] |
|
Code source de XOOPS 2.0.17.1 |
1 <?php 2 // $Id: users.php 937 2007-08-05 13:52:31Z malanciault $ 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 32 if ( !is_object($xoopsUser) || !is_object($xoopsModule) || !$xoopsUser->isAdmin($xoopsModule->mid()) ) { 33 exit("Access Denied"); 34 } 35 /*********************************************************/ 36 /* Users Functions */ 37 /*********************************************************/ 38 include_once XOOPS_ROOT_PATH."/class/xoopslists.php"; 39 include_once XOOPS_ROOT_PATH."/class/xoopsformloader.php"; 40 41 function displayUsers() 42 { 43 global $xoopsDB, $xoopsConfig, $xoopsModule; 44 $userstart = isset($_GET['userstart']) ? intval($_GET['userstart']) : 0; 45 xoops_cp_header(); 46 $member_handler =& xoops_gethandler('member'); 47 $usercount = $member_handler->getUserCount(); 48 $nav = new XoopsPageNav($usercount, 200, $userstart, "userstart", "fct=users"); 49 $editform = new XoopsThemeForm(_AM_EDEUSER, "edituser", "admin.php"); 50 $user_select = new XoopsFormSelect('', "uid"); 51 $criteria = new CriteriaCompo(); 52 $criteria->setSort('uname'); 53 $criteria->setOrder('ASC'); 54 $criteria->setLimit(200); 55 $criteria->setStart($userstart); 56 $user_select->addOptionArray($member_handler->getUserList($criteria)); 57 $user_select_tray = new XoopsFormElementTray(_AM_NICKNAME, "<br />"); 58 $user_select_tray->addElement($user_select); 59 $user_select_nav = new XoopsFormLabel('', $nav->renderNav(4)); 60 $user_select_tray->addElement($user_select_nav); 61 $op_select = new XoopsFormSelect("", "op"); 62 $op_select->addOptionArray(array("modifyUser"=>_AM_MODIFYUSER, "delUser"=>_AM_DELUSER)); 63 $submit_button = new XoopsFormButton("", "submit", _AM_GO, "submit"); 64 $fct_hidden = new XoopsFormHidden("fct", "users"); 65 $editform->addElement($user_select_tray); 66 $editform->addElement($op_select); 67 $editform->addElement($submit_button); 68 $editform->addElement($fct_hidden); 69 $editform->display(); 70 71 echo "<br />\n"; 72 $uid_value = ""; 73 $uname_value = ""; 74 $name_value = ""; 75 $email_value = ""; 76 $email_cbox_value = 0; 77 $url_value = ""; 78 // $avatar_value = "blank.gif"; 79 // $theme_value = $xoopsConfig['default_theme']; 80 $timezone_value = $xoopsConfig['default_TZ']; 81 $icq_value = ""; 82 $aim_value = ""; 83 $yim_value = ""; 84 $msnm_value = ""; 85 $location_value = ""; 86 $occ_value = ""; 87 $interest_value = ""; 88 $sig_value = ""; 89 $sig_cbox_value = 0; 90 $umode_value = $xoopsConfig['com_mode']; 91 $uorder_value = $xoopsConfig['com_order']; 92 // RMV-NOTIFY 93 include_once XOOPS_ROOT_PATH . '/include/notification_constants.php'; 94 $notify_method_value = XOOPS_NOTIFICATION_METHOD_PM; 95 $notify_mode_value = XOOPS_NOTIFICATION_MODE_SENDALWAYS; 96 $bio_value = ""; 97 $rank_value = 0; 98 $mailok_value = 0; 99 $op_value = "addUser"; 100 $form_title = _AM_ADDUSER; 101 $form_isedit = false; 102 $groups = array(XOOPS_GROUP_USERS); 103 include XOOPS_ROOT_PATH."/modules/system/admin/users/userform.php"; 104 xoops_cp_footer(); 105 } 106 107 function modifyUser($user) 108 { 109 global $xoopsDB, $xoopsConfig, $xoopsModule; 110 xoops_cp_header(); 111 $member_handler =& xoops_gethandler('member'); 112 $user =& $member_handler->getUser($user); 113 if (is_object($user)) { 114 if (!$user->isActive()) { 115 xoops_confirm(array('fct' => 'users', 'op' => 'reactivate', 'uid' => $user->getVar('uid')), 'admin.php', _AM_NOTACTIVE); 116 xoops_cp_footer(); 117 exit(); 118 } 119 $uid_value = $user->getVar("uid"); 120 $uname_value = $user->getVar("uname", "E"); 121 $name_value = $user->getVar("name", "E"); 122 $email_value = $user->getVar("email", "E"); 123 $email_cbox_value = $user->getVar("user_viewemail") ? 1 : 0; 124 $url_value = $user->getVar("url", "E"); 125 // $avatar_value = $user->getVar("user_avatar"); 126 $temp = $user->getVar("theme"); 127 // $theme_value = empty($temp) ? $xoopsConfig['default_theme'] : $temp; 128 $timezone_value = $user->getVar("timezone_offset"); 129 $icq_value = $user->getVar("user_icq", "E"); 130 $aim_value = $user->getVar("user_aim", "E"); 131 $yim_value = $user->getVar("user_yim", "E"); 132 $msnm_value = $user->getVar("user_msnm", "E"); 133 $location_value = $user->getVar("user_from", "E"); 134 $occ_value = $user->getVar("user_occ", "E"); 135 $interest_value = $user->getVar("user_intrest", "E"); 136 $sig_value = $user->getVar("user_sig", "E"); 137 $sig_cbox_value = ($user->getVar("attachsig") == 1) ? 1 : 0; 138 $umode_value = $user->getVar("umode"); 139 $uorder_value = $user->getVar("uorder"); 140 // RMV-NOTIFY 141 $notify_method_value = $user->getVar("notify_method"); 142 $notify_mode_value = $user->getVar("notify_mode"); 143 $bio_value = $user->getVar("bio", "E"); 144 $rank_value = $user->rank(false); 145 $mailok_value = $user->getVar('user_mailok', 'E'); 146 $op_value = "updateUser"; 147 $form_title = _AM_UPDATEUSER.": ".$user->getVar("uname"); 148 $form_isedit = true; 149 $groups = array_values($user->getGroups()); 150 include XOOPS_ROOT_PATH."/modules/system/admin/users/userform.php"; 151 echo "<br /><b>"._AM_USERPOST."</b><br /><br />\n"; 152 echo "<table>\n"; 153 echo "<tr><td>"._AM_COMMENTS."</td><td>".$user->getVar("posts")."</td></tr>\n"; 154 echo "</table>\n"; 155 echo "<br />"._AM_PTBBTSDIYT."<br />\n"; 156 echo "<form action=\"admin.php\" method=\"post\">\n"; 157 echo "<input type=\"hidden\" name=\"id\" value=\"".$user->getVar("uid")."\">"; 158 echo "<input type=\"hidden\" name=\"type\" value=\"user\">\n"; 159 echo "<input type=\"hidden\" name=\"fct\" value=\"users\">\n"; 160 echo "<input type=\"hidden\" name=\"op\" value=\"synchronize\">\n"; 161 echo $GLOBALS['xoopsSecurity']->getTokenHTML()."\n"; 162 echo "<input type=\"submit\" value=\""._AM_SYNCHRONIZE."\">\n"; 163 echo "</form>\n"; 164 } else { 165 echo "<h4 style='text-align:left;'>"; 166 echo _AM_USERDONEXIT; 167 echo "</h4>"; 168 } 169 xoops_cp_footer(); 170 } 171 172 // RMV-NOTIFY 173 function updateUser($uid, $uname, $name, $url, $email, $user_icq, $user_aim, $user_yim, $user_msnm, $user_from, $user_occ, $user_intrest, $user_viewemail, $user_avatar, $user_sig, $attachsig, $theme, $pass, $pass2, $rank, $bio, $uorder, $umode, $notify_method, $notify_mode, $timezone_offset, $user_mailok, $groups = array()) 174 { 175 global $xoopsConfig, $xoopsDB, $xoopsModule; 176 $member_handler =& xoops_gethandler('member'); 177 $edituser =& $member_handler->getUser($uid); 178 if ($edituser->getVar('uname') != $uname && $member_handler->getUserCount(new Criteria('uname', $uname)) > 0) { 179 xoops_cp_header(); 180 echo 'User name '.$uname.' already exists'; 181 xoops_cp_footer(); 182 } else { 183 $edituser->setVar("name", $name); 184 $edituser->setVar("uname", $uname); 185 $edituser->setVar("email", $email); 186 $url = isset( $url ) ? formatURL( $url ) : ''; 187 $edituser->setVar( "url", $url ); 188 // $edituser->setVar("user_avatar", $user_avatar); 189 $edituser->setVar("user_icq", $user_icq); 190 $edituser->setVar("user_from", $user_from); 191 $edituser->setVar("user_sig", $user_sig); 192 $user_viewemail = (isset($user_viewemail) && $user_viewemail == 1) ? 1 : 0; 193 $edituser->setVar("user_viewemail", $user_viewemail); 194 $edituser->setVar("user_aim", $user_aim); 195 $edituser->setVar("user_yim", $user_yim); 196 $edituser->setVar("user_msnm", $user_msnm); 197 $attachsig = ( isset( $attachsig ) && $attachsig == 1 ) ? 1 : 0; 198 $edituser->setVar("attachsig", $attachsig); 199 $edituser->setVar("timezone_offset", $timezone_offset); 200 // $edituser->setVar("theme", $theme); 201 $edituser->setVar("uorder", $uorder); 202 $edituser->setVar("umode", $umode); 203 // RMV-NOTIFY 204 $edituser->setVar("notify_method", $notify_method); 205 $edituser->setVar("notify_mode", $notify_mode); 206 $edituser->setVar("bio", $bio); 207 $edituser->setVar("rank", $rank); 208 $edituser->setVar("user_occ", $user_occ); 209 $edituser->setVar("user_intrest", $user_intrest); 210 $edituser->setVar('user_mailok', $user_mailok); 211 if ($pass2 != "") { 212 if ( $pass != $pass2 ) { 213 xoops_cp_header(); 214 echo " 215 <b>"._AM_STNPDNM."</b>"; 216 xoops_cp_footer(); 217 exit(); 218 } 219 $edituser->setVar("pass", md5($pass)); 220 } 221 if (!$member_handler->insertUser($edituser)) { 222 xoops_cp_header(); 223 echo $edituser->getHtmlErrors(); 224 xoops_cp_footer(); 225 } else { 226 if ($groups != array()) { 227 global $xoopsUser; 228 $oldgroups = $edituser->getGroups(); 229 //If the edited user is the current user and the current user WAS in the webmaster's group and is NOT in the new groups array 230 if ($edituser->getVar('uid') == $xoopsUser->getVar('uid') && (in_array(XOOPS_GROUP_ADMIN, $oldgroups)) && !(in_array(XOOPS_GROUP_ADMIN, $groups))) { 231 //Add the webmaster's group to the groups array to prevent accidentally removing oneself from the webmaster's group 232 array_push($groups, XOOPS_GROUP_ADMIN); 233 } 234 $member_handler =& xoops_gethandler('member'); 235 foreach ($oldgroups as $groupid) { 236 $member_handler->removeUsersFromGroup($groupid, array($edituser->getVar('uid'))); 237 } 238 foreach ($groups as $groupid) { 239 $member_handler->addUserToGroup($groupid, $edituser->getVar('uid')); 240 } 241 } 242 redirect_header("admin.php?fct=users",1,_AM_DBUPDATED); 243 } 244 } 245 exit(); 246 } 247 248 function synchronize($id, $type) 249 { 250 global $xoopsDB; 251 switch($type) { 252 case 'user': 253 // Array of tables from which to count 'posts' 254 $tables = array(); 255 // Count comments (approved only: com_status == XOOPS_COMMENT_ACTIVE) 256 include_once XOOPS_ROOT_PATH . '/include/comment_constants.php'; 257 $tables[] = array ('table_name' => 'xoopscomments', 'uid_column' => 'com_uid', 'criteria' => new Criteria('com_status', XOOPS_COMMENT_ACTIVE)); 258 // Count forum posts 259 $tables[] = array ('table_name' => 'bb_posts', 'uid_column' => 'uid'); 260 261 $total_posts = 0; 262 foreach ($tables as $table) { 263 $criteria = new CriteriaCompo(); 264 $criteria->add (new Criteria($table['uid_column'], $id)); 265 if (!empty($table['criteria'])) { 266 $criteria->add ($table['criteria']); 267 } 268 $sql = "SELECT COUNT(*) AS total FROM ".$xoopsDB->prefix($table['table_name']) . ' ' . $criteria->renderWhere(); 269 if ( $result = $xoopsDB->query($sql) ) { 270 if ($row = $xoopsDB->fetchArray($result)) { 271 $total_posts = $total_posts + $row['total']; 272 } 273 } 274 } 275 $sql = "UPDATE ".$xoopsDB->prefix("users")." SET posts = $total_posts WHERE uid = $id"; 276 if ( !$result = $xoopsDB->query($sql) ) { 277 exit(sprintf(_AM_CNUUSER %s ,$id)); 278 } 279 break; 280 case 'all users': 281 $sql = "SELECT uid FROM ".$xoopsDB->prefix("users").""; 282 if ( !$result = $xoopsDB->query($sql) ) { 283 exit(_AM_CNGUSERID); 284 } 285 while ($row = $xoopsDB->fetchArray($result)) { 286 $id = $row['uid']; 287 synchronize($id, "user"); 288 } 289 break; 290 default: 291 break; 292 } 293 redirect_header("admin.php?fct=users&op=modifyUser&uid=".$id,1,_AM_DBUPDATED); 294 exit(); 295 } 296 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sun Nov 25 11:44:32 2007 | par Balluche grâce à PHPXref 0.7 |
|