Sha256: 0861fab2cc60a5c58d417f09616d56c10a082bf106c278a28b949273a529c9d1

Contents?: true

Size: 1.58 KB

Versions: 6

Compression:

Stored size: 1.58 KB

Contents

module ::Refinery
  module Admin
    class SettingsController < ::Refinery::AdminController

      helper "refinery/admin/settings"

      crudify :'refinery/setting',
              :order => "name ASC",
              :redirect_to_url => :redirect_to_where?,
              :xhr_paging => true

      before_filter :sanitise_params, :only => [:create, :update]

      def new
        form_value_type = ((current_refinery_user.has_role?(:superuser) && params[:form_value_type]) || 'text_area')
        @setting = ::Refinery::Setting.new(:form_value_type => form_value_type)
      end

      def edit
        @setting = ::Refinery::Setting.find(params[:id])

        render :layout => false if request.xhr?
      end

    protected
      def find_all_settings
        @settings = ::Refinery::Setting.order('name ASC')

        unless current_refinery_user.has_role?(:superuser)
          @settings = @settings.where("restricted <> ? ", true)
        end

        @settings
      end

      def search_all_settings
        # search for settings that begin with keyword
        term = "^" + params[:search].to_s.downcase.gsub(' ', '_')

        # First find normal results, then weight them with the query.
         @settings = find_all_settings.with_query(term)
      end

    private
      def redirect_to_where?
        (from_dialog? && session[:return_to].present?) ? session[:return_to] : refinery.admin_settings_path
      end

      # this fires before an update or create to remove any attempts to pass sensitive arguments.
      def sanitise_params
        params.delete(:scoping)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
refinerycms-settings-2.1.1 app/controllers/refinery/admin/settings_controller.rb
refinerycms-settings-2.1.0 app/controllers/refinery/admin/settings_controller.rb
refinerycms-settings-2.0.3 app/controllers/refinery/admin/settings_controller.rb
refinerycms-settings-2.0.2 app/controllers/refinery/admin/settings_controller.rb
refinerycms-settings-2.0.1 app/controllers/refinery/admin/settings_controller.rb
refinerycms-settings-2.0.0 app/controllers/refinery/admin/settings_controller.rb