diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 6bc21b1b..8e62edac 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -145,11 +145,14 @@ class ApplicationController < ActionController::Base condition = VALID_LOCALES.include?(session[:locale]) elsif session[:locale] condition = @site.in_use_locales.include?(session[:locale]) + elsif @site.default_locale.present? + default_locale = @site.default_locale + condition = @site.valid_locales.include?(default_locale) else browser_locale = request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first rescue nil condition = @site.in_use_locales.include?(browser_locale) end - session[:locale] = condition ? (browser_locale || session[:locale]) : I18n.default_locale.to_s + session[:locale] = condition ? (default_locale || browser_locale || session[:locale]) : I18n.default_locale.to_s I18n.locale = session[:locale].to_sym @site_in_use_locales = site_locales_default_head(@site.in_use_locales) @site_valid_locales = site_locales_default_head(@site.valid_locales) diff --git a/app/controllers/desktop_controller.rb b/app/controllers/desktop_controller.rb index 6c323d54..ab5856d1 100644 --- a/app/controllers/desktop_controller.rb +++ b/app/controllers/desktop_controller.rb @@ -1,9 +1,12 @@ class DesktopController< ApplicationController layout 'desktop' before_filter :authenticate_user! + before_filter :check_desktop_open, :only => [:index,:show] #to load pages... - + + # caches_page :index + def index @desktop = current_user.desktop @currentusername = current_user.name @@ -335,7 +338,14 @@ class DesktopController< ApplicationController b = {"success"=>"true"} render :json=>b.to_json end + + private + def check_desktop_open + if Me.desktop_closed && current_user.nil? #Need to be change + redirect_to '/admin/dashboards' + end + end end diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 032910eb..a85c6548 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -4,12 +4,6 @@ class PagesController < ApplicationController before_filter :check_frontend_open, :only => [:index,:show] # caches_page :index - def check_frontend_open - if Me.frontend_closed and current_user.nil? #Need to be change - redirect_to '/admin/dashboards' - end - end - def index @item = Page.find_by_name('home') @@ -117,6 +111,12 @@ class PagesController < ApplicationController end raise PageError,'Missing Frontend Page' if @item.nil? end + + def check_frontend_open + if Me.frontend_closed && current_user.nil? #Need to be change + redirect_to '/admin/dashboards' + end + end def save_from_no_lang_for_page if @item.nil? or !@item.enabled_for_lang(I18n.locale.to_s) diff --git a/app/models/site.rb b/app/models/site.rb index 7967c539..331f3179 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -14,10 +14,12 @@ class Site field :frontend_closed, :type => Boolean, :default => false field :backend_openness_on, :type => Boolean, :default => false + field :desktop_closed, :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 + field :enabled_for, :type => Array, :default => nil field :disk_space, :type => String field :system_package_info, :type => Hash,:default=>{} @@ -34,6 +36,7 @@ class Site field :sub_menu, localize: true field :terms_of_user, localize: true field :google_analytics + field :default_locale field :mobile_on, :type => Boolean, :default => false diff --git a/app/views/admin/sites/preference.html.erb b/app/views/admin/sites/preference.html.erb index f7e8b2e4..26c42793 100644 --- a/app/views/admin/sites/preference.html.erb +++ b/app/views/admin/sites/preference.html.erb @@ -130,7 +130,7 @@
- + <%= f.check_box :desktop_open , :class=>"toggle-check" %>
@@ -138,24 +138,29 @@
-
+
- - + <% @site_in_use_locales.each do |locale| %> + <%= check_box_tag :default_locale, locale, :class=>"toggle-check" %> + <%= I18nVariable.from_locale(locale) %> + <% end %>
- - + <% @site_valid_locales.each do |valid_locale| %> + <%= check_box_tag 'site[enabled_for][]', valid_locale, (@site.enabled_for.nil?), :class=>"toggle-check" %> + <%= I18nVariable.from_locale(valid_locale) %> + <% end %> + <%= hidden_field_tag 'site[enabled_for][]', '' %>