[72] | 1 | <?php
|
---|
| 2 | function get_xpress_mid($mydirname){
|
---|
| 3 | $xoopsDB =& Database::getInstance();
|
---|
| 4 | $module_tbl = $xoopsDB->prefix('modules');
|
---|
| 5 | $module_dir = XOOPS_ROOT_PATH . '/modules/' . $mydirname;
|
---|
| 6 | $module_id = 0;
|
---|
| 7 |
|
---|
| 8 | $sql = "SELECT mid FROM $module_tbl WHERE dirname LIKE '$mydirname'";
|
---|
| 9 | $result = $xoopsDB->query($sql, 0, 0);
|
---|
| 10 | if ($xoopsDB->getRowsNum($result) > 0){
|
---|
| 11 | $row = $xoopsDB->fetchArray($result);
|
---|
| 12 | $module_id = $row['mid'];
|
---|
| 13 | }
|
---|
| 14 | return $module_id;
|
---|
| 15 | }
|
---|
| 16 |
|
---|
| 17 |
|
---|
| 18 | function get_xoops_group_capabillities_name($mydirname , $uid=0){
|
---|
| 19 | if ($uid == 0){
|
---|
| 20 | return '';
|
---|
| 21 | }
|
---|
| 22 |
|
---|
| 23 | global $xoopsModule;
|
---|
| 24 | $xoopsDB =& Database::getInstance();
|
---|
| 25 | $db_groups_users_link = $xoopsDB->prefix('groups_users_link');
|
---|
| 26 | $db_group_permission = $xoopsDB->prefix('group_permission');
|
---|
| 27 | $module_tbl = $xoopsDB->prefix('modules');
|
---|
| 28 |
|
---|
| 29 | $module_id = get_xpress_mid($mydirname);
|
---|
| 30 | $sql = "SELECT uid FROM $db_groups_users_link WHERE groupid = 1 AND uid = $uid";
|
---|
| 31 |
|
---|
| 32 | $result = $xoopsDB->query($sql, 0, 0);
|
---|
| 33 | if ($xoopsDB->getRowsNum($result) > 0){
|
---|
| 34 | return 'administrator';
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | $sql = "SELECT Max($db_group_permission.gperm_itemid) AS user_level ,$db_groups_users_link.uid ";
|
---|
| 38 | $sql .= "FROM $db_groups_users_link LEFT JOIN $db_group_permission ON $db_groups_users_link.groupid = $db_group_permission.gperm_groupid ";
|
---|
| 39 | $sql .= "WHERE $db_group_permission.gperm_modid = $module_id ";
|
---|
| 40 | $sql .= "GROUP BY $db_groups_users_link.uid ";
|
---|
| 41 | $sql .= "HAVING $db_groups_users_link.uid = $uid";
|
---|
| 42 | $result = $xoopsDB->query($sql, 0, 0);
|
---|
| 43 | if ($result === false){
|
---|
| 44 | return '';
|
---|
| 45 | }else{
|
---|
| 46 | if ($xoopsDB->getRowsNum($result) > 0){
|
---|
| 47 | $row = $xoopsDB->fetchArray($result);
|
---|
| 48 | $level = $row['user_level'];
|
---|
| 49 | switch($level) {
|
---|
| 50 | case 5:
|
---|
| 51 | return 'administrator';
|
---|
| 52 | case 4:
|
---|
| 53 | return 'editor';
|
---|
| 54 | case 3:
|
---|
| 55 | return 'author';
|
---|
| 56 | case 2:
|
---|
| 57 | return 'contributor';
|
---|
| 58 | case 1:
|
---|
| 59 | return 'subscriber';
|
---|
| 60 | default:
|
---|
| 61 | return 'subscriber';
|
---|
| 62 | }
|
---|
| 63 | } else {
|
---|
| 64 | return '';
|
---|
| 65 | }
|
---|
| 66 | }
|
---|
| 67 | }
|
---|
| 68 |
|
---|
| 69 | //endif;
|
---|
| 70 |
|
---|
| 71 | //if( ! function_exists( 'get_xpress_prefix' ) ) :
|
---|
| 72 | function get_xpress_prefix($mydirname){
|
---|
| 73 | global $xoopsModule;
|
---|
| 74 | if ($mydirname == 'wordpress'){
|
---|
| 75 | return 'wp_';
|
---|
| 76 | } else {
|
---|
| 77 | return $mydirname . '_';
|
---|
| 78 | }
|
---|
| 79 | }
|
---|
| 80 | //endif;
|
---|
| 81 |
|
---|
| 82 | //if( ! function_exists( 'xpress_user_found' ) ) :
|
---|
| 83 | function xpress_user_found($mydirname, $login_name){
|
---|
| 84 | $wp_prefix = get_xpress_prefix($mydirname);
|
---|
| 85 | $xoopsDB =& Database::getInstance();
|
---|
| 86 | $db_xpress_users = $xoopsDB->prefix($wp_prefix . 'users');
|
---|
| 87 |
|
---|
| 88 | $sql = "SELECT ID FROM $db_xpress_users WHERE user_login = '$login_name'";
|
---|
| 89 | $res = $xoopsDB->query($sql, 0, 0);
|
---|
| 90 | if ($res === false){
|
---|
| 91 | return 0;
|
---|
| 92 | } else {
|
---|
| 93 | if ($xoopsDB->getRowsNum($res) > 0){
|
---|
| 94 | $row = $xoopsDB->fetchArray($res);
|
---|
| 95 | return $row['ID'];
|
---|
| 96 | } else {
|
---|
| 97 | return 0;
|
---|
| 98 | }
|
---|
| 99 | }
|
---|
| 100 | }
|
---|
| 101 | //endif;
|
---|
| 102 |
|
---|
| 103 |
|
---|
| 104 | //if( ! function_exists( 'xpress_usermeta_sync' ) ) :
|
---|
| 105 | function xpress_usermeta_sync($mydirname , $uid,$meta_key,$meta_value, &$message){
|
---|
| 106 | $wp_prefix = get_xpress_prefix($mydirname);
|
---|
| 107 | $meta_key = "'" . $meta_key . "'";
|
---|
| 108 | $meta_value = "'" . $meta_value . "'";
|
---|
| 109 | $xoopsDB =& Database::getInstance();
|
---|
| 110 | $db_xpress_usermeta = $xoopsDB->prefix($wp_prefix . 'usermeta');
|
---|
| 111 | $sql = "SELECT user_id FROM $db_xpress_usermeta WHERE (user_id = $uid) AND (meta_key = $meta_key)";
|
---|
| 112 | $res = $xoopsDB->query($sql, 0, 0);
|
---|
| 113 |
|
---|
| 114 | if ($res === false){
|
---|
| 115 | $sql2 = "INSERT INTO $db_xpress_usermeta (user_id,meta_key,meta_value) VALUES ($uid,$meta_key,$meta_value)";
|
---|
| 116 | }else {
|
---|
| 117 | if ($xoopsDB->getRowsNum($res) > 0){
|
---|
| 118 |
|
---|
| 119 | $sql2 = "UPDATE $db_xpress_usermeta SET meta_value = $meta_value WHERE (user_id = $uid) AND (meta_key = $meta_key)";
|
---|
| 120 | } else {
|
---|
| 121 | $sql2 = "INSERT INTO $db_xpress_usermeta (user_id,meta_key,meta_value) VALUES ($uid,$meta_key,$meta_value)";
|
---|
| 122 | }
|
---|
| 123 | }
|
---|
| 124 | $res = $xoopsDB->queryF($sql2, 0, 0);
|
---|
| 125 | if ($res === false) {
|
---|
| 126 | $message .= "...ERR($sql2)";
|
---|
| 127 | return false;
|
---|
| 128 | } else {
|
---|
| 129 | return true;
|
---|
| 130 | }
|
---|
| 131 |
|
---|
| 132 | }
|
---|
| 133 | //endif;
|
---|
| 134 |
|
---|
| 135 | function sql_str($text = ''){
|
---|
| 136 | return "'" . $text . "'";
|
---|
| 137 | }
|
---|
| 138 |
|
---|
| 139 | //if( ! function_exists( 'xpress_user_sync' ) ) :
|
---|
| 140 | function xpress_user_sync($sync_uid = 0, &$message){
|
---|
| 141 | $mydirname = basename( dirname( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) ) );
|
---|
| 142 |
|
---|
| 143 | if( is_object( @$GLOBALS["xoopsModule"] ) ) {
|
---|
| 144 | $wp_prefix = get_xpress_prefix($mydirname);
|
---|
| 145 | $xoopsDB =& Database::getInstance();
|
---|
| 146 | $db_xoops_users = $xoopsDB->prefix('users');
|
---|
| 147 | $db_xpress_users = $xoopsDB->prefix($wp_prefix . 'users');
|
---|
| 148 |
|
---|
| 149 | $message = 'Do Sync';
|
---|
| 150 |
|
---|
| 151 | if ($sync_uid == 0) {
|
---|
| 152 | $xu_sql = "SELECT uid ,name ,uname ,pass ,email, url, user_regdate, user_aim, user_yim FROM $db_xoops_users";
|
---|
| 153 | } else {
|
---|
| 154 | $xu_sql = "SELECT uid ,name ,uname ,pass ,email, url, user_regdate, user_aim, user_yim FROM $db_xoops_users WHERE uid = $sync_uid";
|
---|
| 155 | }
|
---|
| 156 |
|
---|
| 157 | $xu_res = $xoopsDB->query($xu_sql, 0, 0);
|
---|
| 158 | if ($xu_res === false){
|
---|
| 159 | $message .= '...ERR ('. $xu_sql . ')';
|
---|
| 160 | return false;
|
---|
| 161 | }else {
|
---|
| 162 | while($xu_row = $xoopsDB->fetchArray($xu_res)){
|
---|
| 163 | $capabillities_name = get_xoops_group_capabillities_name($mydirname , $xu_row['uid']);
|
---|
| 164 | if (empty($capabillities_name)){
|
---|
| 165 | $message .= "...PASS '" . $xu_row['uname'] ."'[uid=".$xu_row['uid'] ."](not xpress user)";
|
---|
| 166 | if ($sync_uid != 0){
|
---|
| 167 | $message .= '...NOT XPRESS USER ' . $xu_row['uname'];
|
---|
| 168 | return false;
|
---|
| 169 | }
|
---|
| 170 | } else {
|
---|
| 171 | $user_ID = $xu_row['uid'];
|
---|
| 172 | if ($capabillities_name != 'administrator' ){
|
---|
| 173 | if (!empty($GLOBALS["xoopsModuleConfig"]["use_wp_userlevel"])){
|
---|
| 174 | $capabillities_name = get_option('default_role');
|
---|
| 175 | }
|
---|
| 176 | }
|
---|
| 177 | $user_login_name = $xu_row['uname'];
|
---|
| 178 | $user_pass_md5 = $xu_row['pass'];
|
---|
| 179 | $user_email = $xu_row['email'];
|
---|
| 180 | $user_url = $xu_row['url'];
|
---|
| 181 | $user_regist_time = date('Y-m-d H:i:s' , $xu_row['user_regdate']);
|
---|
| 182 | $user_nicename = $xu_row['uname'];
|
---|
| 183 | $user_status = 0;
|
---|
| 184 | $user_display_name =empty($xu_row['name']) ? $xu_row['uname'] :$xu_row['name'] ;
|
---|
| 185 | $user_nickname = empty($xu_row['name']) ? $xu_row['uname'] :$xu_row['name'] ;
|
---|
| 186 | $user_aim = $xu_row['user_aim'];
|
---|
| 187 | $user_yim = $xu_row['user_yim'];
|
---|
| 188 | $user_first_name = $xu_row['uname'];
|
---|
| 189 | $user_last_name = '';
|
---|
| 190 | $user_description = '';
|
---|
| 191 | $user_jabber = '';
|
---|
| 192 | $user_rich_editing = 'true';
|
---|
| 193 |
|
---|
| 194 | $is_update = false;
|
---|
| 195 | if (xpress_user_found($mydirname, $user_login_name)){
|
---|
| 196 | $wu_sql = "UPDATE $db_xpress_users ";
|
---|
| 197 | $wu_sql .= 'SET ';
|
---|
| 198 | $wu_sql .= "user_pass = '$user_pass_md5', ";
|
---|
| 199 | $wu_sql .= "user_email = '$user_email', ";
|
---|
| 200 | $wu_sql .= "user_url = '$user_url', ";
|
---|
| 201 | $wu_sql .= "user_nicename = '$user_nicename', ";
|
---|
| 202 | $wu_sql .= "user_registered = '$user_regist_time', ";
|
---|
| 203 | $wu_sql .= "user_status = 0 ";
|
---|
| 204 | $wu_sql .= "WHERE (user_login = '$user_login_name' )";
|
---|
| 205 | if (!empty($GLOBALS["xoopsModuleConfig"]["use_wp_userlevel"])){
|
---|
| 206 | $message .= '...UPDATE ' . $user_login_name . '(Level Not Change)';
|
---|
| 207 | } else {
|
---|
| 208 | $message .= '...UPDATE ' . $user_login_name . '(' . $capabillities_name . ')';
|
---|
| 209 | }
|
---|
| 210 | $is_update = true;
|
---|
| 211 | }else{
|
---|
| 212 | $wu_sql = "INSERT INTO $db_xpress_users ";
|
---|
| 213 | $wu_sql .= "(user_login , user_pass ,user_email , user_url , user_nicename " ;
|
---|
| 214 | $wu_sql .= " , user_registered , user_status , display_name) ";
|
---|
| 215 | $wu_sql .= "VALUES ";
|
---|
| 216 | $wu_sql .= "('$user_login_name', '$user_pass_md5', '$user_email', '$user_url', '$user_nicename' ";
|
---|
| 217 | $wu_sql .= " , '$user_regist_time', $user_status, '$user_display_name')";
|
---|
| 218 | if (!empty($GLOBALS["xoopsModuleConfig"]["use_wp_userlevel"])){
|
---|
| 219 | $message .= '...INSERT ' . $user_login_name . '(' . $capabillities_name . '-WP Default)';
|
---|
| 220 | } else {
|
---|
| 221 | $message .= '...INSERT ' . $user_login_name . '(' . $capabillities_name . ')';
|
---|
| 222 | }
|
---|
| 223 | }
|
---|
| 224 |
|
---|
| 225 | $wu_res = $xoopsDB->queryF($wu_sql, 0, 0);
|
---|
| 226 |
|
---|
| 227 | if ($wu_res === false){
|
---|
| 228 | $message .= '...ERR(' . $wu_sql . ')';
|
---|
| 229 | return false;
|
---|
| 230 | }
|
---|
| 231 |
|
---|
| 232 | if (!empty($GLOBALS["xoopsModuleConfig"]["use_wp_userlevel"])){
|
---|
| 233 | if (!$is_update){
|
---|
| 234 | $sycc_user = new WP_User($user_ID);
|
---|
| 235 | $sycc_user->set_role($capabillities_name);
|
---|
| 236 | }
|
---|
| 237 | } else {
|
---|
| 238 | $sycc_user = new WP_User($user_ID);
|
---|
| 239 | $sycc_user->set_role($capabillities_name);
|
---|
| 240 | }
|
---|
| 241 |
|
---|
| 242 | // if( $is_update === false){
|
---|
| 243 | if(!xpress_usermeta_sync($mydirname, $user_ID,'nickname',$user_nickname,$message) )return false;
|
---|
| 244 | if(!xpress_usermeta_sync($mydirname, $user_ID,'first_name',$user_first_name,$message) )return false;
|
---|
| 245 | if(!xpress_usermeta_sync($mydirname, $user_ID,'last_name',$user_last_name,$message) )return false;
|
---|
| 246 | if(!xpress_usermeta_sync($mydirname, $user_ID,'description',$user_description,$message) )return false;
|
---|
| 247 | if(!xpress_usermeta_sync($mydirname, $user_ID,'jabber',$user_jabber,$message) )return false;
|
---|
| 248 | // }
|
---|
| 249 | if(!xpress_usermeta_sync($mydirname, $user_ID,'aim',$user_aim,$message) )return false;
|
---|
| 250 | if(!xpress_usermeta_sync($mydirname, $user_ID,'yim',$user_yim,$message) )return false;
|
---|
| 251 | if ($is_update === false ) {
|
---|
| 252 | if(!xpress_usermeta_sync($mydirname, $user_ID,'rich_editing',$user_rich_editing,$message) )return false;
|
---|
| 253 | }
|
---|
| 254 | }
|
---|
| 255 | }
|
---|
| 256 | }
|
---|
| 257 | $message .= "...END";
|
---|
| 258 | return true;
|
---|
| 259 | }
|
---|
| 260 | }
|
---|
| 261 | //endif;
|
---|
| 262 |
|
---|
| 263 |
|
---|
| 264 |
|
---|
| 265 | //if( ! function_exists( 'check_user_role_prefix' ) ) :
|
---|
| 266 | function check_user_role_prefix($mydirname){
|
---|
| 267 | $wp_prefix = get_xpress_prefix($mydirname);
|
---|
| 268 | $xoopsDB =& Database::getInstance();
|
---|
| 269 | $db_xpress_usermeta = $xoopsDB->prefix($wp_prefix . 'usermeta');
|
---|
| 270 | $user_meta_prefix =$xoopsDB->prefix($wp_prefix);
|
---|
| 271 |
|
---|
| 272 | $sql = "SELECT * FROM $db_xpress_usermeta WHERE meta_key LIKE '%_" . $wp_prefix . "user_level' OR meta_key LIKE '%_" . $wp_prefix . "capabilities' OR meta_key LIKE '%_" . $wp_prefix . "autosave_draft_ids'";
|
---|
| 273 | $result = $xoopsDB->query($sql, 0, 0);
|
---|
| 274 | if ($result === false){
|
---|
| 275 | return -1;
|
---|
| 276 | }else{
|
---|
| 277 | $i=0;
|
---|
| 278 | while($row = $xoopsDB->fetchArray($result)){
|
---|
| 279 | $meta_key = $row['meta_key'];
|
---|
| 280 | if (strpos($meta_key,$user_meta_prefix) === false) {
|
---|
| 281 | $i++;
|
---|
| 282 | }
|
---|
| 283 | }
|
---|
| 284 | return $i;
|
---|
| 285 | }
|
---|
| 286 | }
|
---|
| 287 | //endif;
|
---|
| 288 |
|
---|
| 289 | //if( ! function_exists( 'same_metakey_delete' ) ) :
|
---|
| 290 | function same_metakey_delete($mydirname,$metakey){
|
---|
| 291 | $wp_prefix = get_xpress_prefix($mydirname);
|
---|
| 292 | $xoopsDB =& Database::getInstance();
|
---|
| 293 | $db_xpress_usermeta = $xoopsDB->prefix($wp_prefix . 'usermeta');
|
---|
| 294 | $user_meta_prefix =$xoopsDB->prefix($wp_prefix);
|
---|
| 295 |
|
---|
| 296 | $sql = "DELETE FROM $db_xpress_usermeta WHERE meta_key LIKE '$metakey'";
|
---|
| 297 | $result = $xoopsDB->query($sql, 0, 0);
|
---|
| 298 | if ($result === false){
|
---|
| 299 | return false;
|
---|
| 300 | }else{
|
---|
| 301 | return true;
|
---|
| 302 | }
|
---|
| 303 | }
|
---|
| 304 | //endif;
|
---|
| 305 |
|
---|
| 306 | //if( ! function_exists( 'repair_user_role_prefix' ) ) :
|
---|
| 307 | function repair_user_role_prefix($mydirname){
|
---|
| 308 | $wp_prefix = get_xpress_prefix($mydirname);
|
---|
| 309 | $xoopsDB =& Database::getInstance();
|
---|
| 310 | $db_xpress_usermeta = $xoopsDB->prefix($wp_prefix . 'usermeta');
|
---|
| 311 | $user_meta_prefix =$xoopsDB->prefix($wp_prefix);
|
---|
| 312 | $ret = '';
|
---|
| 313 |
|
---|
| 314 | $sql = "SELECT * FROM $db_xpress_usermeta WHERE meta_key LIKE '%_" . $wp_prefix . "user_level' OR meta_key LIKE '%_" . $wp_prefix . "capabilities' OR meta_key LIKE '%_" . $wp_prefix . "autosave_draft_ids'";
|
---|
| 315 | $result = $xoopsDB->queryF($sql, 0, 0);
|
---|
| 316 | if ($result === false){
|
---|
| 317 | return -1;
|
---|
| 318 | }else{
|
---|
| 319 | $i=0;
|
---|
| 320 | while($row = $xoopsDB->fetchArray($result)){
|
---|
| 321 | $meta_key = $row['meta_key'];
|
---|
| 322 | $umeta_id = $row['umeta_id'];
|
---|
| 323 | if (strpos($meta_key,$user_meta_prefix) === false) {
|
---|
| 324 | $new_meta_key = '';
|
---|
| 325 | if (strpos($meta_key,$wp_prefix.'user_level')){
|
---|
| 326 | $new_meta_key = $xoopsDB->prefix($wp_prefix . 'user_level');
|
---|
| 327 | }
|
---|
| 328 |
|
---|
| 329 | if (strpos($meta_key,$wp_prefix.'capabilities')){
|
---|
| 330 | $new_meta_key = $xoopsDB->prefix($wp_prefix . 'capabilities');
|
---|
| 331 | }
|
---|
| 332 |
|
---|
| 333 | if (strpos($meta_key,$wp_prefix.'autosave_draft_ids')){
|
---|
| 334 | $new_meta_key = $xoopsDB->prefix($wp_prefix . 'autosave_draft_ids');
|
---|
| 335 | }
|
---|
| 336 |
|
---|
| 337 | if (!empty($new_meta_key)){
|
---|
| 338 | same_metakey_delete($mydirname,$new_meta_key);
|
---|
| 339 |
|
---|
| 340 | $repair_sql = "UPDATE $db_xpress_usermeta ";
|
---|
| 341 | $repair_sql .= 'SET ';
|
---|
| 342 | $repair_sql .= "meta_key = '$new_meta_key' ";
|
---|
| 343 | $repair_sql .= "WHERE (umeta_id = $umeta_id )";
|
---|
| 344 | $repair_res = $xoopsDB->queryF($repair_sql, 0, 0);
|
---|
| 345 | if ($repair_res === false){
|
---|
| 346 | $ret .= '...ERR(' . $meta_key . '->' . $new_meta_key . ')<br>';
|
---|
| 347 | } else {
|
---|
| 348 | $ret .= '...DO(' . $meta_key . '->' . $new_meta_key . ')<br>';
|
---|
| 349 | }
|
---|
| 350 | }
|
---|
| 351 | }
|
---|
| 352 | }
|
---|
| 353 | }
|
---|
| 354 | return $ret;
|
---|
| 355 | }
|
---|
| 356 | //endif;
|
---|
| 357 |
|
---|
| 358 |
|
---|
| 359 | /*
|
---|
| 360 | * Get User ID of XOOPS from the login name.
|
---|
| 361 | */
|
---|
| 362 | function get_xoops_user_id($login_name){
|
---|
| 363 | global $xoops_db;
|
---|
| 364 | $sql = "SELECT uid FROM " . get_xoops_prefix() . "users WHERE uname = '$login_name'";
|
---|
| 365 | $uid = $xoops_db->get_var($sql);
|
---|
| 366 | return $uid;
|
---|
| 367 | }
|
---|
| 368 |
|
---|
| 369 | /*
|
---|
| 370 | *The user data of wordpress is written in the xoops user data.
|
---|
| 371 | */
|
---|
| 372 | function user_sync_to_xoops($user_ID){
|
---|
| 373 | global $xoops_db;
|
---|
| 374 |
|
---|
| 375 | $user_info = get_userdata($user_ID);
|
---|
| 376 | $xoops_uid = get_xoops_user_id($user_info->user_login);
|
---|
| 377 | $db_xoops_users = get_xoops_prefix() . "users";
|
---|
| 378 | $user_regdate = strtotime($user_info->user_registered);
|
---|
| 379 | $aim = get_usermeta($user_ID,'aim');
|
---|
| 380 | $yim = get_usermeta($user_ID,'yim');
|
---|
| 381 |
|
---|
| 382 | if ($xoops_uid){
|
---|
| 383 | $wu_sql = "UPDATE $db_xoops_users ";
|
---|
| 384 | $wu_sql .= 'SET ';
|
---|
| 385 | $wu_sql .= "uname = '$user_info->user_login', ";
|
---|
| 386 | $wu_sql .= "pass = '$user_info->user_pass', ";
|
---|
| 387 | $wu_sql .= "email = '$user_info->user_email', ";
|
---|
| 388 | $wu_sql .= "url = '$user_info->user_url', ";
|
---|
| 389 | $wu_sql .= "name = '$user_info->display_name', ";
|
---|
| 390 | $wu_sql .= "user_aim = '$aim', ";
|
---|
| 391 | $wu_sql .= "user_yim = '$yim', ";
|
---|
| 392 | $wu_sql .= "user_regdate = $user_regdate ";
|
---|
| 393 | $wu_sql .= "WHERE (uid = $xoops_uid )";
|
---|
[82] | 394 | $xoops_db->query($wu_sql);
|
---|
[72] | 395 | }else{
|
---|
| 396 | $wu_sql = "INSERT INTO $db_xoops_users ";
|
---|
| 397 | $wu_sql .= "(uname , pass ,email , url , name , user_aim , user_yim , user_regdate) " ;
|
---|
| 398 | $wu_sql .= "VALUES ";
|
---|
| 399 | $wu_sql .= "('$user_info->user_login', '$user_info->user_pass', '$user_info->user_email', '$user_info->user_url', '$user_info->display_name' ";
|
---|
| 400 | $wu_sql .= " , '$aim' , '$yim' , $user_regdate )";
|
---|
[82] | 401 | $xoops_db->query($wu_sql);
|
---|
| 402 | // get xoops users default groupe ID
|
---|
| 403 | $db_xoops_group = get_xoops_prefix() . 'groups';
|
---|
| 404 | $default_xoops_group_id = $xoops_db->get_var("SELECT groupid FROM $db_xoops_group WHERE group_type = 'User'");
|
---|
| 405 | // get insert users ID
|
---|
| 406 | $db_xoops_group = get_xoops_prefix() . 'users';
|
---|
| 407 | $user_id = $xoops_db->get_var("SELECT uid FROM $db_xoops_group WHERE uname = '$user_info->user_login'");
|
---|
| 408 | // insert groups_users_link
|
---|
| 409 | $db_xoops_group_users_link = get_xoops_prefix() . 'groups_users_link';
|
---|
| 410 | $default_xoops_group_id = $xoops_db->get_var("INSERT INTO $db_xoops_group_users_link (groupid , uid ) VALUES ($default_xoops_group_id , $user_id)");
|
---|
[72] | 411 | }
|
---|
| 412 | }
|
---|
| 413 | ?> |
---|