Sha256: 1e79e27f00f1434f208fea6498c9a1d38e75bade1d61604aaada70413d37e1a3

Contents?: true

Size: 1.79 KB

Versions: 8

Compression:

Stored size: 1.79 KB

Contents

class Admin::ApplicationController < Spud::ApplicationController

  before_filter :require_admin_user
  before_filter :verify_site_mode
  add_breadcrumb "Dashboard", :admin_root_path
  layout 'admin/detail'
  respond_to :html, :json, :xml, :js
  unloadable

  rescue_from Spud::AccessDeniedError do |exception|
    redirect_to admin_root_path, :flash => {:error => exception.message}
  end

  def current_admin_site
    if(session[:admin_site] == nil)
      return 0
    else
      return session[:admin_site]
    end
  end

private

  def require_admin_user
    if current_user.blank?
      flash[:notice] = "You must be logged in to access the requested page"
      redirect_to admin_login_path
      return false
    elsif !current_user.has_admin_rights?
      flash[:notice] = "You do not have permission to access the requested page"
      redirect_to root_path
      return false
    else
      return true
    end
  end

  def verify_site_mode
    if(session[:admin_site] == nil)
      session[:admin_site] = 0
    end

  end

  def multisite_caching
    if Spud::Core.multisite_mode_enabled
      @old_cache_directory = Rails.application.config.action_controller.page_cache_directory
      if(@old_cache_directory.blank?)
        @old_cache_directory = Rails.application.config.action_controller.page_cache_directory = File.join(Rails.root,'public')
      end
      if session && session[:admin_site]
        site_config = Spud::Core.site_config_for_id(session[:admin_site])
      else
        site_config = Spud::Core.site_config_for_host(request.host_with_port)
      end
      self.class.page_cache_directory = File.join(@old_cache_directory.to_s, site_config[:short_name].to_s.downcase)
      logger.debug "Cache directory set to: #{Rails.application.config.action_controller.page_cache_directory}"
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
tb_core-1.1.10 app/controllers/admin/application_controller.rb
tb_core-1.1.9 app/controllers/admin/application_controller.rb
tb_core-1.1.8 app/controllers/admin/application_controller.rb
tb_core-1.1.7 app/controllers/admin/application_controller.rb
tb_core-1.1.6 app/controllers/admin/application_controller.rb
tb_core-1.1.5 app/controllers/admin/application_controller.rb
tb_core-1.1.4 app/controllers/admin/application_controller.rb
tb_core-1.1.2 app/controllers/admin/application_controller.rb