Adds named scopes for users index.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8081 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -38,23 +38,17 @@ class UsersController < ApplicationController
|
||||
@limit = per_page_option
|
||||
end
|
||||
|
||||
scope = User
|
||||
scope = scope.in_group(params[:group_id].to_i) if params[:group_id].present?
|
||||
@status = params[:status] || 1
|
||||
|
||||
@status = params[:status] ? params[:status].to_i : 1
|
||||
c = ARCondition.new(@status == 0 ? "status <> 0" : ["status = ?", @status])
|
||||
scope = User.logged.status(@status)
|
||||
scope = scope.like(params[:name]) if params[:name].present?
|
||||
scope = scope.in_group(params[:group_id]) if params[:group_id].present?
|
||||
|
||||
unless params[:name].blank?
|
||||
name = "%#{params[:name].strip.downcase}%"
|
||||
c << ["LOWER(login) LIKE ? OR LOWER(firstname) LIKE ? OR LOWER(lastname) LIKE ? OR LOWER(mail) LIKE ?", name, name, name, name]
|
||||
end
|
||||
|
||||
@user_count = scope.count(:conditions => c.conditions)
|
||||
@user_count = scope.count
|
||||
@user_pages = Paginator.new self, @user_count, @limit, params['page']
|
||||
@offset ||= @user_pages.current.offset
|
||||
@users = scope.find :all,
|
||||
:order => sort_clause,
|
||||
:conditions => c.conditions,
|
||||
:limit => @limit,
|
||||
:offset => @offset
|
||||
|
||||
|
||||
Reference in New Issue
Block a user