diff options
Diffstat (limited to 'app/models/user.rb')
-rw-r--r-- | app/models/user.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 8268d752e..c7b883e6e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 |