Module: GroupedControllerExtensions

Defined in:
lib/grouped_controller_extensions.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/grouped_controller_extensions.rb', line 3

def self.included(base)
  base.class_eval {
    before_filter :require_visibility_to_reader

  protected
    
    def require_visibility_to_reader
      if @page && !@page.visible_to?(current_reader)
        flash[:error] = t("page_not_public")
        redirect_to reader_permission_denied_url
        return false
      end
      
      if @forum && !@forum.visible_to?(current_reader)
        flash[:error] = "forum_not_public"
        redirect_to reader_permission_denied_url
        return false
      end
    end
  }
end