Sha256: 1ed3d44c81294abf4ca5158d13b8ae7833fdafc1f9384d7118149cc289b7ae90

Contents?: true

Size: 1.32 KB

Versions: 5

Compression:

Stored size: 1.32 KB

Contents

class Refinery::AdminBaseController < 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

  # never take the backend down for maintenance.
  def take_down_for_maintenance?;end

  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", :status => 404
  end

  def restrict_plugins
    Refinery::Plugins.set_active( current_user.authorized_plugins ) if current_user.respond_to? :plugins
  end

  def restrict_controller
    if Refinery::Plugins.active.reject {|plugin| params[:controller] !~ Regexp.new(plugin.menu_match) }.empty?
      flash.now[: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]}'"
    end
  end
  
  # Override method from application_controller. Not needed in this controller.
  def find_pages_for_menu; end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
refinerycms-0.9.5.28 vendor/plugins/refinery/lib/refinery/admin_base_controller.rb
refinerycms-0.9.5.27 vendor/plugins/refinery/lib/refinery/admin_base_controller.rb
refinerycms-0.9.5.26 vendor/plugins/refinery/lib/refinery/admin_base_controller.rb
refinerycms-0.9.5.25 vendor/plugins/refinery/lib/refinery/admin_base_controller.rb
refinerycms-0.9.5.24 vendor/plugins/refinery/lib/refinery/admin_base_controller.rb