- Timestamp:
- Mar 10, 2010, 4:47:23 PM (15 years ago)
- Location:
- trunk/xpressme_integration_kit/wp-content/plugins/xpressme/include
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/xpressme_integration_kit/wp-content/plugins/xpressme/include/custom_functions.php
r531 r534 44 44 global $xoops_config; 45 45 46 if ( defined('MULTISITE')) return MULTISITE;46 if (function_exists('is_multisite') && is_multisite()) return true; 47 47 return false; 48 48 } … … 50 50 function xpress_is_multiblog_root() { 51 51 global $blog_id; 52 if ( defined('MULTISITE') && MULTISITE&& $blog_id == 1){52 if ( xpress_is_multiblog() && $blog_id == 1){ 53 53 return true; 54 54 } else { -
trunk/xpressme_integration_kit/wp-content/plugins/xpressme/include/user_sync_xoops.php
r417 r534 26 26 */ 27 27 function get_xoops_group_role($uid=0){ 28 $ans = array();29 28 if ($uid == 0){ 30 29 return ''; … … 32 31 33 32 global $xoops_db; 33 34 34 $db_groups_users_link = get_xoops_prefix() . 'groups_users_link'; 35 35 $db_group_role = get_wp_prefix() . 'group_role'; 36 36 $db_groups = get_xoops_prefix() . 'groups'; 37 38 $sql = "SELECT * "; 39 $sql .= "FROM $db_groups_users_link "; 40 $sql .= "LEFT JOIN $db_group_role ON $db_groups_users_link.groupid = $db_group_role.groupid "; 41 $sql .= "LEFT JOIN $db_groups ON $db_groups_users_link.groupid = $db_groups.groupid "; 42 $sql .= "WHERE uid = $uid"; 43 $user_groups = $xoops_db->get_results($sql); 44 $ans['capabillities'] = ''; 45 $ans['allway_update'] = 0; 46 47 foreach($user_groups as $user_group){ 48 if ($user_group->group_type == 'Admin'){ 49 $ans['capabillities'] = 'administrator'; 50 if ($user_group->groupid =1){ 51 //It always rewrites it as WordPress adninistrator for an initial admin group of XOOPS. 52 $ans['allway_update'] = 1; 53 } else { 54 // admin groups other than initial admin group of XOOPS 55 // It group rewrites group_type of the data base in Admin. 56 $ans['allway_update'] = $user_group->login_all; 57 } 58 break; 59 } 60 $before_level = get_role_level($ans['capabillities']); 37 38 $blog_id_list = array(); 39 40 if (function_exists('is_multisite') && is_multisite()){ 41 $blog_id_sql = "SELECT blog_id FROM $db_group_role GROUP BY blog_id"; 42 $blog_id_list = $xoops_db->get_results($blog_id_sql); 43 } else { 44 $std = new stdClass(); 45 $std->blog_id = 1; 46 $blog_id_list[] = $std; 47 } 48 49 $ans_array = array(); 50 foreach($blog_id_list as $blog_id){ 51 $ans = array(); 52 $sql = "SELECT * "; 53 $sql .= "FROM $db_groups_users_link "; 54 $sql .= "LEFT JOIN $db_group_role ON $db_groups_users_link.groupid = $db_group_role.groupid "; 55 $sql .= "LEFT JOIN $db_groups ON $db_groups_users_link.groupid = $db_groups.groupid "; 56 $sql .= "WHERE uid = $uid AND $db_group_role.blog_id = $blog_id->blog_id"; 57 $user_groups = $xoops_db->get_results($sql); 61 58 62 $now_level = get_role_level($user_group->role); 63 if ($now_level > $before_level){ 64 $ans['capabillities'] = $user_group->role; 65 $ans['allway_update'] = $user_group->login_all; 66 } 67 } 68 return $ans; 69 } 70 59 //default value set 60 $ans['blog_id'] = $blog_id->blog_id; 61 $ans['capabillities'] = ''; 62 $ans['allway_update'] = 0; 63 64 //get maximum role 65 foreach($user_groups as $user_group){ 66 if ($user_group->group_type == 'Admin'){ 67 $ans['capabillities'] = 'administrator'; 68 if ($user_group->groupid =1){ 69 //It always rewrites it as WordPress adninistrator for an initial admin group of XOOPS. 70 $ans['allway_update'] = 1; 71 } else { 72 // admin groups other than initial admin group of XOOPS 73 // It group rewrites group_type of the data base in Admin. 74 $ans['allway_update'] = $user_group->login_all; 75 } 76 break; 77 } 78 $before_level = get_role_level($ans['capabillities']); 79 80 $now_level = get_role_level($user_group->role); 81 if ($now_level > $before_level){ 82 $ans['capabillities'] = $user_group->role; 83 $ans['allway_update'] = $user_group->login_all; 84 } 85 } 86 $ans_array[] = $ans; 87 } 88 return $ans_array; 89 } 90 91 // for Multi Blog group_role delete 92 function blog_group_role_delete($blog_id,$drop = false) { 93 global $xoops_db; 94 95 $db_group_role = get_wp_prefix() . 'group_role'; 96 if ($drop){ 97 $delsql = "DELETE FROM $db_group_role WHERE blog_id = $blog_id"; 98 $xoops_db->query($delsql); 99 } 100 } 101 102 // for Multi Blog group_role add 103 function blog_group_role_add($blog_id,$uid = 0) { 104 global $xoops_db,$xpress_config; 105 $xpress_config->GroupeRoleCheck($blog_id); 106 } 107 108 // check user has groupe role 109 function has_group_role($uid = 0) { 110 if (empty($uid)) return false; 111 $user_roles = get_xoops_group_role($uid); 112 foreach ($user_roles as $user_role){ 113 if (!empty($user_role['capabillities'])) 114 return true; 115 } 116 return false; 117 } 118 119 /* 120 * WP User ID exists is checked.. 121 */ 122 function set_user_role($uid=0,$new_user = false){ 123 $roles = get_xoops_group_role($uid); 124 125 foreach($roles as $role){ 126 $b_id = $role['blog_id']; 127 $capabillities_name = $role['capabillities']; 128 $allway_update = $role['allway_update']; 129 if ($allway_update || $new_user ){ 130 $sycc_user = new WP_User($uid); 131 if (function_exists('is_multisite') && is_multisite()){ 132 $sycc_user->for_blog($b_id); // for Multi blog 133 } 134 // check user role is admin 135 $is_blog_admin = false; 136 $user_roles = $sycc_user->roles; 137 foreach ($user_roles as $user_role){ 138 if (strcmp($user_role , 'administrator') == 0){ 139 $is_blog_admin = true; 140 break; 141 } 142 } 143 if (!$is_blog_admin){ // admin not change role 144 $sycc_user->set_role($capabillities_name); 145 } 146 } 147 // $message .= '...UPDATE ' . $xoops_user->uname . '(' . $capabillities_name . ')'; 148 // $message .= '...INSERT ' . $user_login_name . '(' . $capabillities_name . ')'; 149 } 150 151 } 152 71 153 /* 72 154 * Get User ID of WordPress from the login name. … … 118 200 119 201 foreach($xoops_users as $xoops_user){ 120 $role = get_xoops_group_role($xoops_user->uid);121 $capabillities_name = $role['capabillities'];122 $allway_update = $role['allway_update'];123 202 124 203 $wp_user_id = get_wp_user_id($xoops_user->uname) ; 125 126 if (empty($capabillities_name)){ 204 205 206 $has_role = has_group_role($xoops_user->uid); 207 if (!$has_role){ 127 208 if ($sync_uid != 0){ 128 209 if ($wp_user_id) { … … 148 229 149 230 if ($wp_user_id){ 231 $add_user = true; 150 232 $wu_sql = "UPDATE $db_xpress_users "; 151 233 $wu_sql .= 'SET '; … … 159 241 160 242 $xoops_db->query($wu_sql); 161 if ($allway_update){ 162 $sycc_user = new WP_User($wp_user_id); 163 $sycc_user->set_role($capabillities_name); 164 $message .= '...UPDATE ' . $xoops_user->uname . '(' . $capabillities_name . ')'; 165 166 } else { 167 $message .= '...UPDATE ' . $xoops_user->uname . '(Level Not Change)'; 168 } 243 244 $message .= set_user_role($wp_user_id,$add_user); 245 169 246 if (!check_user_meta_prefix($wp_user_id)){ 170 247 repair_user_meta_prefix(); … … 173 250 $is_update = true; 174 251 }else{ 252 $add_user = false; 175 253 if (is_used_wp_user_id($xoops_user->uid) ) { // WP User ID has already been used. 176 254 $wu_sql = "INSERT INTO $db_xpress_users "; … … 192 270 $wp_user_id = $xoops_user->uid; 193 271 } 194 $sycc_user = new WP_User($wp_user_id); 195 $sycc_user->set_role($capabillities_name); 196 $message .= '...INSERT ' . $user_login_name . '(' . $capabillities_name . ')'; 272 $message .= set_user_role($wp_user_id,$add_user); 197 273 } 198 274
Note: See TracChangeset
for help on using the changeset viewer.