From bbae1e98fdbd861cecfc20fa43a799b36f285aff Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 29 Jan 2010 17:36:57 +0000 Subject: [PATCH] ms-sites cleanup. Add escaping. Use API instead of direct queries. Add blog status label to row title. see #11644 git-svn-id: http://svn.automattic.com/wordpress/trunk@12897 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/ms-sites.php | 137 ++++++++++++++++++++++-------------------- 1 file changed, 73 insertions(+), 64 deletions(-) diff --git a/wp-admin/ms-sites.php b/wp-admin/ms-sites.php index f3bb609fa4..06d61a53c8 100644 --- a/wp-admin/ms-sites.php +++ b/wp-admin/ms-sites.php @@ -76,13 +76,13 @@ switch ( $action ) { // Edit blog case "editblog": $blog_prefix = $wpdb->get_blog_prefix( $id ); - $options = $wpdb->get_results( "SELECT * FROM {$blog_prefix}options WHERE option_name NOT LIKE '_transient_rss%' AND option_name NOT LIKE '%user_roles'", ARRAY_A ); - $details = $wpdb->get_row( "SELECT * FROM {$wpdb->blogs} WHERE blog_id = '{$id}'", ARRAY_A ); + $options = $wpdb->get_results( "SELECT * FROM {$blog_prefix}options WHERE option_name NOT LIKE '\_%' AND option_name NOT LIKE '%user_roles'" ); + $details = get_blog_details($id); $editblog_roles = get_blog_option( $id, "{$blog_prefix}user_roles" ); ?>
-

- '>http://

+

- http://domain . $details->path; ?>

@@ -93,54 +93,54 @@ switch ( $action ) { - + - + - + - +
http://http://
-
/>
+
domain . $details->path) || get_blog_option( $id, 'home' ) == preg_replace('|/+$|', '', 'http://' . $details->domain . $details->path) ) echo 'checked="checked"'; ?> />
- /> - /> + public == '1' ) echo 'checked="checked"'; ?> /> + public == '0' ) echo 'checked="checked"'; ?> />
- /> - /> + archived == '1' ) echo 'checked="checked"'; ?> /> + archived == '0' ) echo 'checked="checked"'; ?> />
- /> - /> + mature == '1' ) echo 'checked="checked"'; ?> /> + mature == '0' ) echo 'checked="checked"'; ?> />
- /> - /> + spam == '1' ) echo 'checked="checked"'; ?> /> + spam == '0' ) echo 'checked="checked"'; ?> />
- /> - /> + deleted == '1' ) echo 'checked="checked"'; ?> /> + deleted == '0' ) echo 'checked="checked"'; ?> />
@@ -153,31 +153,30 @@ switch ( $action ) { $val ) { - if ( $val['option_name'] == 'default_role' ) { - $editblog_default_role = $val['option_value']; - } + foreach ( $options as $option ) { + if ( $option->option_name == 'default_role' ) + $editblog_default_role = $option->option_value; $disabled = ''; - if ( is_serialized($val['option_value']) ) { - if ( is_serialized_string($val['option_value']) ) { - $val['option_value'] = wp_specialchars(maybe_unserialize($val['option_value']), 'single'); + if ( is_serialized($option->option_value) ) { + if ( is_serialized_string($option->option_value) ) { + $option->option_value = wp_specialchars(maybe_unserialize($option->option_value), 'single'); } else { - $val['option_value'] = "SERIALIZED DATA"; + $option->option_value = "SERIALIZED DATA"; $disabled = ' disabled="disabled"'; } } - if ( stristr($val['option_value'], "\r") || stristr($val['option_value'], "\n") || stristr($val['option_value'], "\r\n") ) { + if ( stristr($option->option_value, "\r") || stristr($option->option_value, "\n") || stristr($option->option_value, "\r\n") ) { ?> - - + + - - + + $theme ) { + foreach ( $themes as $key => $theme ) { $theme_key = wp_specialchars( $theme['Stylesheet'] ); - if ( isset($allowed_themes[$theme_key] ) == false ) { + if ( ! isset($allowed_themes[$theme_key] ) ) { $checked = ( isset($blog_allowed_themes[ $theme_key ]) ) ? 'checked="checked"' : ''; $out .= ' - - + + '; } } @@ -212,10 +210,10 @@ switch ( $action ) { if ( $out != '' ) { ?>
-

+

option_name ) ) ?>
/>option_name ) ) ?> />
'.$key.'' . __( 'Active' ) . '' . esc_html($key) . '' . __( 'Active' ) . '
- +

@@ -241,7 +239,7 @@ switch ( $action ) { ?> - + '; + echo ''; } else { echo "" . __ ('N/A') . "" . __ ('N/A') . "" . __('N/A') . ""; } @@ -448,22 +446,35 @@ switch ( $action ) { "#fee", "spam" => "#faa", "deleted" => "#f55" ); + $status_list = array( 'archived' => array( '#fee', __('Archived') ), 'spam' => array( '#faa', __('Spam') ), 'deleted' => array( '#f55', __('Deleted') ) ); foreach ( $blog_list as $blog ) { $class = ('alternate' == $class) ? '' : 'alternate'; reset( $status_list ); - $bgcolour = ""; + $bgcolour = ''; + $blog_states = array(); foreach ( $status_list as $status => $col ) { if ( get_blog_status( $blog['blog_id'], $status ) == 1 ) { - $bgcolour = "style='background: $col'"; + $bgcolour = "style='background: {$col[0]}'"; + $blog_states[] = $col[1]; + } + } + $blog_state = ''; + if ( ! empty($blog_states) ) { + $state_count = count($blog_states); + $i = 0; + $blog_state .= ' - '; + foreach ( $blog_states as $state ) { + ++$i; + ( $i == $state_count ) ? $sep = '' : $sep = ', '; + $blog_state .= "$state$sep"; } } echo ""; $blogname = ( is_subdomain_install() ) ? str_replace('.'.$current_site->domain, '', $blog['domain']) : $blog['path']; foreach ( $posts_columns as $column_name=>$column_display_name ) { - switch($column_name) { + switch ( $column_name ) { case 'id': ?> ' name='allblogs[]' value='' /> @@ -476,36 +487,36 @@ switch ( $action ) { case 'blogname': ?> - +
' . __('Edit') . ''; - $controlActions[] = "" . __('Backend') . ''; + $actions = array(); + $actions[] = '' . __('Edit') . ''; + $actions[] = "" . __('Backend') . ''; if ( get_blog_status( $blog['blog_id'], "deleted" ) == '1' ) - $controlActions[] = '' . __('Activate') . ''; + $actions[] = '' . __('Activate') . ''; else - $controlActions[] = '' . __('Deactivate') . ''; + $actions[] = '' . __('Deactivate') . ''; if ( get_blog_status( $blog['blog_id'], "archived" ) == '1' ) - $controlActions[] = '' . __('Unarchive') . ''; + $actions[] = '' . __('Unarchive') . ''; else - $controlActions[] = '' . __('Archive') . ''; + $actions[] = '' . __('Archive') . ''; if ( get_blog_status( $blog['blog_id'], "spam" ) == '1' ) - $controlActions[] = '' . __('Not Spam') . ''; + $actions[] = '' . __('Not Spam') . ''; else - $controlActions[] = '' . __("Spam") . ''; + $actions[] = '' . __("Spam") . ''; - $controlActions[] = '' . __("Delete") . ''; + $actions[] = '' . __("Delete") . ''; - $controlActions[] = "" . __('Visit') . ''; + $actions[] = "" . __('Visit') . ''; ?> - +
- +
@@ -535,12 +546,10 @@ switch ( $action ) { $blogusers = array_slice( $blogusers, 0, 5 ); $blogusers_warning = __( 'Only showing first 5 users.' ) . ' ' . __( 'More' ) . ''; } - foreach ( $blogusers as $key => $val ) { + foreach ( $blogusers as $key => $val ) echo '' . $val->user_login . ' ('.$val->user_email.')
'; - } - if ( $blogusers_warning != '' ) { + if ( $blogusers_warning != '' ) echo '' . $blogusers_warning . '
'; - } } ?>