]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/includes/ms.php
Wordpress 3.2
[autoinstalls/wordpress.git] / wp-admin / includes / ms.php
index 84585264965909efdd3bfedc86651b0581a41ec0..98991ef61802f7d5e5b2446579f2b075ec251be5 100644 (file)
@@ -496,26 +496,41 @@ function sync_category_tag_slugs( $term, $taxonomy ) {
 }
 add_filter( 'get_term', 'sync_category_tag_slugs', 10, 2 );
 
-function redirect_user_to_blog() {
-       $c = 0;
-       if ( isset( $_GET['c'] ) )
-               $c = (int) $_GET['c'];
+function _access_denied_splash() {
+       if ( ! is_user_logged_in() || is_network_admin() )
+               return;
 
-       if ( $c >= 5 ) {
-               wp_die( __( "You don’t have permission to view this site. Please contact the system administrator." ) );
-       }
-       $c ++;
+       $blogs = get_blogs_of_user( get_current_user_id() );
 
-       $blog = get_active_blog_for_user( get_current_user_id() );
+       if ( wp_list_filter( $blogs, array( 'userblog_id' => get_current_blog_id() ) ) )
+               return;
 
-       if ( is_object( $blog ) ) {
-               wp_redirect( get_admin_url( $blog->blog_id, '?c=' . $c ) ); // redirect and count to 5, "just in case"
-       } else {
-               wp_redirect( user_admin_url( '?c=' . $c ) ); // redirect and count to 5, "just in case"
+       $blog_name = get_bloginfo( 'name' );
+
+       if ( empty( $blogs ) )
+               wp_die( sprintf( __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), $blog_name ) );
+
+       $output = '<p>' . sprintf( __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), $blog_name ) . '</p>';
+       $output .= '<p>' . __( 'If you reached this screen by accident and meant to visit one of your own sites, here are some shortcuts to help you find your way.' ) . '</p>';
+
+       $output .= '<h3>' . __('Your Sites') . '</h3>';
+       $output .= '<table>';
+
+       foreach ( $blogs as $blog ) {
+               $output .= "<tr>";
+               $output .= "<td valign='top'>";
+               $output .= "{$blog->blogname}";
+               $output .= "</td>";
+               $output .= "<td valign='top'>";
+               $output .= "<a href='" . esc_url( get_admin_url( $blog->userblog_id ) ) . "'>" . __( 'Visit Dashboard' ) . "</a> | <a href='" . esc_url( get_home_url( $blog->userblog_id ) ). "'>" . __( 'View Site' ) . "</a>" ;
+               $output .= "</td>";
+               $output .= "</tr>";
        }
-       exit;
+       $output .= '</table>';
+
+       wp_die( $output );
 }
-add_action( 'admin_page_access_denied', 'redirect_user_to_blog', 99 );
+add_action( 'admin_page_access_denied', '_access_denied_splash', 99 );
 
 function check_import_new_users( $permission ) {
        if ( !is_super_admin() )