]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/network/sites.php
Wordpress 3.3
[autoinstalls/wordpress.git] / wp-admin / network / sites.php
1 <?php
2 /**
3  * Multisite sites administration panel.
4  *
5  * @package WordPress
6  * @subpackage Multisite
7  * @since 3.0.0
8  */
9
10 /** Load WordPress Administration Bootstrap */
11 require_once( './admin.php' );
12
13 if ( ! is_multisite() )
14         wp_die( __( 'Multisite support is not enabled.' ) );
15
16 if ( ! current_user_can( 'manage_sites' ) )
17         wp_die( __( 'You do not have permission to access this page.' ) );
18
19 $wp_list_table = _get_list_table('WP_MS_Sites_List_Table');
20 $pagenum = $wp_list_table->get_pagenum();
21
22 $title = __( 'Sites' );
23 $parent_file = 'sites.php';
24
25 add_screen_option( 'per_page', array('label' => _x( 'Sites', 'sites per page (screen options)' )) );
26
27 get_current_screen()->add_help_tab( array(
28         'id'      => 'overview',
29         'title'   => __('Overview'),
30         'content' =>
31                 '<p>' . __('Add New takes you to the Add New Site screen. You can search for a site by Name, ID number, or IP address. Screen Options allows you to choose how many sites to display on one page.') . '</p>' .
32                 '<p>' . __('This is the main table of all sites on this network. Switch between list and excerpt views by using the icons above the right side of the table.') . '</p>' .
33                 '<p>' . __('Hovering over each site reveals seven options (three for the primary site):') . '</p>' .
34                 '<ul><li>' . __('An Edit link to a separate Edit Site screen.') . '</li>' .
35                 '<li>' . __('Dashboard leads to the Dashboard for that site.') . '</li>' .
36                 '<li>' . __('Deactivate, Archive, and Spam which lead to confirmation screens. These actions can be reversed later.') . '</li>' .
37                 '<li>' . __('Delete which is a permanent action after the confirmation screens.') . '</li>' .
38                 '<li>' . __('Visit to go to the frontend site live.') . '</li></ul>' .
39                 '<p>' . __('The site ID is used internally, and is not shown on the front end of the site or to users/viewers.') . '</p>' .
40                 '<p>' . __('Clicking on bold headings can re-sort this table.') . '</p>'
41 ) );
42
43 get_current_screen()->set_help_sidebar(
44         '<p><strong>' . __('For more information:') . '</strong></p>' .
45         '<p>' . __('<a href="http://codex.wordpress.org/Network_Admin_Sites_Screens" target="_blank">Documentation on Site Management</a>') . '</p>' .
46         '<p>' . __('<a href="http://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>'
47 );
48
49 $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
50
51 if ( isset( $_GET['action'] ) ) {
52         do_action( 'wpmuadminedit' , '' );
53
54         switch ( $_GET['action'] ) {
55                 case 'updateblog':
56                         // No longer used.
57                 break;
58
59                 case 'deleteblog':
60                         check_admin_referer('deleteblog');
61                         if ( ! ( current_user_can( 'manage_sites' ) && current_user_can( 'delete_sites' ) ) )
62                                 wp_die( __( 'You do not have permission to access this page.' ) );
63
64                         if ( $id != '0' && $id != $current_site->blog_id && current_user_can( 'delete_site', $id ) ) {
65                                 wpmu_delete_blog( $id, true );
66                                 wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'delete' ), wp_get_referer() ) );
67                         } else {
68                                 wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'not_deleted' ), wp_get_referer() ) );
69                         }
70
71                         exit();
72                 break;
73
74                 case 'allblogs':
75                         if ( ( isset( $_POST['action'] ) || isset( $_POST['action2'] ) ) && isset( $_POST['allblogs'] ) ) {
76                                 check_admin_referer( 'bulk-sites' );
77
78                                 if ( ! current_user_can( 'manage_sites' ) )
79                                         wp_die( __( 'You do not have permission to access this page.' ) );
80
81                                 if ( $_GET['action'] != -1 || $_POST['action2'] != -1 )
82                                         $doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2'];
83
84                                 $blogfunction = '';
85
86                                 foreach ( (array) $_POST['allblogs'] as $key => $val ) {
87                                         if ( $val != '0' && $val != $current_site->blog_id ) {
88                                                 switch ( $doaction ) {
89                                                         case 'delete':
90                                                                 if ( ! current_user_can( 'delete_site', $val ) )
91                                                                         wp_die( __( 'You are not allowed to delete the site.' ) );
92                                                                 $blogfunction = 'all_delete';
93                                                                 wpmu_delete_blog( $val, true );
94                                                         break;
95
96                                                         case 'spam':
97                                                                 $blogfunction = 'all_spam';
98                                                                 update_blog_status( $val, 'spam', '1' );
99                                                                 set_time_limit( 60 );
100                                                         break;
101
102                                                         case 'notspam':
103                                                                 $blogfunction = 'all_notspam';
104                                                                 update_blog_status( $val, 'spam', '0' );
105                                                                 set_time_limit( 60 );
106                                                         break;
107                                                 }
108                                         } else {
109                                                 wp_die( __( 'You are not allowed to change the current site.' ) );
110                                         }
111                                 }
112
113                                 wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $blogfunction ), wp_get_referer() ) );
114                         } else {
115                                 wp_redirect( network_admin_url( 'sites.php' ) );
116                         }
117                         exit();
118                 break;
119
120                 case 'archiveblog':
121                         check_admin_referer( 'archiveblog' );
122                         if ( ! current_user_can( 'manage_sites' ) )
123                                 wp_die( __( 'You do not have permission to access this page.' ) );
124
125                         update_blog_status( $id, 'archived', '1' );
126                         wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'archive' ), wp_get_referer() ) );
127                         exit();
128                 break;
129
130                 case 'unarchiveblog':
131                         check_admin_referer( 'unarchiveblog' );
132                         if ( ! current_user_can( 'manage_sites' ) )
133                                 wp_die( __( 'You do not have permission to access this page.' ) );
134
135                         update_blog_status( $id, 'archived', '0' );
136                         wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'unarchive' ), wp_get_referer() ) );
137                         exit();
138                 break;
139
140                 case 'activateblog':
141                         check_admin_referer( 'activateblog' );
142                         if ( ! current_user_can( 'manage_sites' ) )
143                                 wp_die( __( 'You do not have permission to access this page.' ) );
144
145                         update_blog_status( $id, 'deleted', '0' );
146                         do_action( 'activate_blog', $id );
147                         wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'activate' ), wp_get_referer() ) );
148                         exit();
149                 break;
150
151                 case 'deactivateblog':
152                         check_admin_referer( 'deactivateblog' );
153                         if ( ! current_user_can( 'manage_sites' ) )
154                                 wp_die( __( 'You do not have permission to access this page.' ) );
155
156                         do_action( 'deactivate_blog', $id );
157                         update_blog_status( $id, 'deleted', '1' );
158                         wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'deactivate' ), wp_get_referer() ) );
159                         exit();
160                 break;
161
162                 case 'unspamblog':
163                         check_admin_referer( 'unspamblog' );
164                         if ( ! current_user_can( 'manage_sites' ) )
165                                 wp_die( __( 'You do not have permission to access this page.' ) );
166
167                         update_blog_status( $id, 'spam', '0' );
168                         wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'unspam' ), wp_get_referer() ) );
169                         exit();
170                 break;
171
172                 case 'spamblog':
173                         check_admin_referer( 'spamblog' );
174                         if ( ! current_user_can( 'manage_sites' ) )
175                                 wp_die( __( 'You do not have permission to access this page.' ) );
176
177                         update_blog_status( $id, 'spam', '1' );
178                         wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'spam' ), wp_get_referer() ) );
179                         exit();
180                 break;
181
182                 case 'unmatureblog':
183                         check_admin_referer( 'unmatureblog' );
184                         if ( ! current_user_can( 'manage_sites' ) )
185                                 wp_die( __( 'You do not have permission to access this page.' ) );
186
187                         update_blog_status( $id, 'mature', '0' );
188                         wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'unmature' ), wp_get_referer() ) );
189                         exit();
190                 break;
191
192                 case 'matureblog':
193                         check_admin_referer( 'matureblog' );
194                         if ( ! current_user_can( 'manage_sites' ) )
195                                 wp_die( __( 'You do not have permission to access this page.' ) );
196
197                         update_blog_status( $id, 'mature', '1' );
198                         wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'mature' ), wp_get_referer() ) );
199                         exit();
200                 break;
201
202                 // Common
203                 case 'confirm':
204                         check_admin_referer( 'confirm' );
205                         if ( !headers_sent() ) {
206                                 nocache_headers();
207                                 header( 'Content-Type: text/html; charset=utf-8' );
208                         }
209                         if ( $current_site->blog_id == $id )
210                                 wp_die( __( 'You are not allowed to change the current site.' ) );
211                         ?>
212                         <!DOCTYPE html>
213                         <html xmlns="http://www.w3.org/1999/xhtml" <?php if ( function_exists( 'language_attributes' ) ) language_attributes(); ?>>
214                                 <head>
215                                         <title><?php _e( 'WordPress &rsaquo; Confirm your action' ); ?></title>
216
217                                         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
218                                         <?php
219                                         wp_admin_css( 'install', true );
220                                         wp_admin_css( 'ie', true );
221                                         ?>
222                                 </head>
223                                 <body>
224                                         <h1 id="logo"><img alt="WordPress" src="<?php echo esc_attr( admin_url( 'images/wordpress-logo.png' ) ); ?>" /></h1>
225                                         <form action="sites.php?action=<?php echo esc_attr( $_GET['action2'] ) ?>" method="post">
226                                                 <input type="hidden" name="action" value="<?php echo esc_attr( $_GET['action2'] ) ?>" />
227                                                 <input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" />
228                                                 <input type="hidden" name="_wp_http_referer" value="<?php echo esc_attr( wp_get_referer() ); ?>" />
229                                                 <?php wp_nonce_field( $_GET['action2'], '_wpnonce', false ); ?>
230                                                 <p><?php echo esc_html( stripslashes( $_GET['msg'] ) ); ?></p>
231                                                 <?php submit_button( __('Confirm'), 'button' ); ?>
232                                         </form>
233                                 </body>
234                         </html>
235                         <?php
236                         exit();
237                 break;
238         }
239 }
240
241 $msg = '';
242 if ( isset( $_REQUEST['updated'] ) && $_REQUEST['updated'] == 'true' && ! empty( $_REQUEST['action'] ) ) {
243         switch ( $_REQUEST['action'] ) {
244                 case 'all_notspam':
245                         $msg = __( 'Sites removed from spam.' );
246                 break;
247                 case 'all_spam':
248                         $msg = __( 'Sites marked as spam.' );
249                 break;
250                 case 'all_delete':
251                         $msg = __( 'Sites deleted.' );
252                 break;
253                 case 'delete':
254                         $msg = __( 'Site deleted.' );
255                 break;
256                 case 'not_deleted':
257                         $msg = __( 'You do not have permission to delete that site.' );
258                 break;
259                 case 'archive':
260                         $msg = __( 'Site archived.' );
261                 break;
262                 case 'unarchive':
263                         $msg = __( 'Site unarchived.' );
264                 break;
265                 case 'activate':
266                         $msg = __( 'Site activated.' );
267                 break;
268                 case 'deactivate':
269                         $msg = __( 'Site deactivated.' );
270                 break;
271                 case 'unspam':
272                         $msg = __( 'Site removed from spam.' );
273                 break;
274                 case 'spam':
275                         $msg = __( 'Site marked as spam.' );
276                 break;
277                 default:
278                         $msg = apply_filters( 'network_sites_updated_message_' . $_REQUEST['action'] , __( 'Settings saved.' ) );
279                 break;
280         }
281         if ( $msg )
282                 $msg = '<div class="updated" id="message"><p>' . $msg . '</p></div>';
283 }
284
285 $wp_list_table->prepare_items();
286
287 require_once( '../admin-header.php' );
288 ?>
289
290 <div class="wrap">
291 <?php screen_icon('ms-admin'); ?>
292 <h2><?php _e('Sites') ?>
293 <?php echo $msg; ?>
294 <?php if ( current_user_can( 'create_sites') ) : ?>
295         <a href="<?php echo network_admin_url('site-new.php'); ?>" class="add-new-h2"><?php echo esc_html_x( 'Add New', 'site' ); ?></a>
296 <?php endif; ?>
297
298 <?php if ( isset( $_REQUEST['s'] ) && $_REQUEST['s'] ) {
299         printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( $s ) );
300 } ?>
301 </h2>
302
303 <form action="" method="get" id="ms-search">
304 <?php $wp_list_table->search_box( __( 'Search Sites' ), 'site' ); ?>
305 <input type="hidden" name="action" value="blogs" />
306 </form>
307
308 <form id="form-site-list" action="sites.php?action=allblogs" method="post">
309         <?php $wp_list_table->display(); ?>
310 </form>
311 </div>
312 <?php
313
314 require_once( '../admin-footer.php' ); ?>