From bbe5c7f6d15b462c0cfb1bd2590d2f03f10a1c32 Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 30 Dec 2008 19:38:44 +0000 Subject: [PATCH] Show actions and checkbox only if user is editable by current user. Props jeremyclarke. fixes #8760 git-svn-id: http://svn.automattic.com/wordpress/trunk@10268 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/template.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index 1c9203ac45..fed2ee3a6b 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -1805,13 +1805,19 @@ function user_row( $user_object, $style = '', $role = '' ) { if ( strlen( $short_url ) > 35 ) $short_url = substr( $short_url, 0, 32 ).'...'; $numposts = get_usernumposts( $user_object->ID ); + $checkbox = ''; + // Check if the user for this row is editable if ( current_user_can( 'edit_user', $user_object->ID ) ) { + // Set up the user editing link + // TODO: make profile/user-edit determination a seperate function if ($current_user->ID == $user_object->ID) { $edit_link = 'profile.php'; } else { $edit_link = clean_url( add_query_arg( 'wp_http_referer', urlencode( clean_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), "user-edit.php?user_id=$user_object->ID" ) ); } $edit = "$user_object->user_login
"; + + // Set up the hover actions for this user $actions = array(); $actions['edit'] = '' . __('Edit') . ''; if ( $current_user->ID != $user_object->ID ) @@ -1825,6 +1831,10 @@ function user_row( $user_object, $style = '', $role = '' ) { $edit .= "$link$sep"; } $edit .= ''; + + // Set up the checkbox (because the user is editable, otherwise its empty) + $checkbox = ""; + } else { $edit = '' . $user_object->user_login . ''; } @@ -1844,7 +1854,7 @@ function user_row( $user_object, $style = '', $role = '' ) { switch ($column_name) { case 'cb': - $r .= ""; + $r .= "$checkbox"; break; case 'username': $r .= "$avatar $edit";