Changeset 6913
- Timestamp:
- 04/16/2013 12:04:31 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.7/bp-groups/bp-groups-admin.php
r6835 r6913 260 260 261 261 if ( ! $admin_count ) { 262 262 263 $redirect_to = add_query_arg( 'no_admins', 1, $redirect_to ); 263 bp_core_redirect( $redirect_to ); 264 } 265 266 // Process only those users who have had their roles changed 267 foreach ( (array) $_POST['bp-groups-role'] as $user_id => $new_role ) { 268 269 $existing_role = isset( $_POST['bp-groups-existing-role'][$user_id] ) ? $_POST['bp-groups-existing-role'][$user_id] : ''; 270 271 if ( $existing_role != $new_role ) { 272 273 switch ( $new_role ) { 274 case 'mod' : 275 // Admin to mod is a demotion. Demote to 276 // member, then fall through 277 if ( 'admin' == $existing_role ) { 278 groups_demote_member( $user_id, $group_id ); 279 } 280 281 case 'admin' : 282 // If the user was banned, we must 283 // unban first 284 if ( 'banned' == $existing_role ) { 285 groups_unban_member( $user_id, $group_id ); 286 } 287 288 // At this point, each existing_role 289 // is a member, so promote 290 $result = groups_promote_member( $user_id, $group_id, $new_role ); 291 292 break; 293 294 case 'member' : 295 296 if ( 'admin' == $existing_role || 'mod' == $existing_role ) { 297 $result = groups_demote_member( $user_id, $group_id ); 298 } else if ( 'banned' == $existing_role ) { 299 $result = groups_unban_member( $user_id, $group_id ); 300 } 301 302 break; 303 304 case 'banned' : 305 306 $result = groups_ban_member( $user_id, $group_id ); 307 308 break; 309 310 case 'remove' : 311 312 $result = groups_remove_member( $user_id, $group_id ); 313 314 break; 315 } 316 317 // Store the success or failure 318 if ( $result ) { 319 $success_modified[] = $user_id; 320 } else { 321 $error_modified[] = $user_id; 264 $error = $group_id; 265 266 } else { 267 268 // Process only those users who have had their roles changed 269 foreach ( (array) $_POST['bp-groups-role'] as $user_id => $new_role ) { 270 271 $existing_role = isset( $_POST['bp-groups-existing-role'][$user_id] ) ? $_POST['bp-groups-existing-role'][$user_id] : ''; 272 273 if ( $existing_role != $new_role ) { 274 275 switch ( $new_role ) { 276 case 'mod' : 277 // Admin to mod is a demotion. Demote to 278 // member, then fall through 279 if ( 'admin' == $existing_role ) { 280 groups_demote_member( $user_id, $group_id ); 281 } 282 283 case 'admin' : 284 // If the user was banned, we must 285 // unban first 286 if ( 'banned' == $existing_role ) { 287 groups_unban_member( $user_id, $group_id ); 288 } 289 290 // At this point, each existing_role 291 // is a member, so promote 292 $result = groups_promote_member( $user_id, $group_id, $new_role ); 293 294 break; 295 296 case 'member' : 297 298 if ( 'admin' == $existing_role || 'mod' == $existing_role ) { 299 $result = groups_demote_member( $user_id, $group_id ); 300 } else if ( 'banned' == $existing_role ) { 301 $result = groups_unban_member( $user_id, $group_id ); 302 } 303 304 break; 305 306 case 'banned' : 307 308 $result = groups_ban_member( $user_id, $group_id ); 309 310 break; 311 312 case 'remove' : 313 314 $result = groups_remove_member( $user_id, $group_id ); 315 316 break; 317 } 318 319 // Store the success or failure 320 if ( $result ) { 321 $success_modified[] = $user_id; 322 } else { 323 $error_modified[] = $user_id; 324 } 322 325 } 323 326 }
Note: See TracChangeset
for help on using the changeset viewer.