diff --git a/app/controllers/my_profile/profile_editor_controller.rb b/app/controllers/my_profile/profile_editor_controller.rb index 62911e4..934479d 100644 --- a/app/controllers/my_profile/profile_editor_controller.rb +++ b/app/controllers/my_profile/profile_editor_controller.rb @@ -5,6 +5,7 @@ class ProfileEditorController < MyProfileController before_filter :access_welcome_page, :only => [:welcome_page] before_filter :back_to + before_filter :forbid_destroy_profile, :only => [:destroy_profile] helper_method :has_welcome_page def index @@ -155,4 +156,10 @@ class ProfileEditorController < MyProfileController end end + def forbid_destroy_profile + if environment.enabled?('forbid_destroy_profile') && !current_person.is_admin?(environment) + session[:notice] = _('You can not destroy the profile.') + redirect_to_previous_location + end + end end diff --git a/app/models/environment.rb b/app/models/environment.rb index f39efb9..1a1d9d8 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -128,6 +128,7 @@ class Environment < ActiveRecord::Base 'disable_select_city_for_contact' => _('Disable state/city select for contact form'), 'disable_contact_person' => _('Disable contact for people'), 'disable_contact_community' => _('Disable contact for groups/communities'), + 'forbid_destroy_profile' => _('Forbid users of removing profiles'), 'products_for_enterprises' => _('Enable products for enterprises'), 'enterprise_registration' => _('Enterprise registration'), diff --git a/app/views/profile_editor/edit.html.erb b/app/views/profile_editor/edit.html.erb index a02ed3c..daeb8cd 100644 --- a/app/views/profile_editor/edit.html.erb +++ b/app/views/profile_editor/edit.html.erb @@ -75,14 +75,23 @@ <% if user && user.has_permission?('destroy_profile', profile) %> <% button_bar(:id => 'delete-profile') do %> - <%= button(:remove, _('Delete profile'), {:action => :destroy_profile}) %> - <% if environment.admins.include?(current_person) %> + <% if !environment.enabled?('forbid_destroy_profile') || user.is_admin?(environment) %> + <%= button(:remove, _('Delete profile'), {:action => :destroy_profile}) %> + <% end %> + <% if user.is_admin?(environment) %> <% if profile.visible? %> - <%= button(:remove, _('Deactivate profile'), {:action => :deactivate_profile, :id=>profile.id}, :id=>'deactivate_profile_button', :data => {:confirm=>_("Are you sure you want to deactivate this profile?")}) %> + <%= button(:remove, _('Deactivate profile'), + {:action => :deactivate_profile, :id=>profile.id}, + :id=>'deactivate_profile_button', + :data => {:confirm=>_("Are you sure you want to deactivate this profile?")}) + %> <% else %> - <%= button(:add, _('Activate profile'), {:action => :activate_profile, :id=>profile.id}, :data => {:confirm=>_("Are you sure you want to deactivate this profile?")}) %> + <%= button(:add, _('Activate profile'), + {:action => :activate_profile, :id=>profile.id}, + :data => {:confirm=>_("Are you sure you want to deactivate this profile?")}) + %> <% end %> <% end %> <% end %> diff --git a/app/views/shared/_list_groups.html.erb b/app/views/shared/_list_groups.html.erb index 6ec3108..05466a7 100644 --- a/app/views/shared/_list_groups.html.erb +++ b/app/views/shared/_list_groups.html.erb @@ -1,28 +1,32 @@