diff --git a/app/models/module_app.rb b/app/models/module_app.rb index b64ac908..98fc719e 100644 --- a/app/models/module_app.rb +++ b/app/models/module_app.rb @@ -63,11 +63,31 @@ class ModuleApp end def is_manager?(user) - managing_users.include?(user) + if user.nil? + return false + else + m_users = managing_users + if m_users.blank? + false + else + m_users.include?(user) + end + end end def is_sub_manager?(user) - sub_managing_users.include?(user) || is_manager?(user) + if user.nil? + return false + else # when user is guest + s_m_users = sub_managing_users + result = false + if s_m_users.blank? + result = false + else + result = s_m_users.include?(user) + end + result || is_manager?(user) + end end def managing_users diff --git a/lib/orbit_app/helper/context_link_renderer.rb b/lib/orbit_app/helper/context_link_renderer.rb index d4014fae..530b0946 100644 --- a/lib/orbit_app/helper/context_link_renderer.rb +++ b/lib/orbit_app/helper/context_link_renderer.rb @@ -25,7 +25,7 @@ protected else (eval(available_for_in_sym).include? @current_user rescue false) end # of case - return true if result || @current_user.admin? + return true if result || (@current_user.admin? rescue false) end # of collect false end diff --git a/lib/orbit_app/helper/renderer.rb b/lib/orbit_app/helper/renderer.rb index ee2ffb23..70b0f111 100644 --- a/lib/orbit_app/helper/renderer.rb +++ b/lib/orbit_app/helper/renderer.rb @@ -8,10 +8,11 @@ module Renderer protected def active_for_app_auth? - if @module_app.nil? + module_app = get_module_app + if module_app.nil? false else - @module_app.id.to_s == @params[:module_app_id] ? true : false + module_app.id.to_s == @params[:module_app_id] ? true : false end end diff --git a/lib/orbit_app/helper/side_bar_renderer.rb b/lib/orbit_app/helper/side_bar_renderer.rb index ba6f7c7d..e0e1f994 100644 --- a/lib/orbit_app/helper/side_bar_renderer.rb +++ b/lib/orbit_app/helper/side_bar_renderer.rb @@ -25,7 +25,7 @@ module SideBarRenderer def display? #控制sidebar 要不要算圖 if is_manager? || is_admin? #如果是系統管理員 或 是模組管理員 true - elsif (@current_module_app.open rescue false) # 如果app 被設定成 開放 + elsif (@current_module_app.open rescue true) # 如果app 被設定成 開放 true elsif is_member? #如果app 是封閉 那至少需要是 member true diff --git a/vendor/built_in_modules/ad_banner/init.rb b/vendor/built_in_modules/ad_banner/init.rb index 6776ee0a..e4c7f8cc 100644 --- a/vendor/built_in_modules/ad_banner/init.rb +++ b/vendor/built_in_modules/ad_banner/init.rb @@ -35,12 +35,12 @@ module AdBanner side_bar do head_label_i18n 'admin.ad_banner',:icon_class=>"icons-landscape" available_for [:admin,:guest,:manager,:sub_manager] - active_for_controllers ({:private=>['ad_banners', 'ad_images']}) + active_for_controllers ({:public=>['admin/ad_banners', 'admin/ad_images']}) head_link_path "admin_ad_banners_path" context_link 'module_authorization', - :link_path=>"admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {key: 'ad_banner'}))", + :link_path=>"admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {title: 'AdBanner'}))", :priority=>6, :active_for_app_auth => 'ad_banners', :available_for => [:admin] diff --git a/vendor/built_in_modules/archive/init.rb b/vendor/built_in_modules/archive/init.rb index 565b2cdf..23cc97b7 100644 --- a/vendor/built_in_modules/archive/init.rb +++ b/vendor/built_in_modules/archive/init.rb @@ -28,7 +28,7 @@ module Archive side_bar do head_label_i18n 'miss_module_i18n.archive',:icon_class=>"icons-archive" available_for [:admin,:guest,:manager,:sub_manager] - active_for_controllers ({:private=>['archive_file_categorys'],:public=>['panel/archive/back_end/tags']}) + active_for_controllers ({:private=>['archive_file_categorys','archive_files'],:public=>['panel/archive/back_end/tags']}) active_for_object_auth ['BulletinCategory'] head_link_path "panel_archive_back_end_archive_files_path" @@ -36,13 +36,13 @@ module Archive context_link 'miss_module_i18n._archive.all', :link_path=>"panel_archive_back_end_archive_files_path" , :priority=>1, - :active_for_action=>{:archive_file=>:index}, + :active_for_action=>{:archive_files=>:index}, :available_for => [:all] context_link 'add', :link_path=>"new_panel_archive_back_end_archive_file_path" , :priority=>2, - :active_for_action=>{:archive_file=>:new}, + :active_for_action=>{:archive_files=>:new}, :available_for => [:admin] context_link 'categories', diff --git a/vendor/built_in_modules/gallery/init.rb b/vendor/built_in_modules/gallery/init.rb index e7db1e81..3e7fa633 100644 --- a/vendor/built_in_modules/gallery/init.rb +++ b/vendor/built_in_modules/gallery/init.rb @@ -50,7 +50,7 @@ module Gallery :available_for => [:manager] context_link 'module_authorization', - :link_path=>"admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {key: 'gallery'}))", + :link_path=>"admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {title: 'Gallery'}))", :priority=>6, :active_for_app_auth => 'gallery', :available_for => [:admin] diff --git a/vendor/built_in_modules/page_content/init.rb b/vendor/built_in_modules/page_content/init.rb index 2bf8a2f7..73199b18 100644 --- a/vendor/built_in_modules/page_content/init.rb +++ b/vendor/built_in_modules/page_content/init.rb @@ -24,7 +24,7 @@ module PageContent head_link_path "panel_page_content_back_end_page_contexts_path" context_link 'module_authorization', - :link_path=>"admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {key: 'page_content'}))", + :link_path=>"admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {title: 'PageContent'}))", :priority=>1, :active_for_app_auth => 'PageContext', :available_for => [:admin] diff --git a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_link_categorys/_web_link_category.html.erb b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_link_categorys/_web_link_category.html.erb index f78b9878..bb278435 100644 --- a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_link_categorys/_web_link_category.html.erb +++ b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_link_categorys/_web_link_category.html.erb @@ -8,7 +8,7 @@
<% end -%> diff --git a/vendor/built_in_modules/web_resource/init.rb b/vendor/built_in_modules/web_resource/init.rb index c581506b..3362849a 100644 --- a/vendor/built_in_modules/web_resource/init.rb +++ b/vendor/built_in_modules/web_resource/init.rb @@ -36,19 +36,19 @@ module WebResource context_link 'list_', :link_path=>"panel_web_resource_back_end_web_links_path" , :priority=>1, - :active_for_action=>{:bulletins=>:index}, + :active_for_action=>{:web_links=>:index}, :available_for => [:all] context_link 'link', :link_path=>"new_panel_web_resource_back_end_web_link_path" , :priority=>2, - :active_for_action=>{:bulletins=>:new}, + :active_for_action=>{:web_links=>:new}, :available_for => [:sub_manager] context_link 'categories', :link_path=>"panel_web_resource_back_end_web_link_categorys_path" , :priority=>3, - :active_for_action=>{:bulletin_categorys=>:index}, + :active_for_action=>{:web_link_categorys=>:index}, :available_for => [:manager] context_link 'tags', @@ -58,7 +58,7 @@ module WebResource :available_for => [:manager] context_link 'module_authorization', - :link_path=>"admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {key: 'web_resource'}))", + :link_path=>"admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {title: 'WebResource'}))", :priority=>6, :active_for_app_auth => 'web_resource', :available_for => [:admin]