Make WordPress Core

Changeset 18562


Ignore:
Timestamp:
08/18/2011 02:29:06 AM (14 years ago)
Author:
nacin
Message:

Dissolve wp-admin/network/edit.php. props PeteMall, fixes #18379.

Location:
trunk/wp-admin
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/class-wp-ms-sites-list-table.php

    r18442 r18562  
    249249                            if ( $current_site->blog_id != $blog['blog_id'] ) {
    250250                                if ( get_blog_status( $blog['blog_id'], 'deleted' ) == '1' )
    251                                     $actions['activate']    = '<span class="activate"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'edit.php?action=confirm&amp;action2=activateblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to activate the site %s' ), $blogname ) ) ), 'confirm' ) ) . '">' . __( 'Activate' ) . '</a></span>';
     251                                    $actions['activate']    = '<span class="activate"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=activateblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to activate the site %s' ), $blogname ) ) ), 'confirm' ) ) . '">' . __( 'Activate' ) . '</a></span>';
    252252                                else
    253                                     $actions['deactivate']  = '<span class="activate"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'edit.php?action=confirm&amp;action2=deactivateblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to deactivate the site %s' ), $blogname ) ) ), 'confirm') ) . '">' . __( 'Deactivate' ) . '</a></span>';
     253                                    $actions['deactivate']  = '<span class="activate"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=deactivateblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to deactivate the site %s' ), $blogname ) ) ), 'confirm') ) . '">' . __( 'Deactivate' ) . '</a></span>';
    254254
    255255                                if ( get_blog_status( $blog['blog_id'], 'archived' ) == '1' )
    256                                     $actions['unarchive']   = '<span class="archive"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'edit.php?action=confirm&amp;action2=unarchiveblog&amp;id=' .  $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to unarchive the site %s.' ), $blogname ) ) ), 'confirm') ) . '">' . __( 'Unarchive' ) . '</a></span>';
     256                                    $actions['unarchive']   = '<span class="archive"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=unarchiveblog&amp;id=' .  $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to unarchive the site %s.' ), $blogname ) ) ), 'confirm') ) . '">' . __( 'Unarchive' ) . '</a></span>';
    257257                                else
    258                                     $actions['archive'] = '<span class="archive"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'edit.php?action=confirm&amp;action2=archiveblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to archive the site %s.' ), $blogname ) ) ), 'confirm') ) . '">' . _x( 'Archive', 'verb; site' ) . '</a></span>';
     258                                    $actions['archive'] = '<span class="archive"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=archiveblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to archive the site %s.' ), $blogname ) ) ), 'confirm') ) . '">' . _x( 'Archive', 'verb; site' ) . '</a></span>';
    259259
    260260                                if ( get_blog_status( $blog['blog_id'], 'spam' ) == '1' )
    261                                     $actions['unspam']  = '<span class="spam"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'edit.php?action=confirm&amp;action2=unspamblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to unspam the site %s.' ), $blogname ) ) ), 'confirm') ) . '">' . _x( 'Not Spam', 'site' ) . '</a></span>';
     261                                    $actions['unspam']  = '<span class="spam"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=unspamblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to unspam the site %s.' ), $blogname ) ) ), 'confirm') ) . '">' . _x( 'Not Spam', 'site' ) . '</a></span>';
    262262                                else
    263                                     $actions['spam']    = '<span class="spam"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'edit.php?action=confirm&amp;action2=spamblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to mark the site %s as spam.' ), $blogname ) ) ), 'confirm') ) . '">' . _x( 'Spam', 'site' ) . '</a></span>';
     263                                    $actions['spam']    = '<span class="spam"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=spamblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to mark the site %s as spam.' ), $blogname ) ) ), 'confirm') ) . '">' . _x( 'Spam', 'site' ) . '</a></span>';
    264264
    265265                                if ( current_user_can( 'delete_site', $blog['blog_id'] ) )
    266                                     $actions['delete']  = '<span class="delete"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'edit.php?action=confirm&amp;action2=deleteblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to delete the site %s.' ), $blogname ) ) ), 'confirm') ) . '">' . __( 'Delete' ) . '</a></span>';
     266                                    $actions['delete']  = '<span class="delete"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=deleteblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to delete the site %s.' ), $blogname ) ) ), 'confirm') ) . '">' . __( 'Delete' ) . '</a></span>';
    267267                            }
    268268
  • trunk/wp-admin/includes/class-wp-ms-users-list-table.php

    r18254 r18562  
    189189                                $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
    190190
    191                                 if ( current_user_can( 'delete_user', $user->ID) && ! in_array( $user->user_login, $super_admins ) ) {
    192                                     $actions['delete'] = '<a href="' . $delete = esc_url( network_admin_url( add_query_arg( '_wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ), wp_nonce_url( 'edit.php', 'deleteuser' ) . '&amp;action=deleteuser&amp;id=' . $user->ID ) ) ) . '" class="delete">' . __( 'Delete' ) . '</a>';
     191                                if ( current_user_can( 'delete_user', $user->ID ) && ! in_array( $user->user_login, $super_admins ) ) {
     192                                    $actions['delete'] = '<a href="' . $delete = esc_url( network_admin_url( add_query_arg( '_wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ), wp_nonce_url( 'users.php', 'deleteuser' ) . '&amp;action=deleteuser&amp;id=' . $user->ID ) ) ) . '" class="delete">' . __( 'Delete' ) . '</a>';
    193193                                }
    194194
  • trunk/wp-admin/network/edit.php

    r18536 r18562  
    1919}
    2020
    21 function confirm_delete_users( $users ) {
    22     $current_user = wp_get_current_user();
    23     if ( !is_array( $users ) )
    24         return false;
    25 
    26     screen_icon();
    27     ?>
    28     <h2><?php esc_html_e( 'Users' ); ?></h2>
    29     <p><?php _e( 'Transfer or delete posts and links before deleting users.' ); ?></p>
    30     <form action="edit.php?action=dodelete" method="post">
    31     <input type="hidden" name="dodelete" />
    32     <?php
    33     wp_nonce_field( 'ms-users-delete' );
    34     $site_admins = get_super_admins();
    35     $admin_out = "<option value='$current_user->ID'>$current_user->user_login</option>";
    36 
    37     foreach ( ( $allusers = (array) $_POST['allusers'] ) as $key => $val ) {
    38         if ( $val != '' && $val != '0' ) {
    39             $delete_user = new WP_User( $val );
    40 
    41             if ( ! current_user_can( 'delete_user', $delete_user->ID ) )
    42                 wp_die( sprintf( __( 'Warning! User %s cannot be deleted.' ), $delete_user->user_login ) );
    43 
    44             if ( in_array( $delete_user->user_login, $site_admins ) )
    45                 wp_die( sprintf( __( 'Warning! User cannot be deleted. The user %s is a network admnistrator.' ), $delete_user->user_login ) );
    46 
    47             echo "<input type='hidden' name='user[]' value='{$val}'/>\n";
    48             $blogs = get_blogs_of_user( $val, true );
    49 
    50             if ( !empty( $blogs ) ) {
    51                 ?>
    52                 <br /><fieldset><p><legend><?php printf( __( "What should be done with posts and links owned by <em>%s</em>?" ), $delete_user->user_login ); ?></legend></p>
    53                 <?php
    54                 foreach ( (array) $blogs as $key => $details ) {
    55                     $blog_users = get_users( array( 'blog_id' => $details->userblog_id ) );
    56                     if ( is_array( $blog_users ) && !empty( $blog_users ) ) {
    57                         $user_site = "<a href='" . esc_url( get_home_url( $details->userblog_id ) ) . "'>{$details->blogname}</a>";
    58                         $user_dropdown = "<select name='blog[$val][{$key}]'>";
    59                         $user_list = '';
    60                         foreach ( $blog_users as $user ) {
    61                             if ( ! in_array( $user->ID, $allusers ) )
    62                                 $user_list .= "<option value='{$user->ID}'>{$user->user_login}</option>";
    63                         }
    64                         if ( '' == $user_list )
    65                             $user_list = $admin_out;
    66                         $user_dropdown .= $user_list;
    67                         $user_dropdown .= "</select>\n";
    68                         ?>
    69                         <ul style="list-style:none;">
    70                             <li><?php printf( __( 'Site: %s' ), $user_site ); ?></li>
    71                             <li><label><input type="radio" id="delete_option0" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="delete" checked="checked" />
    72                             <?php _e( 'Delete all posts and links.' ); ?></label></li>
    73                             <li><label><input type="radio" id="delete_option1" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="reassign" />
    74                             <?php echo __( 'Attribute all posts and links to:' ) . '</label>' . $user_dropdown; ?></li>
    75                         </ul>
    76                         <?php
    77                     }
    78                 }
    79                 echo "</fieldset>";
    80             }
    81         }
    82     }
    83 
    84     submit_button( __('Confirm Deletion'), 'delete' );
    85     ?>
    86     </form>
    87     <?php
    88     return true;
    89 }
    90 
    9121do_action( 'wpmuadminedit' , '');
    9222
    93 if ( isset( $_GET['id' ]) )
    94     $id = intval( $_GET['id'] );
    95 elseif ( isset( $_POST['id'] ) )
    96     $id = intval( $_POST['id'] );
     23// Let plugins use us as a post handler easily
     24do_action( 'network_admin_edit_' . $_GET['action'] );
     25wp_redirect( network_admin_url( 'index.php' ) );
     26exit();
    9727
    98 switch ( $_GET['action'] ) {
    99     case 'updateblog':
    100         // No longer used.
    101     break;
    102 
    103     case 'deleteblog':
    104         check_admin_referer('deleteblog');
    105         if ( ! ( current_user_can( 'manage_sites' ) && current_user_can( 'delete_sites' ) ) )
    106             wp_die( __( 'You do not have permission to access this page.' ) );
    107 
    108         if ( $id != '0' && $id != $current_site->blog_id && current_user_can( 'delete_site', $id ) ) {
    109             wpmu_delete_blog( $id, true );
    110             wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'delete' ), wp_get_referer() ) );
    111         } else {
    112             wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'not_deleted' ), wp_get_referer() ) );
    113         }
    114 
    115         exit();
    116     break;
    117 
    118     case 'allblogs':
    119         if ( ( isset( $_POST['action'] ) || isset( $_POST['action2'] ) ) && isset( $_POST['allblogs'] ) ) {
    120             check_admin_referer( 'bulk-sites' );
    121 
    122             if ( ! current_user_can( 'manage_sites' ) )
    123                 wp_die( __( 'You do not have permission to access this page.' ) );
    124 
    125             if ( $_GET['action'] != -1 || $_POST['action2'] != -1 )
    126                 $doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2'];
    127 
    128             $blogfunction = '';
    129 
    130             foreach ( (array) $_POST['allblogs'] as $key => $val ) {
    131                 if ( $val != '0' && $val != $current_site->blog_id ) {
    132                     switch ( $doaction ) {
    133                         case 'delete':
    134                             if ( ! current_user_can( 'delete_site', $val ) )
    135                                 wp_die( __( 'You are not allowed to delete the site.' ) );
    136                             $blogfunction = 'all_delete';
    137                             wpmu_delete_blog( $val, true );
    138                         break;
    139 
    140                         case 'spam':
    141                             $blogfunction = 'all_spam';
    142                             update_blog_status( $val, 'spam', '1' );
    143                             set_time_limit( 60 );
    144                         break;
    145 
    146                         case 'notspam':
    147                             $blogfunction = 'all_notspam';
    148                             update_blog_status( $val, 'spam', '0' );
    149                             set_time_limit( 60 );
    150                         break;
    151                     }
    152                 } else {
    153                     wp_die( __( 'You are not allowed to change the current site.' ) );
    154                 }
    155             }
    156 
    157             wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $blogfunction ), wp_get_referer() ) );
    158         } else {
    159             wp_redirect( network_admin_url( 'sites.php' ) );
    160         }
    161         exit();
    162     break;
    163 
    164     case 'archiveblog':
    165         check_admin_referer( 'archiveblog' );
    166         if ( ! current_user_can( 'manage_sites' ) )
    167             wp_die( __( 'You do not have permission to access this page.' ) );
    168 
    169         update_blog_status( $id, 'archived', '1' );
    170         wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'archive' ), wp_get_referer() ) );
    171         exit();
    172     break;
    173 
    174     case 'unarchiveblog':
    175         check_admin_referer( 'unarchiveblog' );
    176         if ( ! current_user_can( 'manage_sites' ) )
    177             wp_die( __( 'You do not have permission to access this page.' ) );
    178 
    179         update_blog_status( $id, 'archived', '0' );
    180         wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'unarchive' ), wp_get_referer() ) );
    181         exit();
    182     break;
    183 
    184     case 'activateblog':
    185         check_admin_referer( 'activateblog' );
    186         if ( ! current_user_can( 'manage_sites' ) )
    187             wp_die( __( 'You do not have permission to access this page.' ) );
    188 
    189         update_blog_status( $id, 'deleted', '0' );
    190         do_action( 'activate_blog', $id );
    191         wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'activate' ), wp_get_referer() ) );
    192         exit();
    193     break;
    194 
    195     case 'deactivateblog':
    196         check_admin_referer( 'deactivateblog' );
    197         if ( ! current_user_can( 'manage_sites' ) )
    198             wp_die( __( 'You do not have permission to access this page.' ) );
    199 
    200         do_action( 'deactivate_blog', $id );
    201         update_blog_status( $id, 'deleted', '1' );
    202         wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'deactivate' ), wp_get_referer() ) );
    203         exit();
    204     break;
    205 
    206     case 'unspamblog':
    207         check_admin_referer( 'unspamblog' );
    208         if ( ! current_user_can( 'manage_sites' ) )
    209             wp_die( __( 'You do not have permission to access this page.' ) );
    210 
    211         update_blog_status( $id, 'spam', '0' );
    212         wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'unspam' ), wp_get_referer() ) );
    213         exit();
    214     break;
    215 
    216     case 'spamblog':
    217         check_admin_referer( 'spamblog' );
    218         if ( ! current_user_can( 'manage_sites' ) )
    219             wp_die( __( 'You do not have permission to access this page.' ) );
    220 
    221         update_blog_status( $id, 'spam', '1' );
    222         wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'spam' ), wp_get_referer() ) );
    223         exit();
    224     break;
    225 
    226     case 'unmatureblog':
    227         check_admin_referer( 'unmatureblog' );
    228         if ( ! current_user_can( 'manage_sites' ) )
    229             wp_die( __( 'You do not have permission to access this page.' ) );
    230 
    231         update_blog_status( $id, 'mature', '0' );
    232         wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'unmature' ), wp_get_referer() ) );
    233         exit();
    234     break;
    235 
    236     case 'matureblog':
    237         check_admin_referer( 'matureblog' );
    238         if ( ! current_user_can( 'manage_sites' ) )
    239             wp_die( __( 'You do not have permission to access this page.' ) );
    240 
    241         update_blog_status( $id, 'mature', '1' );
    242         wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'mature' ), wp_get_referer() ) );
    243         exit();
    244     break;
    245 
    246     // Common
    247     case 'confirm':
    248         check_admin_referer( 'confirm' );
    249         if ( !headers_sent() ) {
    250             nocache_headers();
    251             header( 'Content-Type: text/html; charset=utf-8' );
    252         }
    253         if ( $current_site->blog_id == $id )
    254             wp_die( __( 'You are not allowed to change the current site.' ) );
    255         ?>
    256         <!DOCTYPE html>
    257         <html xmlns="http://www.w3.org/1999/xhtml" <?php if ( function_exists( 'language_attributes' ) ) language_attributes(); ?>>
    258             <head>
    259                 <title><?php _e( 'WordPress &rsaquo; Confirm your action' ); ?></title>
    260 
    261                 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    262                 <?php
    263                 wp_admin_css( 'install', true );
    264                 wp_admin_css( 'ie', true );
    265                 ?>
    266             </head>
    267             <body>
    268                 <h1 id="logo"><img alt="WordPress" src="<?php echo esc_attr( admin_url( 'images/wordpress-logo.png' ) ); ?>" /></h1>
    269                 <form action="edit.php?action=<?php echo esc_attr( $_GET['action2'] ) ?>" method="post">
    270                     <input type="hidden" name="action" value="<?php echo esc_attr( $_GET['action2'] ) ?>" />
    271                     <input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" />
    272                     <input type="hidden" name="_wp_http_referer" value="<?php echo esc_attr( wp_get_referer() ); ?>" />
    273                     <?php wp_nonce_field( $_GET['action2'], '_wpnonce', false ); ?>
    274                     <p><?php echo esc_html( stripslashes( $_GET['msg'] ) ); ?></p>
    275                     <?php submit_button( __('Confirm'), 'button' ); ?>
    276                 </form>
    277             </body>
    278         </html>
    279         <?php
    280         exit();
    281     break;
    282 
    283     // Users
    284     case 'deleteuser':
    285         if ( ! current_user_can( 'manage_network_users' ) )
    286             wp_die( __( 'You do not have permission to access this page.' ) );
    287 
    288         check_admin_referer( 'deleteuser' );
    289 
    290         if ( $id != '0' && $id != '1' ) {
    291             $_POST['allusers'] = array( $id ); // confirm_delete_users() can only handle with arrays
    292             $title = __( 'Users' );
    293             $parent_file = 'users.php';
    294             require_once( '../admin-header.php' );
    295             echo '<div class="wrap">';
    296             confirm_delete_users( $_POST['allusers'] );
    297             echo '</div>';
    298             require_once( '../admin-footer.php' );
    299         } else {
    300             wp_redirect( network_admin_url( 'users.php' ) );
    301         }
    302         exit();
    303     break;
    304 
    305     case 'allusers':
    306         if ( !current_user_can( 'manage_network_users' ) )
    307             wp_die( __( 'You do not have permission to access this page.' ) );
    308 
    309         if ( ( isset( $_POST['action']) || isset($_POST['action2'] ) ) && isset( $_POST['allusers'] ) ) {
    310             check_admin_referer( 'bulk-users-network' );
    311 
    312             if ( $_GET['action'] != -1 || $_POST['action2'] != -1 )
    313                 $doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2'];
    314 
    315             $userfunction = '';
    316 
    317             foreach ( (array) $_POST['allusers'] as $key => $val ) {
    318                 if ( !empty( $val ) ) {
    319                     switch ( $doaction ) {
    320                         case 'delete':
    321                             if ( ! current_user_can( 'delete_users' ) )
    322                                 wp_die( __( 'You do not have permission to access this page.' ) );
    323                             $title = __( 'Users' );
    324                             $parent_file = 'users.php';
    325                             require_once( '../admin-header.php' );
    326                             echo '<div class="wrap">';
    327                             confirm_delete_users( $_POST['allusers'] );
    328                             echo '</div>';
    329                             require_once( '../admin-footer.php' );
    330                             exit();
    331                         break;
    332 
    333                         case 'spam':
    334                             $user = new WP_User( $val );
    335                             if ( in_array( $user->user_login, get_super_admins() ) )
    336                                 wp_die( sprintf( __( 'Warning! User cannot be modified. The user %s is a network administrator.' ), esc_html( $user->user_login ) ) );
    337 
    338                             $userfunction = 'all_spam';
    339                             $blogs = get_blogs_of_user( $val, true );
    340                             foreach ( (array) $blogs as $key => $details ) {
    341                                 if ( $details->userblog_id != $current_site->blog_id ) // main blog not a spam !
    342                                     update_blog_status( $details->userblog_id, 'spam', '1' );
    343                             }
    344                             update_user_status( $val, 'spam', '1' );
    345                         break;
    346 
    347                         case 'notspam':
    348                             $userfunction = 'all_notspam';
    349                             $blogs = get_blogs_of_user( $val, true );
    350                             foreach ( (array) $blogs as $key => $details )
    351                                 update_blog_status( $details->userblog_id, 'spam', '0' );
    352 
    353                             update_user_status( $val, 'spam', '0' );
    354                         break;
    355                     }
    356                 }
    357             }
    358 
    359             wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $userfunction ), wp_get_referer() ) );
    360         } else {
    361             $location = network_admin_url( 'users.php' );
    362 
    363             if ( ! empty( $_REQUEST['paged'] ) )
    364                 $location = add_query_arg( 'paged', (int) $_REQUEST['paged'], $location );
    365             wp_redirect( $location );
    366         }
    367         exit();
    368     break;
    369 
    370     case 'dodelete':
    371         check_admin_referer( 'ms-users-delete' );
    372         if ( ! ( current_user_can( 'manage_network_users' ) && current_user_can( 'delete_users' ) ) )
    373             wp_die( __( 'You do not have permission to access this page.' ) );
    374 
    375         if ( ! empty( $_POST['blog'] ) && is_array( $_POST['blog'] ) ) {
    376             foreach ( $_POST['blog'] as $id => $users ) {
    377                 foreach ( $users as $blogid => $user_id ) {
    378                     if ( ! current_user_can( 'delete_user', $id ) )
    379                         continue;
    380 
    381                     if ( ! empty( $_POST['delete'] ) && 'reassign' == $_POST['delete'][$blogid][$id] )
    382                         remove_user_from_blog( $id, $blogid, $user_id );
    383                     else
    384                         remove_user_from_blog( $id, $blogid );
    385                 }
    386             }
    387         }
    388         $i = 0;
    389         if ( is_array( $_POST['user'] ) && ! empty( $_POST['user'] ) )
    390             foreach( $_POST['user'] as $id ) {
    391                 if ( ! current_user_can( 'delete_user', $id ) )
    392                     continue;
    393                 wpmu_delete_user( $id );
    394                 $i++;
    395             }
    396 
    397         if ( $i == 1 )
    398             $deletefunction = 'delete';
    399         else
    400             $deletefunction = 'all_delete';
    401 
    402         wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $deletefunction ), network_admin_url( 'users.php' ) ) );
    403         exit();
    404     break;
    405 
    406     default:
    407         // Let plugins use us as a post handler easily
    408         do_action( 'network_admin_edit_' . $_GET['action'] );
    409         wp_redirect( network_admin_url( 'index.php' ) );
    410         exit();
    411     break;
    412 }
    41328?>
  • trunk/wp-admin/network/sites.php

    r18092 r18562  
    4343$id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
    4444
     45if ( isset( $_GET['action'] ) ) {
     46    do_action( 'wpmuadminedit' , '' );
     47
     48    switch ( $_GET['action'] ) {
     49        case 'updateblog':
     50            // No longer used.
     51        break;
     52
     53        case 'deleteblog':
     54            check_admin_referer('deleteblog');
     55            if ( ! ( current_user_can( 'manage_sites' ) && current_user_can( 'delete_sites' ) ) )
     56                wp_die( __( 'You do not have permission to access this page.' ) );
     57
     58            if ( $id != '0' && $id != $current_site->blog_id && current_user_can( 'delete_site', $id ) ) {
     59                wpmu_delete_blog( $id, true );
     60                wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'delete' ), wp_get_referer() ) );
     61            } else {
     62                wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'not_deleted' ), wp_get_referer() ) );
     63            }
     64
     65            exit();
     66        break;
     67
     68        case 'allblogs':
     69            if ( ( isset( $_POST['action'] ) || isset( $_POST['action2'] ) ) && isset( $_POST['allblogs'] ) ) {
     70                check_admin_referer( 'bulk-sites' );
     71
     72                if ( ! current_user_can( 'manage_sites' ) )
     73                    wp_die( __( 'You do not have permission to access this page.' ) );
     74
     75                if ( $_GET['action'] != -1 || $_POST['action2'] != -1 )
     76                    $doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2'];
     77
     78                $blogfunction = '';
     79
     80                foreach ( (array) $_POST['allblogs'] as $key => $val ) {
     81                    if ( $val != '0' && $val != $current_site->blog_id ) {
     82                        switch ( $doaction ) {
     83                            case 'delete':
     84                                if ( ! current_user_can( 'delete_site', $val ) )
     85                                    wp_die( __( 'You are not allowed to delete the site.' ) );
     86                                $blogfunction = 'all_delete';
     87                                wpmu_delete_blog( $val, true );
     88                            break;
     89
     90                            case 'spam':
     91                                $blogfunction = 'all_spam';
     92                                update_blog_status( $val, 'spam', '1' );
     93                                set_time_limit( 60 );
     94                            break;
     95
     96                            case 'notspam':
     97                                $blogfunction = 'all_notspam';
     98                                update_blog_status( $val, 'spam', '0' );
     99                                set_time_limit( 60 );
     100                            break;
     101                        }
     102                    } else {
     103                        wp_die( __( 'You are not allowed to change the current site.' ) );
     104                    }
     105                }
     106
     107                wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $blogfunction ), wp_get_referer() ) );
     108            } else {
     109                wp_redirect( network_admin_url( 'sites.php' ) );
     110            }
     111            exit();
     112        break;
     113
     114        case 'archiveblog':
     115            check_admin_referer( 'archiveblog' );
     116            if ( ! current_user_can( 'manage_sites' ) )
     117                wp_die( __( 'You do not have permission to access this page.' ) );
     118
     119            update_blog_status( $id, 'archived', '1' );
     120            wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'archive' ), wp_get_referer() ) );
     121            exit();
     122        break;
     123
     124        case 'unarchiveblog':
     125            check_admin_referer( 'unarchiveblog' );
     126            if ( ! current_user_can( 'manage_sites' ) )
     127                wp_die( __( 'You do not have permission to access this page.' ) );
     128
     129            update_blog_status( $id, 'archived', '0' );
     130            wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'unarchive' ), wp_get_referer() ) );
     131            exit();
     132        break;
     133
     134        case 'activateblog':
     135            check_admin_referer( 'activateblog' );
     136            if ( ! current_user_can( 'manage_sites' ) )
     137                wp_die( __( 'You do not have permission to access this page.' ) );
     138
     139            update_blog_status( $id, 'deleted', '0' );
     140            do_action( 'activate_blog', $id );
     141            wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'activate' ), wp_get_referer() ) );
     142            exit();
     143        break;
     144
     145        case 'deactivateblog':
     146            check_admin_referer( 'deactivateblog' );
     147            if ( ! current_user_can( 'manage_sites' ) )
     148                wp_die( __( 'You do not have permission to access this page.' ) );
     149
     150            do_action( 'deactivate_blog', $id );
     151            update_blog_status( $id, 'deleted', '1' );
     152            wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'deactivate' ), wp_get_referer() ) );
     153            exit();
     154        break;
     155
     156        case 'unspamblog':
     157            check_admin_referer( 'unspamblog' );
     158            if ( ! current_user_can( 'manage_sites' ) )
     159                wp_die( __( 'You do not have permission to access this page.' ) );
     160
     161            update_blog_status( $id, 'spam', '0' );
     162            wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'unspam' ), wp_get_referer() ) );
     163            exit();
     164        break;
     165
     166        case 'spamblog':
     167            check_admin_referer( 'spamblog' );
     168            if ( ! current_user_can( 'manage_sites' ) )
     169                wp_die( __( 'You do not have permission to access this page.' ) );
     170
     171            update_blog_status( $id, 'spam', '1' );
     172            wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'spam' ), wp_get_referer() ) );
     173            exit();
     174        break;
     175
     176        case 'unmatureblog':
     177            check_admin_referer( 'unmatureblog' );
     178            if ( ! current_user_can( 'manage_sites' ) )
     179                wp_die( __( 'You do not have permission to access this page.' ) );
     180
     181            update_blog_status( $id, 'mature', '0' );
     182            wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'unmature' ), wp_get_referer() ) );
     183            exit();
     184        break;
     185
     186        case 'matureblog':
     187            check_admin_referer( 'matureblog' );
     188            if ( ! current_user_can( 'manage_sites' ) )
     189                wp_die( __( 'You do not have permission to access this page.' ) );
     190
     191            update_blog_status( $id, 'mature', '1' );
     192            wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'mature' ), wp_get_referer() ) );
     193            exit();
     194        break;
     195
     196        // Common
     197        case 'confirm':
     198            check_admin_referer( 'confirm' );
     199            if ( !headers_sent() ) {
     200                nocache_headers();
     201                header( 'Content-Type: text/html; charset=utf-8' );
     202            }
     203            if ( $current_site->blog_id == $id )
     204                wp_die( __( 'You are not allowed to change the current site.' ) );
     205            ?>
     206            <!DOCTYPE html>
     207            <html xmlns="http://www.w3.org/1999/xhtml" <?php if ( function_exists( 'language_attributes' ) ) language_attributes(); ?>>
     208                <head>
     209                    <title><?php _e( 'WordPress &rsaquo; Confirm your action' ); ?></title>
     210
     211                    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     212                    <?php
     213                    wp_admin_css( 'install', true );
     214                    wp_admin_css( 'ie', true );
     215                    ?>
     216                </head>
     217                <body>
     218                    <h1 id="logo"><img alt="WordPress" src="<?php echo esc_attr( admin_url( 'images/wordpress-logo.png' ) ); ?>" /></h1>
     219                    <form action="sites.php?action=<?php echo esc_attr( $_GET['action2'] ) ?>" method="post">
     220                        <input type="hidden" name="action" value="<?php echo esc_attr( $_GET['action2'] ) ?>" />
     221                        <input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" />
     222                        <input type="hidden" name="_wp_http_referer" value="<?php echo esc_attr( wp_get_referer() ); ?>" />
     223                        <?php wp_nonce_field( $_GET['action2'], '_wpnonce', false ); ?>
     224                        <p><?php echo esc_html( stripslashes( $_GET['msg'] ) ); ?></p>
     225                        <?php submit_button( __('Confirm'), 'button' ); ?>
     226                    </form>
     227                </body>
     228            </html>
     229            <?php
     230            exit();
     231        break;
     232    }
     233}
     234
    45235$msg = '';
    46236if ( isset( $_REQUEST['updated'] ) && $_REQUEST['updated'] == 'true' && ! empty( $_REQUEST['action'] ) ) {
     
    110300</form>
    111301
    112 <form id="form-site-list" action="edit.php?action=allblogs" method="post">
     302<form id="form-site-list" action="sites.php?action=allblogs" method="post">
    113303    <?php $wp_list_table->display(); ?>
    114304</form>
  • trunk/wp-admin/network/users.php

    r17872 r18562  
    1616if ( ! current_user_can( 'manage_network_users' ) )
    1717    wp_die( __( 'You do not have permission to access this page.' ) );
     18
     19function confirm_delete_users( $users ) {
     20    $current_user = wp_get_current_user();
     21    if ( !is_array( $users ) )
     22        return false;
     23
     24    screen_icon();
     25    ?>
     26    <h2><?php esc_html_e( 'Users' ); ?></h2>
     27    <p><?php _e( 'Transfer or delete posts and links before deleting users.' ); ?></p>
     28    <form action="users.php?action=dodelete" method="post">
     29    <input type="hidden" name="dodelete" />
     30    <?php
     31    wp_nonce_field( 'ms-users-delete' );
     32    $site_admins = get_super_admins();
     33    $admin_out = "<option value='$current_user->ID'>$current_user->user_login</option>";
     34
     35    foreach ( ( $allusers = (array) $_POST['allusers'] ) as $key => $val ) {
     36        if ( $val != '' && $val != '0' ) {
     37            $delete_user = new WP_User( $val );
     38
     39            if ( ! current_user_can( 'delete_user', $delete_user->ID ) )
     40                wp_die( sprintf( __( 'Warning! User %s cannot be deleted.' ), $delete_user->user_login ) );
     41
     42            if ( in_array( $delete_user->user_login, $site_admins ) )
     43                wp_die( sprintf( __( 'Warning! User cannot be deleted. The user %s is a network admnistrator.' ), $delete_user->user_login ) );
     44
     45            echo "<input type='hidden' name='user[]' value='{$val}'/>\n";
     46            $blogs = get_blogs_of_user( $val, true );
     47
     48            if ( !empty( $blogs ) ) {
     49                ?>
     50                <br /><fieldset><p><legend><?php printf( __( "What should be done with posts and links owned by <em>%s</em>?" ), $delete_user->user_login ); ?></legend></p>
     51                <?php
     52                foreach ( (array) $blogs as $key => $details ) {
     53                    $blog_users = get_users( array( 'blog_id' => $details->userblog_id ) );
     54                    if ( is_array( $blog_users ) && !empty( $blog_users ) ) {
     55                        $user_site = "<a href='" . esc_url( get_home_url( $details->userblog_id ) ) . "'>{$details->blogname}</a>";
     56                        $user_dropdown = "<select name='blog[$val][{$key}]'>";
     57                        $user_list = '';
     58                        foreach ( $blog_users as $user ) {
     59                            if ( ! in_array( $user->ID, $allusers ) )
     60                                $user_list .= "<option value='{$user->ID}'>{$user->user_login}</option>";
     61                        }
     62                        if ( '' == $user_list )
     63                            $user_list = $admin_out;
     64                        $user_dropdown .= $user_list;
     65                        $user_dropdown .= "</select>\n";
     66                        ?>
     67                        <ul style="list-style:none;">
     68                            <li><?php printf( __( 'Site: %s' ), $user_site ); ?></li>
     69                            <li><label><input type="radio" id="delete_option0" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="delete" checked="checked" />
     70                            <?php _e( 'Delete all posts and links.' ); ?></label></li>
     71                            <li><label><input type="radio" id="delete_option1" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="reassign" />
     72                            <?php echo __( 'Attribute all posts and links to:' ) . '</label>' . $user_dropdown; ?></li>
     73                        </ul>
     74                        <?php
     75                    }
     76                }
     77                echo "</fieldset>";
     78            }
     79        }
     80    }
     81
     82    submit_button( __('Confirm Deletion'), 'delete' );
     83    ?>
     84    </form>
     85    <?php
     86    return true;
     87}
     88
     89if ( isset( $_GET['action'] ) ) {
     90    do_action( 'wpmuadminedit' , '' );
     91
     92    switch ( $_GET['action'] ) {
     93        case 'deleteuser':
     94            if ( ! current_user_can( 'manage_network_users' ) )
     95                wp_die( __( 'You do not have permission to access this page.' ) );
     96
     97            check_admin_referer( 'deleteuser' );
     98
     99            $id = intval( $_GET['id'] );
     100            if ( $id != '0' && $id != '1' ) {
     101                $_POST['allusers'] = array( $id ); // confirm_delete_users() can only handle with arrays
     102                $title = __( 'Users' );
     103                $parent_file = 'users.php';
     104                require_once( '../admin-header.php' );
     105                echo '<div class="wrap">';
     106                confirm_delete_users( $_POST['allusers'] );
     107                echo '</div>';
     108                require_once( '../admin-footer.php' );
     109            } else {
     110                wp_redirect( network_admin_url( 'users.php' ) );
     111            }
     112            exit();
     113        break;
     114
     115        case 'allusers':
     116            if ( !current_user_can( 'manage_network_users' ) )
     117                wp_die( __( 'You do not have permission to access this page.' ) );
     118
     119            if ( ( isset( $_POST['action']) || isset($_POST['action2'] ) ) && isset( $_POST['allusers'] ) ) {
     120                check_admin_referer( 'bulk-users-network' );
     121
     122                if ( $_GET['action'] != -1 || $_POST['action2'] != -1 )
     123                    $doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2'];
     124
     125                $userfunction = '';
     126
     127                foreach ( (array) $_POST['allusers'] as $key => $val ) {
     128                    if ( !empty( $val ) ) {
     129                        switch ( $doaction ) {
     130                            case 'delete':
     131                                if ( ! current_user_can( 'delete_users' ) )
     132                                    wp_die( __( 'You do not have permission to access this page.' ) );
     133                                $title = __( 'Users' );
     134                                $parent_file = 'users.php';
     135                                require_once( '../admin-header.php' );
     136                                echo '<div class="wrap">';
     137                                confirm_delete_users( $_POST['allusers'] );
     138                                echo '</div>';
     139                                require_once( '../admin-footer.php' );
     140                                exit();
     141                            break;
     142
     143                            case 'spam':
     144                                $user = new WP_User( $val );
     145                                if ( in_array( $user->user_login, get_super_admins() ) )
     146                                    wp_die( sprintf( __( 'Warning! User cannot be modified. The user %s is a network administrator.' ), esc_html( $user->user_login ) ) );
     147
     148                                $userfunction = 'all_spam';
     149                                $blogs = get_blogs_of_user( $val, true );
     150                                foreach ( (array) $blogs as $key => $details ) {
     151                                    if ( $details->userblog_id != $current_site->blog_id ) // main blog not a spam !
     152                                        update_blog_status( $details->userblog_id, 'spam', '1' );
     153                                }
     154                                update_user_status( $val, 'spam', '1' );
     155                            break;
     156
     157                            case 'notspam':
     158                                $userfunction = 'all_notspam';
     159                                $blogs = get_blogs_of_user( $val, true );
     160                                foreach ( (array) $blogs as $key => $details )
     161                                    update_blog_status( $details->userblog_id, 'spam', '0' );
     162
     163                                update_user_status( $val, 'spam', '0' );
     164                            break;
     165                        }
     166                    }
     167                }
     168
     169                wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $userfunction ), wp_get_referer() ) );
     170            } else {
     171                $location = network_admin_url( 'users.php' );
     172
     173                if ( ! empty( $_REQUEST['paged'] ) )
     174                    $location = add_query_arg( 'paged', (int) $_REQUEST['paged'], $location );
     175                wp_redirect( $location );
     176            }
     177            exit();
     178        break;
     179
     180        case 'dodelete':
     181            check_admin_referer( 'ms-users-delete' );
     182            if ( ! ( current_user_can( 'manage_network_users' ) && current_user_can( 'delete_users' ) ) )
     183                wp_die( __( 'You do not have permission to access this page.' ) );
     184
     185            if ( ! empty( $_POST['blog'] ) && is_array( $_POST['blog'] ) ) {
     186                foreach ( $_POST['blog'] as $id => $users ) {
     187                    foreach ( $users as $blogid => $user_id ) {
     188                        if ( ! current_user_can( 'delete_user', $id ) )
     189                            continue;
     190
     191                        if ( ! empty( $_POST['delete'] ) && 'reassign' == $_POST['delete'][$blogid][$id] )
     192                            remove_user_from_blog( $id, $blogid, $user_id );
     193                        else
     194                            remove_user_from_blog( $id, $blogid );
     195                    }
     196                }
     197            }
     198            $i = 0;
     199            if ( is_array( $_POST['user'] ) && ! empty( $_POST['user'] ) )
     200                foreach( $_POST['user'] as $id ) {
     201                    if ( ! current_user_can( 'delete_user', $id ) )
     202                        continue;
     203                    wpmu_delete_user( $id );
     204                    $i++;
     205                }
     206
     207            if ( $i == 1 )
     208                $deletefunction = 'delete';
     209            else
     210                $deletefunction = 'all_delete';
     211
     212            wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $deletefunction ), network_admin_url( 'users.php' ) ) );
     213            exit();
     214        break; 
     215    }
     216}
    18217
    19218$wp_list_table = _get_list_table('WP_MS_Users_List_Table');
     
    89288    </form>
    90289
    91     <form id="form-user-list" action='edit.php?action=allusers' method='post'>
     290    <form id="form-user-list" action='users.php?action=allusers' method='post'>
    92291        <?php $wp_list_table->display(); ?>
    93292    </form>
Note: See TracChangeset for help on using the changeset viewer.