diff --git a/app/assets/javascripts/member-selection.js b/app/assets/javascripts/member-selection.js index 443dbeb..075afc8 100644 --- a/app/assets/javascripts/member-selection.js +++ b/app/assets/javascripts/member-selection.js @@ -58,10 +58,20 @@ $(document).ready(function() { $("#remove_users").removeClass("hide"); } } + var is_category_disabled = function(id){ + var obj = app_categories.filter(function(c){return c.id == id})[0]; + return obj.disable; + } $("select[name=anything]").on("change",function(){ + $(".select_user_modal").removeClass("hide"); + $("#disabled_message_span").addClass("hide"); var value_to_filter = $(this).val(); if(value_to_filter != ""){ + if(is_category_disabled(value_to_filter)){ + $(".select_user_modal").addClass("hide"); + $("#disabled_message_span").removeClass("hide"); + } lis.each(function(){ var categories = $(this).data("categories"); if(categories.indexOf(value_to_filter) == -1){ diff --git a/app/controllers/admin/authorizations_controller.rb b/app/controllers/admin/authorizations_controller.rb index 8d1c82c..3c27621 100644 --- a/app/controllers/admin/authorizations_controller.rb +++ b/app/controllers/admin/authorizations_controller.rb @@ -7,7 +7,7 @@ class Admin::AuthorizationsController < OrbitAdminController if @module_apps && @module_apps.include?(@module_app) reload_users if (@module_app.categorizable || @module_app.categories.present?) - @objects = @module_app.categories rescue nil + @objects = @module_app.categories.order_by(:disable.asc) rescue nil end elsif @module_apps && @module_app.key == "authorization" redirect_to admin_authorizations_path(@module_apps.first.key) diff --git a/app/controllers/admin/import_controller.rb b/app/controllers/admin/import_controller.rb index e65970b..4176946 100644 --- a/app/controllers/admin/import_controller.rb +++ b/app/controllers/admin/import_controller.rb @@ -26,7 +26,7 @@ class Admin::ImportController < OrbitAdminController msg = "Failed to connect to RSS2 (#{uri.to_s})" end - render :json=>{"status"=>msg} + render :json=>{"status"=>msg}.to_json end def clean_old_data diff --git a/app/controllers/orbit_admin_controller.rb b/app/controllers/orbit_admin_controller.rb index 5e9aaac..c7e8636 100644 --- a/app/controllers/orbit_admin_controller.rb +++ b/app/controllers/orbit_admin_controller.rb @@ -4,6 +4,7 @@ class OrbitAdminController < ApplicationController include OrbitBackendHelper before_action :authenticate_user, :log_user_action, :load_authorized_categories + before_action :check_for_nil_categories, :only => [:new, :edit] layout "back_end" def sort @@ -81,4 +82,11 @@ class OrbitAdminController < ApplicationController @current_user_is_sub_manager = current_user.is_sub_manager?(@module_app) rescue false end + def check_for_nil_categories + @user_authorized_categories = @module_app.categories.enabled.authorized(current_user) + if @current_user_is_sub_manager && @user_authorized_categories.blank? + render_403 + end + end + end diff --git a/app/controllers/page_parts_controller.rb b/app/controllers/page_parts_controller.rb index dcfbc4a..d2d5eaf 100644 --- a/app/controllers/page_parts_controller.rb +++ b/app/controllers/page_parts_controller.rb @@ -41,7 +41,7 @@ class PagePartsController < ApplicationController app = ModuleApp.find_by_key(module_name) rescue nil app = OrbitWidget.find_by_key(module_name) if app.nil? - @categories = app.categories rescue [] + @categories = app.categories.enabled rescue [] @tags = app.tags rescue [] @widget_methods = app.widget_methods @widget_settings = app.widget_settings @@ -100,7 +100,7 @@ class PagePartsController < ApplicationController module_name = module_name.downcase.singularize app = ModuleApp.find_by_key(module_name) rescue nil app = OrbitWidget.find_by_key(module_name) if app.nil? - @categories = app.categories rescue [] + @categories = app.categories.enabled rescue [] @tags = app.tags rescue [] @widget_methods = app.widget_methods @widget_settings = app.widget_settings diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index fc39620..dc3e5b4 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -74,12 +74,19 @@ class PagesController < ApplicationController params[:layout_type] = params[:method] || page.layout || "index" end params[:url] = page.url - + categories = [] + page.categories.each do |c| + category = Category.find(c) rescue nil + if !category.nil? && !category.disable + categories << c + end + end + categories = ["all"] if categories.blank? @manifest = @key OrbitHelper.set_params params,current_user OrbitHelper.set_site_locale locale OrbitHelper.set_this_module_app module_app.singularize - OrbitHelper.set_page_categories page.categories || [] + OrbitHelper.set_page_categories categories || ["all"] OrbitHelper.set_page_tags page.tags || [] OrbitHelper.set_page_role_status page.role_status || [] OrbitHelper.set_member_sort_position page.member_sort_position @@ -164,7 +171,7 @@ class PagesController < ApplicationController end else if !module_app.key.eql?("page_content") - categories = module_app.categories.collect do |cat| + categories = module_app.categories.enabled.collect do |cat| { "title" => cat.title, "id" => cat.id.to_s @@ -203,7 +210,7 @@ class PagesController < ApplicationController @pages = Page.where(:page_id.ne => "" , :page_id.exists => true) @modules = ModuleApp.all.frontend_enabled @module_app = ModuleApp.find_by_key(@page.module) rescue nil - @categories = @module_app.categories rescue [] + @categories = @module_app.categories.enabled rescue [] if @module_app.key.eql?("page_content") @categories = [] end @@ -283,13 +290,13 @@ class PagesController < ApplicationController partials = [] subparts.each do |subpart| if subpart.kind == "module_widget" + OrbitHelper.set_current_widget subpart OrbitHelper.set_widget_data_count subpart.data_count - OrbitHelper.set_widget_categories subpart.categories OrbitHelper.set_widget_module_app subpart.module OrbitHelper.set_widget_item_url subpart OrbitHelper.set_widget_title subpart.title - OrbitHelper.set_widget_categories subpart.categories || [] + OrbitHelper.set_widget_categories subpart.categories || ["all"] OrbitHelper.set_widget_tags subpart.tags || [] custom_value = subpart.custom_string_field || subpart.custom_array_field rescue nil if !custom_value.nil? diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0d37af4..624d2f5 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -246,7 +246,7 @@ module ApplicationHelper end html.html_safe else - return "
It seems we have a problem with the module at this point of time, we will try to fix it as soon as possible. Sorry for the inconvenience!! :(
".html_safe + return "
No content to show.
".html_safe end else f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', params[:target_controller].singularize, "#{params[:target_action]}.html.erb") @@ -257,7 +257,7 @@ module ApplicationHelper controller = "#{params[:target_controller].capitalize}_controller".classify.constantize.new data = controller.send("#{params[:target_action]}") rescue nil if data.nil? - return "
It seems we have a problem with the module at this point of time, we will try to fix it as soon as possible. Sorry for the inconvenience!! :(
".html_safe + return "
No content to show.
".html_safe end if data.blank? || data.empty? diff --git a/app/helpers/orbit_backend_helper.rb b/app/helpers/orbit_backend_helper.rb index f7bc45c..304fa29 100644 --- a/app/helpers/orbit_backend_helper.rb +++ b/app/helpers/orbit_backend_helper.rb @@ -87,7 +87,8 @@ module OrbitBackendHelper def select_category(f, module_app) - render :partial => '/admin/categories/select_form', :locals => {:f=> f, :module_app=>module_app, :categories=>module_app.categories.enabled.authorized(current_user) } + @user_authorized_categories = module_app.categories.enabled.authorized(current_user) if @user_authorized_categories.nil? + render :partial => '/admin/categories/select_form', :locals => {:f=> f, :module_app=>module_app, :categories=> @user_authorized_categories } end def select_tags(f, module_app) @@ -193,6 +194,10 @@ module OrbitBackendHelper render "public/401" end + def render_403 + render "public/403" + end + def need_access_right render_401 if !has_access? end diff --git a/app/helpers/orbit_helper.rb b/app/helpers/orbit_helper.rb index 2b87dfc..cd133a6 100644 --- a/app/helpers/orbit_helper.rb +++ b/app/helpers/orbit_helper.rb @@ -280,7 +280,14 @@ module OrbitHelper end def self.set_widget_categories(categories) - @widget_categories = categories + @widget_categories = [] + categories.each do |c| + category = Category.find(c) rescue nil + if !category.nil? && !category.disable + @widget_categories << c + end + end + @widget_categories = ["all"] if @widget_categories.blank? end def self.widget_categories diff --git a/app/helpers/pages_helper.rb b/app/helpers/pages_helper.rb index 54dd677..4d451ae 100644 --- a/app/helpers/pages_helper.rb +++ b/app/helpers/pages_helper.rb @@ -87,7 +87,7 @@ module PagesHelper end html.html_safe else - return "
It seems we have a problem with the module at this point of time, we will try to fix it as soon as possible. Sorry for the inconvenience!! :(
".html_safe + return "
No content to show.
".html_safe end end diff --git a/app/views/admin/authorizations/index.html.erb b/app/views/admin/authorizations/index.html.erb index b2f76ce..8725323 100644 --- a/app/views/admin/authorizations/index.html.erb +++ b/app/views/admin/authorizations/index.html.erb @@ -49,8 +49,17 @@

Sub Managers

+ <%= t(:category_disabled) %>
- \ No newline at end of file + + \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index c45c6e3..659ca3a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -26,6 +26,8 @@ en: zh_tw_: Traditional Chinese zh_cn: Simplified Chinese _locale: English + category_notice: "Category once created, cannot be deleted." + category_disabled: "This category is disabled." access: denied: ajax_401_error: "User session has been expired,please login again." diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index c501af4..9f99e3c 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -5,6 +5,9 @@ zh_tw: zh_tw_: 繁體中文 zh_cn: 简体中文 en: 英文 + category_notice: 類別一但被建立,就不能刪除喔! + category_disabled: 此類別已被關閉 + access: denied: ajax_401_error: 使用者已逾時或是登出,請重新登入 diff --git a/public/403.html b/public/403.html new file mode 100644 index 0000000..8e9c880 --- /dev/null +++ b/public/403.html @@ -0,0 +1,18 @@ + + +
+
+
+
+

Categories not present.

+

You dont have any categories assigned or your assigned categories are disabled. Contact manager or admin.

+
+
+
+ \ No newline at end of file diff --git a/public/version-orbit-4-5 b/public/version-orbit-4-5 new file mode 100644 index 0000000..5a73712 --- /dev/null +++ b/public/version-orbit-4-5 @@ -0,0 +1 @@ +version = "4.5"