Class: User
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- User
- Defined in:
- app/models/users/user.rb
Overview
Copyright © 2008-2013 Michael Dvorkin and contributors.
Fat Free CRM is freely distributable under the terms of MIT license. See MIT-LICENSE file or www.opensource.org/licenses/mit-license.php
Schema Information
Table name: users
id :integer not null, primary key
username :string(32) default(""), not null
email :string(64) default(""), not null
first_name :string(32)
last_name :string(32)
title :string(64)
company :string(64)
alt_email :string(64)
phone :string(32)
mobile :string(32)
aim :string(32)
yahoo :string(32)
google :string(32)
skype :string(32)
password_hash :string(255) default(""), not null
password_salt :string(255) default(""), not null
persistence_token :string(255) default(""), not null
perishable_token :string(255) default(""), not null
last_request_at :datetime
last_login_at :datetime
current_login_at :datetime
last_login_ip :string(255)
current_login_ip :string(255)
login_count :integer default(0), not null
deleted_at :datetime
created_at :datetime
updated_at :datetime
admin :boolean default(FALSE), not null
suspended_at :datetime
single_access_token :string(255)
Class Method Summary collapse
Instance Method Summary collapse
-
#awaits_approval? ⇒ Boolean
—————————————————————————-.
-
#deliver_password_reset_instructions! ⇒ Object
—————————————————————————-.
-
#full_name ⇒ Object
—————————————————————————-.
-
#group_ids=(value) ⇒ Object
Massage value when using Chosen select box which gives values like [“”, “1,2,3”] —————————————————————————-.
-
#name ⇒ Object
—————————————————————————-.
-
#preference ⇒ Object
(also: #pref)
—————————————————————————-.
-
#set_individual_locale ⇒ Object
Override global I18n.locale if the user has individual local preference.
-
#set_single_access_token ⇒ Object
Generate the value of single access token if it hasn’t been set already.
-
#suspended? ⇒ Boolean
—————————————————————————-.
- #to_json(options = nil) ⇒ Object
- #to_xml(options = nil) ⇒ Object
Class Method Details
.can_signup? ⇒ Boolean
190 191 192 |
# File 'app/models/users/user.rb', line 190 def can_signup? [ :allowed, :needs_approval ].include? Setting.user_signup end |
Instance Method Details
#awaits_approval? ⇒ Boolean
114 115 116 |
# File 'app/models/users/user.rb', line 114 def awaits_approval? self.suspended? && self.login_count == 0 && Setting.user_signup == :needs_approval end |
#deliver_password_reset_instructions! ⇒ Object
125 126 127 128 |
# File 'app/models/users/user.rb', line 125 def deliver_password_reset_instructions! reset_perishable_token! UserMailer.password_reset_instructions(self).deliver end |
#full_name ⇒ Object
104 105 106 |
# File 'app/models/users/user.rb', line 104 def full_name self.first_name.blank? && self.last_name.blank? ? self.email : "#{self.first_name} #{self.last_name}".strip end |
#group_ids=(value) ⇒ Object
Massage value when using Chosen select box which gives values like [“”, “1,2,3”]
144 145 146 147 |
# File 'app/models/users/user.rb', line 144 def group_ids=(value) value = value.join.split(',').map(&:to_i) if value.map{|v| v.to_s.include?(',')}.any? super(value) end |
#name ⇒ Object
99 100 101 |
# File 'app/models/users/user.rb', line 99 def name self.first_name.blank? ? self.username : self.first_name end |
#preference ⇒ Object Also known as: pref
119 120 121 |
# File 'app/models/users/user.rb', line 119 def preference @preference ||= Preference.new(:user => self) end |
#set_individual_locale ⇒ Object
Override global I18n.locale if the user has individual local preference.
132 133 134 |
# File 'app/models/users/user.rb', line 132 def set_individual_locale I18n.locale = self.preference[:locale] if self.preference[:locale] end |
#set_single_access_token ⇒ Object
Generate the value of single access token if it hasn’t been set already.
138 139 140 |
# File 'app/models/users/user.rb', line 138 def set_single_access_token self.single_access_token ||= update_attribute(:single_access_token, Authlogic::Random.friendly_token) end |
#suspended? ⇒ Boolean
109 110 111 |
# File 'app/models/users/user.rb', line 109 def suspended? self.suspended_at != nil end |
#to_json(options = nil) ⇒ Object
149 150 151 |
# File 'app/models/users/user.rb', line 149 def to_json( = nil) [name].to_json end |
#to_xml(options = nil) ⇒ Object
153 154 155 |
# File 'app/models/users/user.rb', line 153 def to_xml( = nil) [name].to_xml end |