diff --git a/app/controllers/admin/features_controller.rb b/app/controllers/admin/features_controller.rb index 4bbe006..c1b38ce 100644 --- a/app/controllers/admin/features_controller.rb +++ b/app/controllers/admin/features_controller.rb @@ -17,6 +17,10 @@ class FeaturesController < AdminController def manage_fields @person_fields = Person.fields + @plugins.dispatch(:extra_person_fields).collect do |field| + @person_fields << field unless @person_fields.include?(field) + end + @enterprise_fields = Enterprise.fields @community_fields = Community.fields end diff --git a/app/controllers/my_profile/profile_editor_controller.rb b/app/controllers/my_profile/profile_editor_controller.rb index 3ee21a3..acf12f5 100644 --- a/app/controllers/my_profile/profile_editor_controller.rb +++ b/app/controllers/my_profile/profile_editor_controller.rb @@ -15,14 +15,22 @@ class ProfileEditorController < MyProfileController @possible_domains = profile.possible_domains if request.post? params[:profile_data][:fields_privacy] ||= {} if profile.person? && params[:profile_data].is_a?(Hash) - Profile.transaction do - Image.transaction do - if @profile_data.update_attributes(params[:profile_data]) - redirect_to :action => 'index', :profile => profile.identifier - else - profile.identifier = params[:profile] if profile.identifier.blank? + begin + @plugins.dispatch(:profile_editor_transaction_extras) + + Profile.transaction do + Image.transaction do + if @profile_data.update_attributes(params[:profile_data]) + redirect_to :action => 'index', :profile => profile.identifier + else + profile.identifier = params[:profile] if profile.identifier.blank? + end + end + end + rescue Exception => ex + if profile.identifier.blank? + profile.identifier = params[:profile] end - end end end end diff --git a/app/controllers/public/account_controller.rb b/app/controllers/public/account_controller.rb index a7cf41d..0a17dde 100644 --- a/app/controllers/public/account_controller.rb +++ b/app/controllers/public/account_controller.rb @@ -93,7 +93,13 @@ class AccountController < ApplicationController @user.terms_of_use = environment.terms_of_use @user.environment = environment @terms_of_use = environment.terms_of_use - @user.person_data = params[:profile_data] + + params_profile_data = params[:profile_data] + @plugins.dispatch(:extra_person_data_params).each do |data| + params_profile_data = params_profile_data.merge(data) unless params[:profile_data].blank? + end + + @user.person_data = params_profile_data @user.return_to = session[:return_to] @person = Person.new(params[:profile_data]) @person.environment = @user.environment diff --git a/app/models/user.rb b/app/models/user.rb index af05e33..694e618 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -29,6 +29,8 @@ class User < ActiveRecord::Base alias_method_chain :human_attribute_name, :customization end + include Noosfero::Plugin::HotSpot + before_create do |user| if user.environment.nil? user.environment = Environment.default @@ -46,6 +48,7 @@ class User < ActiveRecord::Base p.environment = user.environment p.name ||= user.name || user.login p.visible = false unless user.activated? + p.save! user.person = p diff --git a/app/views/profile_editor/_person_form.html.erb b/app/views/profile_editor/_person_form.html.erb index a2bd218..19abfb0 100644 --- a/app/views/profile_editor/_person_form.html.erb +++ b/app/views/profile_editor/_person_form.html.erb @@ -27,6 +27,10 @@ <%= optional_field(@person, 'district', labelled_form_field(_('District'), text_field(:profile_data, :district, :rel => _('District')))) %> <%= optional_field(@person, 'image', labelled_form_field(_('Image'), file_field(:file, :image, :rel => _('Image')))) %> +<% @plugins.dispatch(:extra_optional_fields).each do |field| %> + <%= optional_field(@person, field[:name], labelled_form_field(field[:label], text_field(field[:object_name], field[:method], :rel => field[:label], :value => field[:value]))) %> +<% end %> + <% optional_field(@person, 'schooling') do %>