diff --git a/app/controllers/static_controller.rb b/app/controllers/static_controller.rb index fa15fd127ff..76b6a209419 100644 --- a/app/controllers/static_controller.rb +++ b/app/controllers/static_controller.rb @@ -4,10 +4,18 @@ class StaticController < ApplicationController def show + map = { + "faq" => "faq_url", + "tos" => "tos_url", + "privacy" => "privacy_policy_url" + } + page = params[:id] - return redirect_to(SiteSetting.tos_url) if page == 'tos' and !SiteSetting.tos_url.blank? - return redirect_to(SiteSetting.privacy_policy_url) if page == 'privacy' and !SiteSetting.privacy_policy_url.blank? + if site_setting_key = map[page] + url = SiteSetting.send(site_setting_key) + return redirect_to(url) unless url.blank? + end # Don't allow paths like ".." or "/" or anything hacky like that page.gsub!(/[^a-z0-9\_\-]/, '') diff --git a/app/models/site_setting.rb b/app/models/site_setting.rb index 2debba0719d..97acbcee37b 100644 --- a/app/models/site_setting.rb +++ b/app/models/site_setting.rb @@ -15,6 +15,7 @@ class SiteSetting < ActiveRecord::Base setting(:company_short_name, 'Unconfigured Forum') setting(:company_domain, 'www.example.com') setting(:tos_url, '') + client_setting(:faq_url, '') setting(:privacy_policy_url, '') setting(:api_key, '') client_setting(:traditional_markdown_linebreaks, false) diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 4c47aff6bcf..3f2e94a4b5b 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -613,6 +613,7 @@ en: topic_views_heat_medium: "The number of views after which a topic's heat level is medium." topic_views_heat_high: "The number of views after which a topic's heat level is high." + faq_url: "If you have a FAQ hosted elsewhere that you want to use, provide the full URL here." tos_url: "If you have a Terms of Service document hosted elsewhere that you want to use, provide the full URL here." privacy_policy_url: "If you have a Privacy Policy document hosted elsewhere that you want to use, provide the full URL here."