diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index ab3d7b120..2a3ce15d8 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -149,7 +149,6 @@ class AdminController < ApplicationController respond_to do |format| format.html { @groups = Group.all.sort - render :layout => @user_base_tag } format.api end @@ -196,4 +195,43 @@ class AdminController < ApplicationController [:text_rmagick_available, Object.const_defined?(:Magick)] ] end + #管理功能用户列表的搜索 + def search + sort_init 'login', 'asc' + sort_update %w(login firstname lastname mail admin created_on last_login_on) + + case params[:format] + when 'xml', 'json' + @offset, @limit = api_offset_and_limit({:limit => 15}) + else + @limit = 15#per_page_option + end + + @status = params[:status] || 1 + has = { + "show_changesets" => true + } + scope = User.logged.status(@status) + scope = scope.like(params[:name]) if params[:name].present? + @user_count = scope.count + @user_pages = Paginator.new @user_count, @limit, params['page'] + @user_base_tag = params[:id] ? 'base_users':'base' + @offset ||= @user_pages.reverse_offset + unless @offset == 0 + @users = scope.offset(@offset).limit(@limit).all.reverse + else + limit = @user_count % @limit + if limit == 0 + limit = @limit + end + @users = scope.offset(@offset).limit(limit).all.reverse + end + + respond_to do |format| + format.html { + @groups = Group.all.sort + } + format.api + end + end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index da9aef30b..82ea7e037 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -70,8 +70,8 @@ class UsersController < ApplicationController cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1" @memberships = @user.memberships.all(:conditions => cond) end - events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 20) - @events_by_day = events.group_by(&:event_date) + #events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 20) + #@events_by_day = events.group_by(&:event_date) @state = 0 @@ -289,7 +289,7 @@ class UsersController < ApplicationController when '0' @offset ||= @user_pages.reverse_offset unless @offset == 0 - @users_statuses = scope.offset(@offset).limit(@limit).all.reverse + @users_statuses = scope.offset(@offset).limit(@limit).all.reverse else limit = @user_count % @limit if limit == 0 @@ -313,7 +313,7 @@ class UsersController < ApplicationController end @s_type = 1 #sort {|x,y| y.user_status.changesets_count <=> x.user_status.changesets_count} - #@users = @users[@offset, @limit] + #@users = @users[@offset, @limit] when '2' @offset ||= @user_pages.reverse_offset unless @offset == 0 @@ -326,9 +326,9 @@ class UsersController < ApplicationController @users_statuses = scope.reorder('watchers_count').offset(@offset).limit(limit).all.reverse end @s_type = 2 - #@users = @users[@offset, @limit] + #@users = @users[@offset, @limit] end - + else @offset ||= @user_pages.reverse_offset unless @offset == 0 diff --git a/app/views/admin/search.html.erb b/app/views/admin/search.html.erb new file mode 100644 index 000000000..17d91e78b --- /dev/null +++ b/app/views/admin/search.html.erb @@ -0,0 +1,68 @@ +<% if User.current.admin? %> +
+ | |||||||
---|---|---|---|---|---|---|---|
<%= avatar(user, :size => "14") %><%= link_to h(user.login), edit_user_path(user) %> | +<%= h(user.firstname) %> | +<%= h(user.lastname) %> | +<%= mail_to(h(user.mail)) %> | +<%= checked_image user.admin? %> | +<%= format_time(user.created_on) %> | +<%= format_time(user.last_login_on) unless user.last_login_on.nil? %> | +<%= change_status_link(user) %> + <%= delete_link user_path(user, :back_url => users_path(params)) unless User.current == user %> | +