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:
Jean-Philippe Lang committed 2011-12-04 22:24:33 +00:00
1 parent b9900661f4
commit f52410be19
4 files changed
+26 -14

No files matched your search

+10
View File
@@ -54,6 +54,16 @@ class User < Principal
# Active non-anonymous users scope
named_scope :active, :conditions => "#{User.table_name}.status = #{STATUS_ACTIVE}"
named_scope :logged, :conditions => "#{User.table_name}.status <> #{STATUS_ANONYMOUS}"
named_scope :status, lambda {|arg| arg.blank? ? {} : {:conditions => {:status => arg.to_i}} }
named_scope :like, lambda {|arg|
if arg.blank?
{}
else
pattern = "%#{arg.to_s.strip.downcase}%"
{:conditions => ["LOWER(login) LIKE :p OR LOWER(firstname) LIKE :p OR LOWER(lastname) LIKE :p OR LOWER(mail) LIKE :p", {:p => pattern}]}
end
}
acts_as_customizable