From e7795c365acf331aaf2f902fe1f27e72ff15775c Mon Sep 17 00:00:00 2001 From: donncha Date: Tue, 13 Feb 2007 15:41:30 +0000 Subject: Added get_user_id_from_string() Make editing a blog much faster git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@884 7be80a69-a1ef-0310-a953-fb0f7c49ff36 --- wp-admin/wpmu-blogs.php | 13 +++---------- wp-admin/wpmu-edit.php | 9 ++++++++- wp-includes/wpmu-functions.php | 18 ++++++++++++++++-- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/wp-admin/wpmu-blogs.php b/wp-admin/wpmu-blogs.php index 11bd3e4..87b1f55 100644 --- a/wp-admin/wpmu-blogs.php +++ b/wp-admin/wpmu-blogs.php @@ -13,16 +13,9 @@ if (isset($_GET['updated'])) { print '
'; switch( $_GET[ 'action' ] ) { case "editblog": - $options_table_name = $wpmuBaseTablePrefix . $_GET[ 'id' ] ."_options"; - $query = "SELECT * - FROM ".$options_table_name." - WHERE option_name NOT LIKE 'rss%' - AND option_name NOT LIKE '%user_roles'"; - $options = $wpdb->get_results( $query, ARRAY_A ); - $query = "SELECT * - FROM ".$wpdb->blogs." - WHERE blog_id = '".$_GET[ 'id' ]."'"; - $details = $wpdb->get_row( $query, ARRAY_A ); + $options_table_name = $wpmuBaseTablePrefix . $_GET[ 'id' ] ."_options"; + $options = $wpdb->get_results( "SELECT * FROM {$options_table_name} WHERE option_name NOT LIKE 'rss%' AND option_name NOT LIKE '%user_roles'", ARRAY_A ); + $details = $wpdb->get_row( "SELECT * FROM {$wpdb->blogs} WHERE blog_id = '{$_GET[ 'id' ]}'", ARRAY_A ); print "

" . __('Edit Blog') . "

"; print "{$details[ 'domain' ]}"; diff --git a/wp-admin/wpmu-edit.php b/wp-admin/wpmu-edit.php index e0168e6..2078ba5 100644 --- a/wp-admin/wpmu-edit.php +++ b/wp-admin/wpmu-edit.php @@ -159,8 +159,15 @@ switch( $_REQUEST[ 'action' ] ) { $_POST[ 'option' ][ 'allowed_themes' ] = ''; } if( is_array( $_POST[ 'option' ] ) ) { + $c = 1; + $count = count( $_POST[ 'option' ] ); while( list( $key, $val ) = each( $_POST[ 'option' ] ) ) { - update_blog_option( $id, $key, $val ); + if( $c == $count ) { + update_blog_option( $id, $key, $val ); + } else { + update_blog_option( $id, $key, $val, false ); // no need to refresh blog details yet + } + $c++; } } // update blogs table diff --git a/wp-includes/wpmu-functions.php b/wp-includes/wpmu-functions.php index d81c36d..4afaecd 100644 --- a/wp-includes/wpmu-functions.php +++ b/wp-includes/wpmu-functions.php @@ -303,11 +303,12 @@ function add_blog_option( $id, $key, $value ) { } -function update_blog_option( $id, $key, $value ) { +function update_blog_option( $id, $key, $value, $refresh = true ) { switch_to_blog($id); $opt = update_option( $key, $value ); restore_current_blog(); - refresh_blog_details( $id ); + if( $refresh == true ) + refresh_blog_details( $id ); } function switch_to_blog( $new_blog ) { @@ -1392,4 +1393,17 @@ function get_current_site() { return $current_site; } +function get_user_id_from_string( $string ) { + global $wpdb; + if( is_email( $string ) ) { + $user_id = $wpdb->get_var( "SELECT ID FROM {$wpdb->users} WHERE user_email = '$string'" ); + } elseif ( is_numeric( $string ) ) { + $user_id = $string; + } else { + $user_id = $wpdb->get_var( "SELECT ID FROM {$wpdb->users} WHERE user_login = '$string'" ); + } + + return $user_id; +} + ?> -- cgit