end
flash[:notice] = l(:notice_successful_update)
redirect_to :action => 'edit', :tab => params[:tab]
+ return
end
+ @options = {}
+ @options[:user_format] = User::USER_FORMATS.keys.collect {|f| [User.current.name(f), f.to_s] }
end
def plugin
self.user.name
end
+ def <=>(member)
+ role == member.role ? (user <=> member.user) : (role <=> member.role)
+ end
+
def before_destroy
# remove category based auto assignments for this member
IssueCategory.update_all "assigned_to_id = NULL", ["project_id = ? AND assigned_to_id = ?", project.id, user.id]
v = read_attribute(:value)
# Unserialize serialized settings
v = YAML::load(v) if @@available_settings[name]['serialized'] && v.is_a?(String)
+ v = v.to_sym if @@available_settings[name]['format'] == 'symbol' && !v.blank?
v
end
def value=(v)
v = v.to_yaml if v && @@available_settings[name]['serialized']
- write_attribute(:value, v)
+ write_attribute(:value, v.to_s)
end
# Returns the value of the setting named name
STATUS_ACTIVE = 1
STATUS_REGISTERED = 2
STATUS_LOCKED = 3
+
+ USER_FORMATS = {
+ :firstname_lastname => '#{firstname} #{lastname}',
+ :firstname => '#{firstname}',
+ :lastname_firstname => '#{lastname} #{firstname}',
+ :lastname_coma_firstname => '#{lastname}, #{firstname}',
+ :username => '#{login}'
+ }
has_many :memberships, :class_name => 'Member', :include => [ :project, :role ], :conditions => "#{Project.table_name}.status=#{Project::STATUS_ACTIVE}", :order => "#{Project.table_name}.name", :dependent => :delete_all
has_many :projects, :through => :memberships
end
# Return user's full name for display
- def name
- "#{firstname} #{lastname}"
+ def name(formatter = nil)
+ f = USER_FORMATS[formatter || Setting.user_format] || USER_FORMATS[:firstname_lastname]
+ eval '"' + f + '"'
end
def active?
end
def <=>(user)
- user.nil? ? -1 : (lastname == user.lastname ? firstname <=> user.firstname : lastname <=> user.lastname)
+ if user.nil?
+ -1
+ elsif lastname.to_s.downcase == user.lastname.to_s.downcase
+ firstname.to_s.downcase <=> user.firstname.to_s.downcase
+ else
+ lastname.to_s.downcase <=> user.lastname.to_s.downcase
+ end
end
def to_s
<%= error_messages_for 'member' %>
<% roles = Role.find_all_givable %>
-<% users = User.find_active(:all) - @project.users %>
+<% users = User.find_active(:all).sort - @project.users %>
<% # members sorted by role position
- members = @project.members.find(:all, :include => [:role, :user]).sort{|x,y| x.role.position <=> y.role.position} %>
+ members = @project.members.find(:all, :include => [:role, :user]).sort %>
<% if members.any? %>
<table class="list">
<p><label><%= l(:setting_time_format) %></label>
<%= select_tag 'settings[time_format]', options_for_select( [[l(:label_language_based), '']] + Setting::TIME_FORMATS.collect {|f| [Time.now.strftime(f), f]}, Setting.time_format) %></p>
+<p><label><%= l(:setting_user_format) %></label>
+<%= select_tag 'settings[user_format]', options_for_select( @options[:user_format], Setting.user_format.to_s ) %></p>
+
<p><label><%= l(:setting_attachment_max_size) %></label>
<%= text_field_tag 'settings[attachment_max_size]', Setting.attachment_max_size, :size => 6 %> KB</p>
default: ''
time_format:
default: ''
+user_format:
+ default: :firstname_lastname
+ format: symbol
cross_project_issue_relations:
default: 0
notified_events:
label_general: General
label_repository_plural: Repositories
label_associated_revisions: Associated revisions
+setting_user_format: Users display format
label_general: General
label_repository_plural: Repositories
label_associated_revisions: Associated revisions
+setting_user_format: Users display format
label_general: General
label_repository_plural: Repositories
label_associated_revisions: Associated revisions
+setting_user_format: Users display format
setting_emails_footer: Emails footer
setting_protocol: Protocol
setting_per_page_options: Objects per page options
+setting_user_format: Users display format
label_user: User
label_user_plural: Users
label_general: General
label_repository_plural: Repositories
label_associated_revisions: Associated revisions
+setting_user_format: Users display format
enumeration_doc_categories: Dokumentin luokat
enumeration_activities: Aktiviteetit (ajan seuranta)
label_associated_revisions: Liittyvät versiot
+setting_user_format: Users display format
setting_emails_footer: Pied-de-page des emails
setting_protocol: Protocole
setting_per_page_options: Options d'objets affichés par page
+setting_user_format: Format d'affichage des utilisateurs
label_user: Utilisateur
label_user_plural: Utilisateurs
label_general: General
label_repository_plural: Repositories
label_associated_revisions: Associated revisions
+setting_user_format: Users display format
label_general: General
label_repository_plural: Repositories
label_associated_revisions: Associated revisions
+setting_user_format: Users display format
label_general: General
label_repository_plural: Repositories
label_associated_revisions: Associated revisions
+setting_user_format: Users display format
label_general: 일반
label_repository_plural: 저장소들
label_associated_revisions: Associated revisions
+setting_user_format: Users display format
label_repository_plural: Repositories
error_can_t_load_default_data: "Default configuration could not be loaded: %s"
label_associated_revisions: Associated revisions
+setting_user_format: Users display format
label_general: General
label_repository_plural: Repositories
label_associated_revisions: Associated revisions
+setting_user_format: Users display format
label_general: Ogólne
label_repository_plural: Repozytoria
label_associated_revisions: Associated revisions
+setting_user_format: Users display format
label_general: General\r
label_repository_plural: Repositories\r
label_associated_revisions: Associated revisions\r
+setting_user_format: Users display format\r
label_general: General
label_repository_plural: Repositories
label_associated_revisions: Associated revisions
+setting_user_format: Users display format
label_general: General
label_repository_plural: Repositories
label_associated_revisions: Associated revisions
+setting_user_format: Users display format
enumeration_activities: Действия (учет времени)
error_can_t_load_default_data: "Конфигурация по умолчанию не была загружена: %s"
+setting_user_format: Users display format
label_general: General
label_repository_plural: Repositories
label_associated_revisions: Associated revisions
+setting_user_format: Users display format
label_general: General
label_repository_plural: Repositories
label_associated_revisions: Associated revisions
+setting_user_format: Users display format
enumeration_doc_categories: 文件分類
enumeration_activities: 活動 (time tracking)
label_associated_revisions: Associated revisions
+setting_user_format: Users display format
label_general: General
label_repository_plural: Repositories
label_associated_revisions: Associated revisions
+setting_user_format: Users display format
assert_equal User.hash_password("hello"), user.hashed_password
end
+ def test_name_format
+ assert_equal 'Smith, John', @jsmith.name(:lastname_coma_firstname)
+ Setting.user_format = :firstname_lastname
+ assert_equal 'John Smith', @jsmith.name
+ Setting.user_format = :username
+ assert_equal 'jsmith', @jsmith.name
+ end
+
def test_lock
user = User.try_to_login("jsmith", "jsmith")
assert_equal @jsmith, user