diff --git a/app/controllers/admin/dashboards_controller.rb b/app/controllers/admin/dashboards_controller.rb index 756c41b5..29d2459d 100644 --- a/app/controllers/admin/dashboards_controller.rb +++ b/app/controllers/admin/dashboards_controller.rb @@ -5,8 +5,9 @@ class Admin::DashboardsController < OrbitBackendController # before_filter :is_admin? def index - @module_app_contents, @module_app_contents_total = get_module_app_count('bulletin', 'page_context', 'web_link') - @recent_updated = get_recently_updated('bulletin', 'page_context', 'web_link') + check_backend_openness + @module_app_contents, @module_app_contents_total = get_module_app_count('bulletin', 'page_context', 'web_link') + @recent_updated = get_recently_updated('bulletin', 'page_context', 'web_link') @most_visited = get_most_visited('bulletin', 'page_context') end diff --git a/app/controllers/admin/sites_controller.rb b/app/controllers/admin/sites_controller.rb index 33f9582f..e9e581a9 100644 --- a/app/controllers/admin/sites_controller.rb +++ b/app/controllers/admin/sites_controller.rb @@ -16,6 +16,7 @@ class Admin::SitesController < OrbitBackendController def update @site.update_attributes(params[:site]) + site_restart redirect_to :back end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7bcd90e0..70e565c2 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -17,7 +17,15 @@ class ApplicationController < ActionController::Base helper_attr :site_valid_locales + def check_backend_openness + if !Me.backend_openness_on + redirect_to '/users/sign_in' if not (authenticate_user! and is_member? ) + end + end + def site_restart + Resque.enqueue(RestartServer) + end def set_current_user User.current = current_or_guest_user diff --git a/app/controllers/orbit_backend_controller.rb b/app/controllers/orbit_backend_controller.rb index 7c25e6fc..b9ede03e 100644 --- a/app/controllers/orbit_backend_controller.rb +++ b/app/controllers/orbit_backend_controller.rb @@ -15,6 +15,7 @@ class OrbitBackendController < ApplicationController private def force_order_for_visitor + check_backend_openness setup_vars set_current_user end diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 058b1843..f9bb0c3f 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -1,8 +1,15 @@ class PagesController < ApplicationController include ApplicationHelper before_filter :get_item, :only => [:index_from_link, :show_from_link] + before_filter :check_frontend_open, :only => [:index,:show] # caches_page :index + def check_frontend_open + if Me.frontend_closed + redirect_to '/admin/dashboards' + end + end + def index @item = Page.find_by_name('home') diff --git a/app/jobs/restart_server.rb b/app/jobs/restart_server.rb new file mode 100644 index 00000000..3ed5d072 --- /dev/null +++ b/app/jobs/restart_server.rb @@ -0,0 +1,8 @@ +class RestartServer + @queue = :high + + def self.perform() + temp_directory = "#{Rails.root}/tmp/" + %x[touch #{temp_directory}restart.txt ] + end +end diff --git a/app/models/site.rb b/app/models/site.rb index e2b2f8ed..c4df3fc3 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -11,6 +11,10 @@ class Site field :roaming_id field :private_key, :type => Binary field :public_key, :type => Binary + + field :frontend_closed, :type => Boolean, :default => false + field :backend_openness_on, :type => Boolean, :default => false + field :title_always_on, :type => Boolean, :default => false field :dashbroad_allow_visitor, :type => Boolean, :default => false field :mail_settings, :type => Hash diff --git a/app/views/admin/sites/site_info.html.erb b/app/views/admin/sites/site_info.html.erb index 56ac6adf..f8bd7efb 100644 --- a/app/views/admin/sites/site_info.html.erb +++ b/app/views/admin/sites/site_info.html.erb @@ -35,6 +35,14 @@ <% end %> <% end %> +
<%= (t 'site.search_help').html_safe %>
+