call get_users() from get_users_of_blog()
git-svn-id: http://svn.automattic.com/wordpress/trunk@15566 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
27d0a177f7
commit
11ff3a7ce9
|
@ -1794,8 +1794,7 @@ class WP_Users_Table extends WP_List_Table {
|
||||||
|
|
||||||
$style = '';
|
$style = '';
|
||||||
foreach ( $this->items as $userid => $user_object ) {
|
foreach ( $this->items as $userid => $user_object ) {
|
||||||
$roles = $user_object->roles;
|
$role = reset( $user_object->roles );
|
||||||
$role = array_shift( $roles );
|
|
||||||
|
|
||||||
if ( is_multisite() && empty( $role ) )
|
if ( is_multisite() && empty( $role ) )
|
||||||
continue;
|
continue;
|
||||||
|
@ -2791,10 +2790,10 @@ class WP_Sites_Table extends WP_List_Table {
|
||||||
$blogusers = array_slice( $blogusers, 0, 5 );
|
$blogusers = array_slice( $blogusers, 0, 5 );
|
||||||
$blogusers_warning = __( 'Only showing first 5 users.' ) . ' <a href="' . esc_url( get_admin_url( $blog['blog_id'], 'users.php' ) ) . '">' . __( 'More' ) . '</a>';
|
$blogusers_warning = __( 'Only showing first 5 users.' ) . ' <a href="' . esc_url( get_admin_url( $blog['blog_id'], 'users.php' ) ) . '">' . __( 'More' ) . '</a>';
|
||||||
}
|
}
|
||||||
foreach ( $blogusers as $key => $val ) {
|
foreach ( $blogusers as $user_object ) {
|
||||||
echo '<a href="' . esc_url( admin_url( 'user-edit.php?user_id=' . $val->user_id ) ) . '">' . esc_html( $val->user_login ) . '</a> ';
|
echo '<a href="' . esc_url( admin_url( 'user-edit.php?user_id=' . $user_object->ID ) ) . '">' . esc_html( $user_object->user_login ) . '</a> ';
|
||||||
if ( 'list' != $mode )
|
if ( 'list' != $mode )
|
||||||
echo '( ' . $val->user_email . ' )';
|
echo '( ' . $user_object->user_email . ' )';
|
||||||
echo '<br />';
|
echo '<br />';
|
||||||
}
|
}
|
||||||
if ( $blogusers_warning != '' )
|
if ( $blogusers_warning != '' )
|
||||||
|
|
|
@ -258,24 +258,19 @@ switch ( $action ) {
|
||||||
|
|
||||||
// Site users
|
// Site users
|
||||||
$blogusers = get_users_of_blog( $id );
|
$blogusers = get_users_of_blog( $id );
|
||||||
|
|
||||||
if ( is_array( $blogusers ) ) {
|
if ( is_array( $blogusers ) ) {
|
||||||
echo '<div id="blogedit_blogusers" class="postbox"><h3 class="hndle"><span>' . __( 'Site Users' ) . '</span></h3><div class="inside">';
|
echo '<div id="blogedit_blogusers" class="postbox"><h3 class="hndle"><span>' . __( 'Site Users' ) . '</span></h3><div class="inside">';
|
||||||
echo '<table class="form-table">';
|
echo '<table class="form-table">';
|
||||||
echo "<tr><th>" . __( 'User' ) . "</th><th>" . __( 'Role' ) . "</th><th>" . __( 'Password' ) . "</th><th>" . __( 'Remove' ) . "</th></tr>";
|
echo "<tr><th>" . __( 'User' ) . "</th><th>" . __( 'Role' ) . "</th><th>" . __( 'Password' ) . "</th><th>" . __( 'Remove' ) . "</th></tr>";
|
||||||
reset( $blogusers );
|
foreach ( $blogusers as $user_id => $user_object ) {
|
||||||
foreach ( (array) $blogusers as $key => $val ) {
|
$existing_role = reset( $user_object->roles );
|
||||||
if ( isset( $val->meta_value ) && ! $val->meta_value )
|
|
||||||
continue;
|
echo '<tr><td><a href="user-edit.php?user_id=' . $user_id . '">' . $user_object->user_login . '</a></td>';
|
||||||
$t = @unserialize( $val->meta_value );
|
if ( $user_id != $current_user->data->ID ) {
|
||||||
if ( is_array( $t ) ) {
|
|
||||||
reset( $t );
|
|
||||||
$existing_role = key( $t );
|
|
||||||
}
|
|
||||||
echo '<tr><td><a href="user-edit.php?user_id=' . $val->user_id . '">' . $val->user_login . '</a></td>';
|
|
||||||
if ( $val->user_id != $current_user->data->ID ) {
|
|
||||||
?>
|
?>
|
||||||
<td>
|
<td>
|
||||||
<select name="role[<?php echo $val->user_id ?>]" id="new_role_1"><?php
|
<select name="role[<?php echo $user_id ?>]" id="new_role_1"><?php
|
||||||
foreach ( $editblog_roles as $role => $role_assoc ){
|
foreach ( $editblog_roles as $role => $role_assoc ){
|
||||||
$name = translate_user_role( $role_assoc['name'] );
|
$name = translate_user_role( $role_assoc['name'] );
|
||||||
echo '<option ' . selected( $role, $existing_role, false ) . ' value="' . esc_attr( $role ) . '">' . esc_html( $name ) . '</option>';
|
echo '<option ' . selected( $role, $existing_role, false ) . ' value="' . esc_attr( $role ) . '">' . esc_html( $name ) . '</option>';
|
||||||
|
@ -284,10 +279,10 @@ switch ( $action ) {
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" name="user_password[<?php echo esc_attr( $val->user_id ) ?>]" />
|
<input type="text" name="user_password[<?php echo esc_attr( $user_id ) ?>]" />
|
||||||
</td>
|
</td>
|
||||||
<?php
|
<?php
|
||||||
echo '<td><input title="' . __( 'Click to remove user' ) . '" type="checkbox" name="blogusers[' . esc_attr( $val->user_id ) . ']" /></td>';
|
echo '<td><input title="' . __( 'Click to remove user' ) . '" type="checkbox" name="blogusers[' . esc_attr( $user_id ) . ']" /></td>';
|
||||||
} else {
|
} else {
|
||||||
echo "<td><strong>" . __ ( 'N/A' ) . "</strong></td><td><strong>" . __ ( 'N/A' ) . "</strong></td><td><strong>" . __( 'N/A' ) . "</strong></td>";
|
echo "<td><strong>" . __ ( 'N/A' ) . "</strong></td><td><strong>" . __ ( 'N/A' ) . "</strong></td><td><strong>" . __( 'N/A' ) . "</strong></td>";
|
||||||
}
|
}
|
||||||
|
|
|
@ -471,9 +471,10 @@ class WP_User {
|
||||||
*
|
*
|
||||||
* @param int|string $id User's ID or username
|
* @param int|string $id User's ID or username
|
||||||
* @param int $name Optional. User's username
|
* @param int $name Optional. User's username
|
||||||
|
* @param int $blog_id Optional Blog ID, defaults to current blog.
|
||||||
* @return WP_User
|
* @return WP_User
|
||||||
*/
|
*/
|
||||||
function WP_User( $id, $name = '' ) {
|
function WP_User( $id, $name = '', $blog_id = '' ) {
|
||||||
|
|
||||||
if ( empty( $id ) && empty( $name ) )
|
if ( empty( $id ) && empty( $name ) )
|
||||||
return;
|
return;
|
||||||
|
@ -496,7 +497,7 @@ class WP_User {
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->id = $this->ID;
|
$this->id = $this->ID;
|
||||||
$this->_init_caps();
|
$this->for_blog( $blog_id );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -4225,6 +4225,8 @@ function _wp_search_sql($string, $cols) {
|
||||||
* @since 3.1.0
|
* @since 3.1.0
|
||||||
*
|
*
|
||||||
* @param array $queries An array of queries
|
* @param array $queries An array of queries
|
||||||
|
* @param string $meta_id_column The column that holds the object id
|
||||||
|
* @param string $table Which meta table to look in
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _wp_meta_sql( $queries, $meta_id_column, $table ) {
|
function _wp_meta_sql( $queries, $meta_id_column, $table ) {
|
||||||
|
|
|
@ -374,11 +374,12 @@ class WP_User_Query {
|
||||||
function __construct( $query = null ) {
|
function __construct( $query = null ) {
|
||||||
if ( !empty( $query ) ) {
|
if ( !empty( $query ) ) {
|
||||||
$this->query_vars = wp_parse_args( $query, array(
|
$this->query_vars = wp_parse_args( $query, array(
|
||||||
'search' => '', 'role' => '',
|
'role' => '', 'blog_id' => $GLOBALS['blog_id'],
|
||||||
'offset' => '', 'number' => '', 'count_total' => true,
|
'meta_key' => '', 'meta_value' => '', 'meta_compare' => '',
|
||||||
'orderby' => 'login', 'order' => 'ASC',
|
|
||||||
'meta_key' => '', 'meta_value' => '',
|
|
||||||
'include' => array(), 'exclude' => array(),
|
'include' => array(), 'exclude' => array(),
|
||||||
|
'search' => '',
|
||||||
|
'orderby' => 'login', 'order' => 'ASC',
|
||||||
|
'offset' => '', 'number' => '', 'count_total' => true,
|
||||||
'fields' => 'all',
|
'fields' => 'all',
|
||||||
) );
|
) );
|
||||||
|
|
||||||
|
@ -444,22 +445,22 @@ class WP_User_Query {
|
||||||
}
|
}
|
||||||
|
|
||||||
$role = trim( $qv['role'] );
|
$role = trim( $qv['role'] );
|
||||||
|
$blog_id = absint( $qv['blog_id'] );
|
||||||
|
|
||||||
$meta_queries = array();
|
$meta_queries = array();
|
||||||
|
|
||||||
$cap_meta_query = array();
|
if ( $blog_id ) {
|
||||||
$cap_meta_key = $wpdb->prefix . 'capabilities';
|
$cap_meta_query = array();
|
||||||
|
$cap_meta_query['meta_key'] = $wpdb->get_blog_prefix( $blog_id ) . 'capabilities';
|
||||||
|
|
||||||
if ( $role || is_multisite() )
|
if ( $role ) {
|
||||||
$cap_meta_query['meta_key'] = $cap_meta_key;
|
$cap_meta_query['meta_value'] = $role;
|
||||||
|
$cap_meta_query['meta_compare'] = 'like';
|
||||||
|
}
|
||||||
|
|
||||||
if ( $role ) {
|
$meta_queries[] = $cap_meta_query;
|
||||||
$cap_meta_query['meta_value'] = $role;
|
|
||||||
$cap_meta_query['meta_compare'] = 'like';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$meta_queries[] = $cap_meta_query;
|
|
||||||
|
|
||||||
$meta_queries[] = array(
|
$meta_queries[] = array(
|
||||||
'meta_key' => @$qv['meta_key'],
|
'meta_key' => @$qv['meta_key'],
|
||||||
'meta_value' => @$qv['meta_key'],
|
'meta_value' => @$qv['meta_key'],
|
||||||
|
@ -506,7 +507,7 @@ class WP_User_Query {
|
||||||
|
|
||||||
$r = array();
|
$r = array();
|
||||||
foreach ( $this->results as $userid )
|
foreach ( $this->results as $userid )
|
||||||
$r[ $userid ] = new WP_User( $userid );
|
$r[ $userid ] = new WP_User( $userid, '', $this->query_vars['blog_id'] );
|
||||||
|
|
||||||
$this->results = $r;
|
$this->results = $r;
|
||||||
}
|
}
|
||||||
|
@ -564,7 +565,7 @@ function get_users( $args ) {
|
||||||
* multi-blog feature.
|
* multi-blog feature.
|
||||||
*
|
*
|
||||||
* @since 2.2.0
|
* @since 2.2.0
|
||||||
* @uses $wpdb WordPress database object for queries
|
* @uses get_users() for queries
|
||||||
* @uses $blog_id The Blog id of the blog for those that use more than one blog
|
* @uses $blog_id The Blog id of the blog for those that use more than one blog
|
||||||
*
|
*
|
||||||
* @param int $id Blog ID.
|
* @param int $id Blog ID.
|
||||||
|
@ -572,11 +573,11 @@ function get_users( $args ) {
|
||||||
*/
|
*/
|
||||||
function get_users_of_blog( $id = '' ) {
|
function get_users_of_blog( $id = '' ) {
|
||||||
global $wpdb, $blog_id;
|
global $wpdb, $blog_id;
|
||||||
|
|
||||||
if ( empty($id) )
|
if ( empty($id) )
|
||||||
$id = (int) $blog_id;
|
$id = (int) $blog_id;
|
||||||
$blog_prefix = $wpdb->get_blog_prefix($id);
|
|
||||||
$users = $wpdb->get_results( "SELECT user_id, user_id AS ID, user_login, display_name, user_email, meta_value FROM $wpdb->users, $wpdb->usermeta WHERE {$wpdb->users}.ID = {$wpdb->usermeta}.user_id AND meta_key = '{$blog_prefix}capabilities' ORDER BY {$wpdb->usermeta}.user_id" );
|
return get_users( array( 'blog_id' => $id ) );
|
||||||
return $users;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue