Make WordPress Core


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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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>
Note: See TracChangeset for help on using the changeset viewer.