Sha256: 317c3cd1d3dcd4fa279b2b8d5188ce410d4631e60165bb2992130dee2f47a8b8

Contents?: true

Size: 1.21 KB

Versions: 8

Compression:

Stored size: 1.21 KB

Contents

class Admin::BaseController < ApplicationController
  
  layout proc { |controller| "admin#{"_dialog" if controller.from_dialog?}" }
  
  before_filter :login_required, :restrict_plugins, :restrict_controller

  helper_method :searching?

	def admin?
		true # we're in the admin base controller, so always true.
	end
	
	def searching?
    not params[:search].blank?
  end

protected

  def error_404
    @page = Page.find_by_menu_match("^/404$", :include => [:parts, :slugs])
    @page[:body] = @page[:body].gsub(/href=(\'|\")\/(\'|\")/, "href='/admin'").gsub("home page", "Dashboard")
    render :template => "/pages/show"
  end
  
  def restrict_plugins
    Refinery::Plugins.set_active( current_user.plugins.collect {|p| p.title} | Refinery::Plugins.always_allowed.titles ) if current_user.respond_to? :plugins
  end

	def restrict_controller
    if params[:controller] != "admin/base" and Refinery::Plugins.active.reject {|plugin| params[:controller] !~ Regexp.new(plugin.menu_match) }.empty?
			flash[:error] = "You do not have permission to access the #{params[:controller]} controller on this plugin."
			logger.warn("'#{current_user.login}' tried to access '#{params[:controller]}'")
			#redirect_to admin_root_url
		end
	end
  
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
refinerycms-0.9.3 vendor/plugins/refinery/app/controllers/admin/base_controller.rb
refinerycms-0.9.2.2 vendor/plugins/refinery/app/controllers/admin/base_controller.rb
refinerycms-0.9.2.1 vendor/plugins/refinery/app/controllers/admin/base_controller.rb
refinerycms-0.9.2 vendor/plugins/refinery/app/controllers/admin/base_controller.rb
refinerycms-0.9.1.2 vendor/plugins/refinery/app/controllers/admin/base_controller.rb
refinerycms-0.9.1.1 vendor/plugins/refinery/app/controllers/admin/base_controller.rb
refinerycms-0.9.1 vendor/plugins/refinery/app/controllers/admin/base_controller.rb
refinerycms-0.9.0 vendor/plugins/refinery/app/controllers/admin/base_controller.rb