Commit ee3bc30102b67d65a69de55e233394af31f565f7
1 parent
91659d7b
Exists in
master
and in
29 other branches
Recover changes to ApplicationController
These changes were lost when I merged the master branch because of the move from app/controllers/application.rb to app/controllers/application_controller.rb. I did not notice that app/controllers/application.rb had changes that needed to be merged in app/controllers/application_controller.rb
Showing
1 changed file
with
32 additions
and
7 deletions
Show diff stats
app/controllers/application_controller.rb
1 | -# his is the application's main controller. Features defined here are | ||
2 | -# available in all controllers. | ||
3 | class ApplicationController < ActionController::Base | 1 | class ApplicationController < ActionController::Base |
4 | 2 | ||
3 | + before_filter :change_pg_schema | ||
4 | + | ||
5 | include ApplicationHelper | 5 | include ApplicationHelper |
6 | layout :get_layout | 6 | layout :get_layout |
7 | def get_layout | 7 | def get_layout |
@@ -23,11 +23,6 @@ class ApplicationController < ActionController::Base | @@ -23,11 +23,6 @@ class ApplicationController < ActionController::Base | ||
23 | helper :document | 23 | helper :document |
24 | helper :language | 24 | helper :language |
25 | 25 | ||
26 | - def boxes_editor? | ||
27 | - false | ||
28 | - end | ||
29 | - protected :boxes_editor? | ||
30 | - | ||
31 | def self.no_design_blocks | 26 | def self.no_design_blocks |
32 | @no_design_blocks = true | 27 | @no_design_blocks = true |
33 | end | 28 | end |
@@ -70,6 +65,21 @@ class ApplicationController < ActionController::Base | @@ -70,6 +65,21 @@ class ApplicationController < ActionController::Base | ||
70 | 65 | ||
71 | protected | 66 | protected |
72 | 67 | ||
68 | + def change_pg_schema | ||
69 | + if Noosfero::MultiTenancy.on? and ActiveRecord::Base.postgresql? | ||
70 | + Noosfero::MultiTenancy.db_by_host = request.host | ||
71 | + end | ||
72 | + end | ||
73 | + | ||
74 | + def boxes_editor? | ||
75 | + false | ||
76 | + end | ||
77 | + | ||
78 | + def content_editor? | ||
79 | + false | ||
80 | + end | ||
81 | + | ||
82 | + | ||
73 | def user | 83 | def user |
74 | current_user.person if logged_in? | 84 | current_user.person if logged_in? |
75 | end | 85 | end |
@@ -89,6 +99,21 @@ class ApplicationController < ActionController::Base | @@ -89,6 +99,21 @@ class ApplicationController < ActionController::Base | ||
89 | 99 | ||
90 | def init_noosfero_plugins | 100 | def init_noosfero_plugins |
91 | @plugins = Noosfero::Plugin::Manager.new(self) | 101 | @plugins = Noosfero::Plugin::Manager.new(self) |
102 | + @plugins.enabled_plugins.map(&:class).each do |plugin| | ||
103 | + prepend_view_path(plugin.view_path) | ||
104 | + end | ||
105 | + init_noosfero_plugins_controller_filters | ||
106 | + end | ||
107 | + | ||
108 | + # This is a generic method that initialize any possible filter defined by a | ||
109 | + # plugin to the current controller being initialized. | ||
110 | + def init_noosfero_plugins_controller_filters | ||
111 | + @plugins.enabled_plugins.each do |plugin| | ||
112 | + plugin.send(self.class.name.underscore + '_filters').each do |plugin_filter| | ||
113 | + self.class.send(plugin_filter[:type], plugin.class.name.underscore + '_' + plugin_filter[:method_name], (plugin_filter[:options] || {})) | ||
114 | + self.class.send(:define_method, plugin.class.name.underscore + '_' + plugin_filter[:method_name], plugin_filter[:block]) | ||
115 | + end | ||
116 | + end | ||
92 | end | 117 | end |
93 | 118 | ||
94 | def load_terminology | 119 | def load_terminology |