class FeaturesController < AdminController protect 'edit_environment_features', :environment def index @features = Environment.available_features.sort_by{|k,v|v} end post_only :update def update if @environment.update_attributes(params[:environment]) session[:notice] = _('Features updated successfully.') redirect_to :action => 'index' else render :action => 'index' end end def manage_fields @person_fields = Person.fields @custom_person_fields = (@environment.settings[:custom_person_fields] || {}).keys.reject {|key| ! (key =~ /^custom_field/) } @enterprise_fields = Enterprise.fields @custom_enterprise_fields = (@environment.settings[:custom_enterprise_fields] || {}).keys.reject {|key| ! (key =~ /^custom_field/) } @community_fields = Community.fields @custom_community_fields = (@environment.settings[:custom_community_fields] || {}).keys.reject {|key| ! (key =~ /^custom_field/) } end def manage_person_fields environment.custom_person_fields = params[:person_fields] if environment.save! session[:notice] = _('Person fields updated successfully.') else flash[:error] = _('Person fields not updated successfully.') end redirect_to :action => 'manage_fields' end def manage_enterprise_fields environment.custom_enterprise_fields = params[:enterprise_fields] if environment.save! session[:notice] = _('Enterprise fields updated successfully.') else flash[:error] = _('Enterprise fields not updated successfully.') end redirect_to :action => 'manage_fields' end def manage_community_fields environment.custom_community_fields = params[:community_fields] if environment.save! session[:notice] = _('Community fields updated successfully.') else flash[:error] = _('Community fields not updated successfully.') end redirect_to :action => 'manage_fields' end end