Sha256: efe761b57e7d4c2fa4795df83816ad3112445051e734e8d44645e9bc5abb7f72

Contents?: true

Size: 1.67 KB

Versions: 16

Compression:

Stored size: 1.67 KB

Contents

class ReaderActionController < ApplicationController
  include Radiant::Pagination::Controller

  helper :reader
  helper_method :current_site, :current_site=, :logged_in?, :logged_in_user?, :logged_in_admin?
  
  no_login_required
  
  # reader session is normally required for modifying actions
  before_filter :require_reader, :except => [:index, :show]
  
  radiant_layout { |controller| Radiant::Config['reader.layout'] }

  # authorisation helpers

  def logged_in?
    true if current_reader
  end

  def logged_in_user?
    true if logged_in? && current_reader.is_user?
  end

  def logged_in_admin?
    true if logged_in_user? && current_reader.admin?
  end

  def permission_denied
    session[:return_to] ||= request.referer
    @title = flash[:error] || t('reader_extension.permission_denied')
    render
  end
  
  def default_welcome_url(reader=nil)
    (reader && reader.home_url) || reader_dashboard_url
  end

protected
  
  # NB. ReaderError exceptions are caught in ApplicationController rescue_froms
    
  def require_reader
    unless set_reader     # set_reader is added to ApplicationController and sets Reader.current while checking authentication
      store_location
      raise ReaderError::LoginRequired, t('reader_extension.please_log_in')
      false
    end
  end
  
  def require_activated_reader
    unless current_reader && current_reader.activated?
      raise ReaderError::ActivationRequired, t('reader_extension.activation_required')
      false
    end
  end

  def require_no_reader
    if set_reader
      store_location
      flash[:notice] = t('reader_extension.please_log_out')
      redirect_back_or_to url_for(current_reader)
      return false
    end
  end
  
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
radiant-reader-extension-3.0.17 app/controllers/reader_action_controller.rb
radiant-reader-extension-3.0.16 app/controllers/reader_action_controller.rb
radiant-reader-extension-3.0.15 app/controllers/reader_action_controller.rb
radiant-reader-extension-3.0.14 app/controllers/reader_action_controller.rb
radiant-reader-extension-3.0.13 app/controllers/reader_action_controller.rb
radiant-reader-extension-3.0.11 app/controllers/reader_action_controller.rb
radiant-reader-extension-3.0.10 app/controllers/reader_action_controller.rb
radiant-reader-extension-3.0.9 app/controllers/reader_action_controller.rb
radiant-reader-extension-3.0.8 app/controllers/reader_action_controller.rb
radiant-reader-extension-3.0.7 app/controllers/reader_action_controller.rb
radiant-reader-extension-3.0.5 app/controllers/reader_action_controller.rb
radiant-reader-extension-3.0.4 app/controllers/reader_action_controller.rb
radiant-reader-extension-3.0.3 app/controllers/reader_action_controller.rb
radiant-reader-extension-3.0.2 app/controllers/reader_action_controller.rb
radiant-reader-extension-3.0.1 app/controllers/reader_action_controller.rb
radiant-reader-extension-3.0.0 app/controllers/reader_action_controller.rb