Commit 073f57b540beb039e79d76bf665cac75f1534604

Authored by Antonio Terceiro
1 parent da26a752

Recovering most recent code for ApplicationController

Showing 1 changed file with 15 additions and 5 deletions   Show diff stats
app/controllers/application_controller.rb
@@ -83,6 +83,7 @@ class ApplicationController < ActionController::Base @@ -83,6 +83,7 @@ class ApplicationController < ActionController::Base
83 include NeedsProfile 83 include NeedsProfile
84 84
85 before_filter :detect_stuff_by_domain 85 before_filter :detect_stuff_by_domain
  86 + before_filter :init_noosfero_plugins
86 attr_reader :environment 87 attr_reader :environment
87 88
88 before_filter :load_terminology 89 before_filter :load_terminology
@@ -93,8 +94,16 @@ class ApplicationController < ActionController::Base @@ -93,8 +94,16 @@ class ApplicationController < ActionController::Base
93 verify :method => :post, :only => actions, :redirect_to => redirect 94 verify :method => :post, :only => actions, :redirect_to => redirect
94 end 95 end
95 96
  97 + helper_method :current_person, :current_person
  98 +
96 protected 99 protected
97 100
  101 + def user
  102 + current_user.person if logged_in?
  103 + end
  104 +
  105 + alias :current_person :user
  106 +
98 # TODO: move this logic somewhere else (Domain class?) 107 # TODO: move this logic somewhere else (Domain class?)
99 def detect_stuff_by_domain 108 def detect_stuff_by_domain
100 @domain = Domain.find_by_name(request.host) 109 @domain = Domain.find_by_name(request.host)
@@ -106,6 +115,10 @@ class ApplicationController < ActionController::Base @@ -106,6 +115,10 @@ class ApplicationController < ActionController::Base
106 end 115 end
107 end 116 end
108 117
  118 + def init_noosfero_plugins
  119 + @plugins = Noosfero::Plugin::Manager.new(self)
  120 + end
  121 +
109 def load_terminology 122 def load_terminology
110 # cache terminology for performance 123 # cache terminology for performance
111 @@terminology_cache ||= {} 124 @@terminology_cache ||= {}
@@ -116,8 +129,9 @@ class ApplicationController < ActionController::Base @@ -116,8 +129,9 @@ class ApplicationController < ActionController::Base
116 def render_not_found(path = nil) 129 def render_not_found(path = nil)
117 @no_design_blocks = true 130 @no_design_blocks = true
118 @path ||= request.path 131 @path ||= request.path
119 - render :template => 'shared/not_found.rhtml', :status => 404 132 + render :template => 'shared/not_found.rhtml', :status => 404, :layout => get_layout
120 end 133 end
  134 + alias :render_404 :render_not_found
121 135
122 def render_access_denied(message = nil, title = nil) 136 def render_access_denied(message = nil, title = nil)
123 @no_design_blocks = true 137 @no_design_blocks = true
@@ -126,10 +140,6 @@ class ApplicationController < ActionController::Base @@ -126,10 +140,6 @@ class ApplicationController < ActionController::Base
126 render :template => 'shared/access_denied.rhtml', :status => 403 140 render :template => 'shared/access_denied.rhtml', :status => 403
127 end 141 end
128 142
129 - def user  
130 - current_user.person if logged_in?  
131 - end  
132 -  
133 def load_category 143 def load_category
134 unless params[:category_path].blank? 144 unless params[:category_path].blank?
135 path = params[:category_path].join('/') 145 path = params[:category_path].join('/')