Changeset 534
- Timestamp:
- Mar 10, 2010, 4:47:23 PM (15 years ago)
- Location:
- trunk/xpressme_integration_kit
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/xpressme_integration_kit/include/add_xpress_process.php
r524 r534 18 18 $guess_url = preg_replace('|/' . $module_name . '/.*|i', '/' . $module_name, $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); 19 19 $blog_sub_path = ''; 20 if (defined('MULTISITE') && MULTISITE){20 if(function_exists('is_multisite') && is_multisite()){ 21 21 if ($blog_id > 1){ 22 $blog_path = '/cube_mu/modules/xpress3/toy/';23 22 $blog_sub_path = '/' .$blogname; 24 23 } -
trunk/xpressme_integration_kit/include/oninstall.php
r531 r534 121 121 $views_queries ="CREATE TABLE $group_role ( 122 122 groupid smallint(5) unsigned NOT NULL default '0', 123 blog_id bigint(20) unsigned NOT NULL default '0', 123 124 name varchar(50) NOT NULL default '' , 124 125 description text NOT NULL default '', -
trunk/xpressme_integration_kit/include/onupdate.php
r481 r534 254 254 } 255 255 256 $group_role = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_group_role' ; 256 257 if (! enhanced_table_check($mydirname,'group_role')){ 257 $group_role = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_group_role' ;258 258 $queries ="CREATE TABLE $group_role ( 259 259 groupid smallint(5) unsigned NOT NULL default '0', 260 blog_id bigint(20) unsigned NOT NULL default '0', 260 261 name varchar(50) NOT NULL default '' , 261 262 description text NOT NULL default '', … … 269 270 $db->queryF( $sql ) ; 270 271 $msgs[] = "$group_role table of XPressME was made."; 272 } else { 273 if (!is_found_table_column($group_role,'blog_id')){ 274 $queries ="ALTER TABLE $group_role ADD blog_id bigint(20) AFTER groupid"; 275 $db->queryF( $queries ) ; 276 $msgs[] = "$group_role ADD blog_id ."; 277 } 278 // The table is repaired. 279 $update_sql = "UPDATE $group_role SET blog_id = 1 WHERE(blog_id IS NULL OR blog_id < 1)"; 280 $db->queryF( $update_sql ) ; 271 281 } 272 282 -
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 -
trunk/xpressme_integration_kit/wp-content/plugins/xpressme/xpressme.php
r532 r534 96 96 add_action('profile_update', 'user_sync_to_xoops'); 97 97 add_action('user_register', 'user_sync_to_xoops'); 98 add_action('delete_blog', 'blog_group_role_delete',10,2); //at multi blog delete 99 add_action('wpmu_new_blog', 'blog_group_role_add',10,2); //at multi blog delete 100 98 101 //require_once('../include/custom_functions.php'); 99 102 … … 141 144 add_action('wpmu_new_blog','my_new_blog_template',0,1); 142 145 143 144 146 function redirect_xoops_admin() 145 147 { … … 193 195 function integration_option_page() 194 196 { 195 global $xoops_config,$xpress_config ;197 global $xoops_config,$xpress_config,$blog_id; 196 198 197 199 $xoops_admin_url = $xoops_config->module_url . '/admin/index.php'; … … 214 216 } 215 217 216 $xpress_config->GroupeRoleCheck( );218 $xpress_config->GroupeRoleCheck($blog_id); 217 219 echo '<div class="wrap">'."\n"; 218 220 echo '<div id="icon-options-general" class="icon32"><br /></div>'."\n"; … … 229 231 xpress_is_multiblog() 230 232 ); 231 $lock = ($xoops_config->module_url != get_bloginfo('url')); 233 // $lock = ($xoops_config->module_url != get_bloginfo('url')); 234 $lock = false; 232 235 echo $xpress_config->groupe_role_option($lock); 233 236 echo $xpress_config->d3forum_option($do_message); -
trunk/xpressme_integration_kit/wp-content/plugins/xpressme/xpressme_class.php
r531 r534 156 156 157 157 function GroupeRoleRead() { 158 global $xoops_db, $blog_id; 159 160 if (empty($blog_id)) $blog_id = 1; 161 $table = get_wp_prefix() . 'group_role'; 162 163 $sql= "SELECT * FROM $table WHERE blog_id = $blog_id ORDER BY groupid"; 164 $this->groupe_role = $xoops_db->get_results($sql); 165 } 166 167 function GroupeRoleCheck($blog_id = 1) { 158 168 global $xoops_db; 159 169 160 $table = get_wp_prefix() . 'group_role'; 161 162 $sql= "SELECT * FROM $table"; 163 $this->groupe_role = $xoops_db->get_results($sql); 164 } 165 166 function GroupeRoleCheck() { 167 global $xoops_db; 170 if (empty($blog_id)) $blog_id = 1; 168 171 169 172 $module_id = get_xpress_modid(); … … 173 176 $xoops_group_permission_table = get_xoops_prefix() . 'group_permission'; 174 177 175 176 177 178 $sql = "SELECT * FROM $xoops_group_permission_table WHERE gperm_itemid = $module_id"; 178 179 $gperms = $xoops_db->get_results($sql); 179 180 180 $sql = "SELECT * FROM $xoops_group_table WHERE group_type <> 'Anonymous' ";181 $sql = "SELECT * FROM $xoops_group_table WHERE group_type <> 'Anonymous' ORDER BY groupid"; 181 182 $groupes = $xoops_db->get_results($sql); 182 183 … … 194 195 } 195 196 196 $sql = "SELECT * FROM $group_role_table ";197 $sql = "SELECT * FROM $group_role_table WHERE blog_id = $blog_id"; 197 198 $groupes_role = $xoops_db->get_results($sql); 198 199 … … 214 215 if ($group_type == 'module_admin') $role = 'administrator'; 215 216 if ($group_type == 'module_inhibit') $role = ''; 216 $edit_sql = "UPDATE $group_role_table SET group_type='$group_type',role='$role' WHERE groupid = $groupe->groupid ";217 $edit_sql = "UPDATE $group_role_table SET group_type='$group_type',role='$role' WHERE groupid = $groupe->groupid AND blog_id = $blog_id"; 217 218 $found = true; 218 219 break; … … 224 225 225 226 $edit_sql = "INSERT INTO $group_role_table "; 226 $edit_sql .= "(groupid , name , description , group_type , role , login_all) ";227 $edit_sql .= "(groupid , blog_id , name , description , group_type , role , login_all) "; 227 228 $edit_sql .= "VALUES ("; 228 229 $edit_sql .= $groupe->groupid . ', '; 230 $edit_sql .= $blog_id . ', '; 229 231 $edit_sql .= "'" . $groupe->name . "' , "; 230 232 $edit_sql .= "'" . $groupe->description . "' , "; 231 $edit_sql .= "'" . $ parmission. "' , ";233 $edit_sql .= "'" . $group_type . "' , "; 232 234 $edit_sql .= "'" . $role . "' , '"; 233 235 $edit_sql .= $login_all . "')"; … … 252 254 function ReadPostData($post_data = null) 253 255 { 254 global $xoops_db; 255 256 global $xoops_db, $blog_id; 257 258 if (empty($blog_id)) $blog_id = 1; 256 259 foreach ( (array) $post_data as $index_key => $value ){ 257 260 if (preg_match('/^ch_/',$index_key)){ // case ch_ … … 322 325 $update_sql .= "role = '$role' , "; 323 326 $update_sql .= "login_all = $login_all "; 324 $update_sql .= "WHERE (groupid = '$groupe->groupid' )";327 $update_sql .= "WHERE (groupid = '$groupe->groupid' AND blog_id = $blog_id)"; 325 328 $xoops_db->query($update_sql); 326 329 }
Note: See TracChangeset
for help on using the changeset viewer.