Index: app/controllers/my_controller.rb =================================================================== --- app/controllers/my_controller.rb (revision 1013) +++ app/controllers/my_controller.rb (working copy) @@ -17,6 +17,8 @@ class MyController < ApplicationController helper :issues + helper :custom_fields + include CustomFieldsHelper layout 'base' before_filter :require_login @@ -52,6 +54,12 @@ def account @user = User.current @pref = @user.pref + if request.get? + @custom_values = UserCustomField.find(:all, :order => "#{CustomField.table_name}.position").collect { |x| @user.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) } + else + @custom_values = UserCustomField.find(:all, :order => "#{CustomField.table_name}.position").collect { |x| CustomValue.new(:custom_field => x, :customized => @user, :value => params["custom_fields"][x.id.to_s]) } + @user.custom_values = @custom_values + end if request.post? @user.attributes = params[:user] @user.mail_notification = (params[:notification_option] == 'all') Index: app/controllers/search_controller.rb =================================================================== --- app/controllers/search_controller.rb (revision 1013) +++ app/controllers/search_controller.rb (working copy) @@ -43,13 +43,13 @@ if @project # only show what the user is allowed to view - @object_types = %w(issues news documents changesets wiki_pages messages) + @object_types = %w(issues news documents changesets wiki_pages messages users) @object_types = @object_types.select {|o| User.current.allowed_to?("view_#{o}".to_sym, @project)} - + @object_types += %w(users) #this is probably better fixed in User.current.allowed_to @scope = @object_types.select {|t| params[t]} @scope = @object_types if @scope.empty? else - @object_types = @scope = %w(projects) + @object_types = @scope = %w(projects users) end # extract tokens from the question @@ -94,8 +94,15 @@ :limit => limit, :conditions => [ (["(#{Project.visible_by(User.current)}) AND (LOWER(name) like ? OR LOWER(description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @scope.include? 'projects' - # if only one project is found, user is redirected to its overview - redirect_to :controller => 'projects', :action => 'show', :id => @results.first and return if @results.size == 1 + @projectCount = @results.size + @results += User.find(:all, + :limit => limit, + :conditions => [ (["(LOWER(firstname) like ? OR LOWER(lastname) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] + ) if @scope.include? 'users' + @userCount = @results.size - @projectCount + # if only one project/user is found, user is redirected to its overview + redirect_to :controller => 'projects', :action => 'show', :id => @results.first and return if @results.size == 1 and @projectCount == 1 + redirect_to :controller => 'users', :action => 'show', :id => @results.first and return if @results.size == 1 and @userCount == 1 end else @question = "" Index: app/controllers/users_controller.rb =================================================================== --- app/controllers/users_controller.rb (revision 1013) +++ app/controllers/users_controller.rb (working copy) @@ -48,6 +48,18 @@ render :action => "list", :layout => false if request.xhr? end + + def show + @user = User.find(params[:id]) + @custom_values = @user.custom_values.find(:all, :include => :custom_field) + + # show only public projects and private projects that the logged in user is also a member of + @memberships = @user.memberships.select do |membership| + membership.project.is_public? || (User.current.role_for_project(membership.project)) + end + rescue ActiveRecord::RecordNotFound + render_404 + end def add if request.get? Index: app/models/user.rb =================================================================== --- app/models/user.rb (revision 1013) +++ app/models/user.rb (working copy) @@ -32,6 +32,14 @@ has_one :rss_token, :dependent => :destroy, :class_name => 'Token', :conditions => "action='feeds'" belongs_to :auth_source + acts_as_searchable :columns => ['firstname', 'lastname'], + :include => :memberships, + :include => :projects, + :project_key => "#{Project.table_name}.id" + acts_as_event :title => Proc.new {|o| "#{l(:field_name)}: #{o.firstname} #{o.lastname}"}, + :description => :mail, + :url => Proc.new {|o| {:controller => 'users', :action => 'show', :id => o.id}} + attr_accessor :password, :password_confirmation attr_accessor :last_before_login_on # Prevents unauthorized assignments Index: app/views/my/account.rhtml =================================================================== --- app/views/my/account.rhtml (revision 1013) +++ app/views/my/account.rhtml (working copy) @@ -20,6 +20,10 @@

<%= pref_fields.select :time_zone, TimeZone.all.collect {|z| [ z.to_s, z.name ]}, :include_blank => true %>

<%= pref_fields.check_box :hide_mail %>

<% end %> + +<% for @custom_value in @custom_values %> +

<%= custom_field_tag_with_label @custom_value %>

+<% end if @custom_values%> <%= submit_tag l(:button_save) %> Index: app/views/users/show.rhtml =================================================================== --- app/views/users/show.rhtml (revision 0) +++ app/views/users/show.rhtml (revision 0) @@ -0,0 +1,16 @@ +

<%=h @user.name %>

+ +

+<%=l(:field_name)%>: <%= @user.firstname %> <%= @user.lastname%>
+<%=l(:field_mail)%>: <%= mail_to @user.mail unless @user.pref.hide_mail %>
+<%=l(:label_registered_on)%>: <%= format_date(@user.created_on) %>
+

+ +

+<% for custom_value in @custom_values %> +<% if !custom_value.value.empty? %> + <%= custom_value.custom_field.name%>: <%=h show_value(custom_value) %>
+<% end %> +<% end %> +

+