From 4f514fd08e9359cd18b6fcd765d6818cd0dc76b8 Mon Sep 17 00:00:00 2001 From: donncha Date: Tue, 16 Aug 2005 16:31:36 +0000 Subject: Edit roles of blog users. git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@198 7be80a69-a1ef-0310-a953-fb0f7c49ff36 --- wp-inst/wp-admin/wpmu-blogs.php | 31 ++++++++++++++++++++++++++++--- wp-inst/wp-admin/wpmu-edit.php | 18 +++++++++++++++++- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/wp-inst/wp-admin/wpmu-blogs.php b/wp-inst/wp-admin/wpmu-blogs.php index 6d79220..93a064d 100644 --- a/wp-inst/wp-admin/wpmu-blogs.php +++ b/wp-inst/wp-admin/wpmu-blogs.php @@ -150,15 +150,29 @@ switch( $_GET[ 'action' ] ) { print "

Blog Users

"; if( is_array( $blogusers ) ) { print ""; - print ""; + print ""; reset( $blogusers ); while( list( $key, $val ) = each( $blogusers ) ) { + $t = @unserialize( $val->meta_value ); + if( is_array( $t ) ) { + reset( $t ); + $existing_role = key( $t ); + } print ""; if( $val->user_id != $current_user->data->ID ) { + ?> + "; } else { - print ""; + print ""; } print ""; } @@ -168,8 +182,19 @@ switch( $_GET[ 'action' ] ) { ?>

As you type WordPress will offer you a choice of usernames.
Click them to select and hit Update Options to add the user.

Current Users
UserRemove
UserRoleRemove
" . $val->user_login . " N/AN/AN/AEdit
- + + + + +
User Login: Search
User Login: Search

diff --git a/wp-inst/wp-admin/wpmu-edit.php b/wp-inst/wp-admin/wpmu-edit.php index 544be37..cf9e650 100644 --- a/wp-inst/wp-admin/wpmu-edit.php +++ b/wp-inst/wp-admin/wpmu-edit.php @@ -110,6 +110,22 @@ switch( $_GET[ 'action' ] ) { $wpdb->query( $query ); } + // user roles + if( is_array( $_POST[ 'role' ] ) == true ) { + $newroles = $_POST[ 'role' ]; + reset( $newroles ); + while( list( $userid, $role ) = each( $newroles ) ) { + $role_len = strlen( $role ); + $existing_role = $wpdb->get_var( "SELECT meta_value FROM $wpdb->usermeta WHERE user_id = '$userid' AND meta_key = '" . $wpmuBaseTablePrefix . $id . "_capabilities'" ); + if( false == $existing_role ) { + $wpdb->query( "INSERT INTO " . $wpdb->usermeta . "( `umeta_id` , `user_id` , `meta_key` , `meta_value` ) VALUES ( NULL, '$userid', '" . $wpmuBaseTablePrefix . $id . "_capabilities', 'a:1:{s:" . strlen( $role ) . ":\"" . $role . "\";b:1;}')" ); + } elseif( $existing_role != "a:1:{s:" . strlen( $role ) . ":\"" . $role . "\";b:1;}" ) { + $wpdb->query( "UPDATE $wpdb->usermeta SET meta_value = 'a:1:{s:" . strlen( $role ) . ":\"" . $role . "\";b:1;}' WHERE user_id = '$userid' AND meta_key = '" . $wpmuBaseTablePrefix . $id . "_capabilities'" ); + } + + } + } + // remove user if( is_array( $_POST[ 'blogusers' ] ) ) { reset( $_POST[ 'blogusers' ] ); @@ -126,7 +142,7 @@ switch( $_GET[ 'action' ] ) { if( $userid ) { $user = $wpdb->get_var( "SELECT user_id FROM " . $wpdb->usermeta . " WHERE user_id='$userid' AND meta_key='wp_" . $id . "_capabilities'" ); if( $user == false ) - $wpdb->query( "INSERT INTO " . $wpdb->usermeta . "( `umeta_id` , `user_id` , `meta_key` , `meta_value` ) VALUES ( NULL, '$userid', 'wp_" . $id . "_capabilities', 'a:1:{s:8:\"inactive\";b:1;}')" ); + $wpdb->query( "INSERT INTO " . $wpdb->usermeta . "( `umeta_id` , `user_id` , `meta_key` , `meta_value` ) VALUES ( NULL, '$userid', '" . $wpmuBaseTablePrefix . $id . "_capabilities', 'a:1:{s:" . strlen( $_POST[ 'new_role' ] ) . ":\"" . $_POST[ 'new_role' ] . "\";b:1;}')" ); } } header( "Location: wpmu-blogs.php?action=editblog&id=".$id."&updated=true" ); -- cgit