Permalink
Browse files

If `current_user_can_bulk_edit()` and they're editing a valid blog, d…

…on't worry about their permissions on the target blog because that means they've been whitelisted for that blog.
  • Loading branch information...
1 parent 82db250 commit 7092b3d995e7ca5f8c16785c6f178a6dd0a63669 @joshbetz joshbetz committed Jul 9, 2012
Showing with 22 additions and 22 deletions.
  1. +3 −3 bulk-user-management.php
  2. +19 −19 includes/class-bulk-user-table.php
View
@@ -241,10 +241,10 @@ public function handle_promote_users_form() {
wp_die( $error->get_error_message() );
}
- // Verify the current user can promote users on all target blgos
+ // Verify the current user can promote users on all target blogs
$errors = array();
foreach ( $blogids as $blogid ) {
- if ( ! current_user_can_for_blog($blogid, 'promote_user') ) {
+ if ( ! ( $this->current_user_can_bulk_edit() && in_array( $blogid, Bulk_User_Table::get_blog_ids( 'promote_user' ) ) ) && ! current_user_can_for_blog( $blogid, 'promote_user' ) ) {
$error = new WP_Error( 'no-promote-user-cap', sprintf( __( 'You can’t edit users on that site.', 'bulk-user-management' ) ) );
// Just throw an error because that shouldn't have been possible
wp_die( $error->get_error_message() );
@@ -311,7 +311,7 @@ public function handle_remove_users_form() {
// Check that the current user can remove users on all target blogs
$errors = array();
foreach ( $blogids as $blogid ) {
- if ( ! current_user_can_for_blog($blogid, 'remove_users') ) {
+ if ( ! ( $this->current_user_can_bulk_edit() && in_array( $blogid, Bulk_User_Table::get_blog_ids( 'remove_users' ) ) ) && ! current_user_can_for_blog( $blogid, 'remove_users' ) ) {
$error = new WP_Error( 'no-remove-user-cap', sprintf( __( 'You can’t remove users on that site.', 'bulk-user-management' ) ) );
// Just throw an error because that shouldn't have been possible
wp_die( $error->get_error_message() );
@@ -95,25 +95,6 @@ function get_bulk_actions() {
return $actions;
}
- function get_blog_ids( $cap ) {
-
- $limit = array_map( 'intval', apply_filters( 'bulk_user_management_blogs', array() ) );
-
- if ( count( $limit ) > 0 )
- return $limit;
-
- $user_id = get_current_user_id();
- $blogs = get_blogs_of_user( $user_id );
- $blog_ids = array();
- foreach ( $blogs as $blog ) {
- $user = new WP_User( $user_id, null, $blog->userblog_id );
- if ( user_can( $user, $cap ) )
- $blog_ids[] = $blog->userblog_id;
- }
-
- return $blog_ids;
- }
-
function prepare_items( $queryitems = true ) {
global $wpdb;
@@ -301,4 +282,23 @@ function bulk_remove() {
</tbody></table>
<?php
}
+
+ static function get_blog_ids( $cap ) {
+
+ $limit = array_map( 'intval', apply_filters( 'bulk_user_management_blogs', array() ) );
+
+ if ( count( $limit ) > 0 )
+ return $limit;
+
+ $user_id = get_current_user_id();
+ $blogs = get_blogs_of_user( $user_id );
+ $blog_ids = array();
+ foreach ( $blogs as $blog ) {
+ $user = new WP_User( $user_id, null, $blog->userblog_id );
+ if ( user_can( $user, $cap ) )
+ $blog_ids[] = $blog->userblog_id;
+ }
+
+ return $blog_ids;
+ }
}

0 comments on commit 7092b3d

Please sign in to comment.