Changeset 1918
- Timestamp:
- 08/05/2009 02:46:08 PM (17 years ago)
- Location:
- branches/2.8
- Files:
-
- 2 edited
-
wp-admin/includes/mu.php (modified) (3 diffs)
-
wp-includes/wpmu-functions.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/2.8/wp-admin/includes/mu.php
r1914 r1918 497 497 function redirect_user_to_blog() { 498 498 global $current_user, $current_site; 499 $details = get_active_blog_for_user( $current_user->ID );500 499 $c = 0; 501 500 if ( isset( $_GET[ 'c' ] ) ) … … 507 506 $c ++; 508 507 509 if( $details == "username only" ) {510 if ( $dashboard_blog = get_site_option( 'dashboard_blog' ) ) {511 add_user_to_blog( $dashboard_blog, $current_user->ID, 'subscriber' ); // Add subscriber permission for dashboard blog512 } else {513 add_user_to_blog( get_blog_id_from_url( $current_site->domain, $current_site->path ), $current_user->ID, 'subscriber' ); // Add subscriber permission for first blog.514 }508 $blog = get_active_blog_for_user( $current_user->ID ); 509 $dashboard_blog = get_dashboard_blog(); 510 if( is_object( $blog ) ) { 511 $protocol = ( is_ssl() ? 'https://' : 'http://' ); 512 wp_redirect( $protocol . $blog->domain . $blog->path . 'wp-admin/?c=' . $c ); // redirect and count to 5, "just in case" 513 exit; 515 514 } 516 515 … … 521 520 $blogs = get_blogs_of_user( $current_user->ID ); 522 521 523 if ( sizeof( $blogs ) == 1) {522 if ( !empty( $blogs ) ) { 524 523 foreach( $blogs as $blogid => $blog ) { 525 if ( $blogid != 1 && get_usermeta( $current_user->ID , 'primary_blog' ) == 1) {524 if ( $blogid != $dashboard_blog->blog_id && get_usermeta( $current_user->ID , 'primary_blog' ) == $dashboard_blog->blog_id ) { 526 525 update_usermeta( $current_user->ID, 'primary_blog', $blogid ); 527 wp_redirect( "http://" . $blog->domain . $blog->path . 'wp-admin/?c=' . $c ); // redirect and count to 5, "just in case" 528 exit; 526 continue; 529 527 } 530 528 } 529 $blog = get_blog_details( get_usermeta( $current_user->ID , 'primary_blog' ) ); 530 $protocol = ( is_ssl() ? 'https://' : 'http://' ); 531 wp_redirect( $protocol . $blog->domain . $blog->path . 'wp-admin/?c=' . $c ); // redirect and count to 5, "just in case" 532 exit; 531 533 } 532 534 wp_die( __( 'You do not have sufficient permissions to access this page.' ) ); -
branches/2.8/wp-includes/wpmu-functions.php
r1917 r1918 424 424 function get_active_blog_for_user( $user_id ) { // get an active blog for user - either primary blog or from blogs list 425 425 global $wpdb; 426 $blogs = get_blogs_of_user( $user_id ); 427 if ( empty( $blogs ) ) { 428 $details = get_dashboard_blog(); 429 add_user_to_blog( $details->blog_id, $user_id, 'subscriber' ); // Add subscriber permission for dashboard blog 430 update_usermeta($user_id, 'primary_blog', $details->blog_id); 431 wp_cache_delete( $user_id, 'users' ); 432 return $details; 433 } 434 426 435 $primary_blog = get_usermeta( $user_id, "primary_blog" ); 427 if( $primary_blog == false ) { 428 $details = false; 436 if ( $primary_blog ) { 437 $blogs = get_blogs_of_user( $user_id ); 438 if ( isset( $blogs[ $primary_blog ] ) == false ) { 439 $details = get_dashboard_blog(); 440 add_user_to_blog( $details->blog_id, $user_id, 'subscriber' ); // Add subscriber permission for dashboard blog 441 update_usermeta( $user_id, 'primary_blog', $details->blog_id ); 442 wp_cache_delete( $user_id, 'users' ); 443 } else { 444 $details = get_blog_details( $primary_blog ); 445 } 429 446 } else { 430 $details = get_blog_details( $primary_blog ); 431 } 432 433 if( ( is_object( $details ) == false ) || ( is_object( $details ) && $details->archived == 1 || $details->spam == 1 || $details->deleted == 1 ) ) { 447 $details = get_dashboard_blog(); 448 add_user_to_blog( $details->blog_id, $user_id, 'subscriber' ); // Add subscriber permission for dashboard blog 449 update_usermeta( $user_id, 'primary_blog', $details->blog_id ); 450 } 451 452 if ( ( is_object( $details ) == false ) || ( is_object( $details ) && $details->archived == 1 || $details->spam == 1 || $details->deleted == 1 ) ) { 434 453 $blogs = get_blogs_of_user( $user_id, true ); // if a user's primary blog is shut down, check their other blogs. 435 454 $ret = false; 436 if ( is_array( $blogs ) && count( $blogs ) > 0 ) {455 if ( is_array( $blogs ) && count( $blogs ) > 0 ) { 437 456 foreach( (array) $blogs as $blog_id => $blog ) { 438 457 if ( $blog->site_id != $wpdb->siteid ) 439 458 continue; 440 459 $details = get_blog_details( $blog_id ); 441 if ( is_object( $details ) && $details->archived == 0 && $details->spam == 0 && $details->deleted == 0 ) {460 if ( is_object( $details ) && $details->archived == 0 && $details->spam == 0 && $details->deleted == 0 ) { 442 461 $ret = $blog; 443 462 $changed = false; 444 if ( !get_usermeta($user_id , 'primary_blog')) {445 update_usermeta( $user_id, 'primary_blog', $blog->userblog_id);463 if ( get_usermeta( $user_id , 'primary_blog' ) != $blog_id ) { 464 update_usermeta( $user_id, 'primary_blog', $blog_id ); 446 465 $changed = true; 447 466 } 448 if ( !get_usermeta($user_id , 'source_domain') ) {449 update_usermeta( $user_id, 'source_domain', $blog->domain);467 if ( !get_usermeta($user_id , 'source_domain') ) { 468 update_usermeta( $user_id, 'source_domain', $blog->domain ); 450 469 $changed = true; 451 470 } 452 if ( $changed )471 if ( $changed ) 453 472 wp_cache_delete( $user_id, 'users' ); 454 473 break; … … 456 475 } 457 476 } else { 458 $ret = "username only"; // user has no blogs. 477 // Should never get here 478 $dashboard_blog = get_dashboard_blog(); 479 add_user_to_blog( $dashboard_blog->blog_id, $user_id, 'subscriber' ); // Add subscriber permission for dashboard blog 480 update_usermeta( $user_id, 'primary_blog', $dashboard_blog->blog_id ); 481 return $dashboard_blog; 459 482 } 460 483 return $ret;
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)