summaryrefslogtreecommitdiffstats
path: root/app/controllers/users_controller.rb
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2022-09-20 03:36:40 +0000
committerGo MAEDA <maeda@farend.jp>2022-09-20 03:36:40 +0000
commit62f7551d57a4a0c77030a35b8822a91d524c8ea7 (patch)
tree2449917ab9c4d3ef50fcb937042bf7a35300583b /app/controllers/users_controller.rb
parentcd70187c2fa2a5058690fde78dcdcb1c759c204e (diff)
downloadredmine-62f7551d57a4a0c77030a35b8822a91d524c8ea7.tar.gz
redmine-62f7551d57a4a0c77030a35b8822a91d524c8ea7.zip
User bulk destroy (#37674).
includes a confirmation page that also gives the opportunity to lock users instead of deleting them. Patch by Jens Krämer. git-svn-id: https://svn.redmine.org/redmine/trunk@21824 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/users_controller.rb')
-rw-r--r--app/controllers/users_controller.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 5cd9eb931..0d80fc33a 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -215,6 +215,21 @@ class UsersController < ApplicationController
end
end
+ def bulk_destroy
+ @users = User.logged.where(id: params[:ids]).where.not(id: User.current)
+ (render_404; return) unless @users.any?
+
+ if params[:lock]
+ @users.update_all status: User::STATUS_LOCKED
+ flash[:notice] = l(:notice_successful_update)
+ redirect_to users_path
+ elsif params[:confirm] == I18n.t(:general_text_Yes)
+ @users.destroy_all
+ flash[:notice] = l(:notice_successful_delete)
+ redirect_to users_path
+ end
+ end
+
private
def find_user(logged = true)