Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions bulk-user-management.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,10 @@ public function handle_promote_users_form() {
public function promote_users($blogids = array(), $userids = array(), $role) {
foreach ( $userids as $id ) {
foreach ( $blogids as $blogid ) {
// Is the current user already a member of the blog with the given `$role`? If so, continue.
if ( count ( get_users( array( 'blog_id' => $blogid, 'role' => $role, 'include' => array ( $id ) ) ) ) > 0 ) {
continue;
}
add_user_to_blog( $blogid, $id, $role );
}
}
Expand Down Expand Up @@ -358,6 +362,10 @@ public function handle_remove_users_form() {
public function remove_users($blogids = array(), $userids = array()) {
foreach ( $userids as $userid ) {
foreach ( $blogids as $blogid ) {
// Is the current user already not a member of the blog? If so, continue.
if ( count ( get_users( array( 'blog_id' => $blogid, 'include' => array ( $userid ) ) ) ) == 0 ) {
continue;
}
remove_user_from_blog( $userid, $blogid );
}
}
Expand Down
10 changes: 8 additions & 2 deletions includes/class-bulk-user-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,10 @@ function inline_edit() {
</div></fieldset>

<fieldset class="inline-edit-col-middle"><div class="inline-edit-col">
<span class="title inline-edit-categories-label"><?php _e( 'Sites', 'bulk-user-management' ) ?></span>
<span class="title inline-edit-categories-label">
<?php _e( 'Sites', 'bulk-user-management' ) ?>
&nbsp;&nbsp;<input class="select-all-sites" type="checkbox" name="select-all-sites" value="1" /><?php _e( 'Select All', 'bulk-user-management' ) ?>
</span>

<ul class="cat-checklist site-checklist">
<?php foreach ( $this->get_blog_ids( 'promote_users' ) as $id ): ?>
Expand Down Expand Up @@ -278,7 +281,10 @@ function bulk_remove() {
</div></fieldset>

<fieldset class="inline-edit-col-right-wide"><div class="inline-edit-col">
<span class="title inline-edit-categories-label"><?php _e( 'Sites', 'bulk-user-management' ) ?></span>
<span class="title inline-edit-categories-label">
<?php _e( 'Sites', 'bulk-user-management' ) ?>
&nbsp;&nbsp;<input class="select-all-sites" type="checkbox" name="select-all-sites" value="1" /><?php _e( 'Select All', 'bulk-user-management' ) ?>
</span>

<ul class="cat-checklist site-checklist">
<?php foreach ( $this->get_blog_ids( 'remove_users' ) as $id ): ?>
Expand Down
12 changes: 11 additions & 1 deletion js/bulk-user-management-inline-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,17 @@ inlineEditUser = {
}
};

$(document).ready(function(){inlineEditUser.init();});
$(document).ready(function(){
inlineEditUser.init();
$('.select-all-sites').on('click', function() {
if($(this).prop('checked')) {
$(this).parents('tr.bulk-edit-row').find('.site-checklist input').prop('checked', true);
}
else {
$(this).parents('tr.bulk-edit-row').find('.site-checklist input').prop('checked', false);
}
});
});
})(jQuery);

function getParameterByName(name, url) {
Expand Down