From 88a26cc6a1c4a43e49b7672ec798b2e1a1d3f129 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Wed, 16 May 2012 12:10:16 +0800 Subject: [PATCH] Fix sidebar and hide some links by roles --- .../admin/module_apps_new_interface_controller.rb | 6 +++--- app/views/layouts/_side_bar.html.erb | 14 ++++++++------ .../back_end/web_link_categorys_controller.rb | 3 ++- .../web_resource/back_end/web_links_controller.rb | 9 ++++++++- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/app/controllers/admin/module_apps_new_interface_controller.rb b/app/controllers/admin/module_apps_new_interface_controller.rb index 83aa0d794..404ac6930 100644 --- a/app/controllers/admin/module_apps_new_interface_controller.rb +++ b/app/controllers/admin/module_apps_new_interface_controller.rb @@ -1,4 +1,4 @@ -class Admin::ModuleAppsNewInterfaceController < ApplicationController +class Admin::ModuleAppsNewInterfaceController < OrbitBackendController before_filter :authenticate_user! before_filter :is_admin? include AdminHelper @@ -25,9 +25,9 @@ class Admin::ModuleAppsNewInterfaceController < ApplicationController def update_setting module_app = update_setting_by_params if module_app.save! - flash[:notice] = "Update Done" + flash[:notice] = t("admin.object_auth.update_done") else - flash[:notice] = "Update Failed" + flash[:notice] = t("admin.object_auth.update_failed") end end diff --git a/app/views/layouts/_side_bar.html.erb b/app/views/layouts/_side_bar.html.erb index 2b6d75c0f..fc3635c19 100644 --- a/app/views/layouts/_side_bar.html.erb +++ b/app/views/layouts/_side_bar.html.erb @@ -36,18 +36,20 @@ <%#= link_to content_tag(:i, nil, :class => 'icons-member') + t('admin.member'), admin_users_path %> <%# end -%> -<%= content_tag :li, :class => active_for_controllers('page_contexts') do -%> +<%= content_tag :li, :class => active_for_controllers('page_contexts') || active_for_app_auth('page_content') || active_for_ob_auths_object("PageContext") do -%> <%= link_to content_tag(:i, nil, :class => 'icons-page') + t('admin.page'), panel_page_content_back_end_page_contexts_path %> - <%#= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('page_contexts')) do -%> + <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('page_contexts')) do -%> <%#= content_tag :li, link_to(t('admin.all_articles'), panel_page_content_back_end_page_contexts_path), :class => active_for_action('page_context', 'index') %> - <%# end -%> + <%= content_tag :li, link_to(t('admin.module.authorization'),admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {title: "page_content"}))), :class => active_for_app_auth('page_content') if (is_admin? rescue nil) %> + <% end -%> + <% end -%> <%= content_tag :li, :class => active_for_controllers('designs') do -%> <%= link_to content_tag(:i, nil, :class => 'icons-window-block') + t('admin.design'), admin_designs_path %> <% end -%> -<%= content_tag :li, :class => active_for_controllers('ad_banners', 'ad_images') || active_for_app_auth('ad_banners') do -%> +<%= content_tag :li, :class => active_for_controllers('ad_banners', 'ad_images') ||active_for_ob_auths_object("AdBanner") ||active_for_app_auth('ad_banners') do -%> <%= link_to content_tag(:i, nil, :class => 'icons-link') + t('admin.ad_banner'), admin_ad_banners_path %> <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('ad_banners', 'ad_images') ) do -%> @@ -58,12 +60,12 @@ <% end -%> <% end %> -<%= content_tag :li, :class => active_for_controllers('web_links', '/panel/web_resource/back_end/tags', 'web_link_categorys') || active_for_app_auth('web_resource') do -%> +<%= content_tag :li, :class => active_for_controllers('web_links', '/panel/web_resource/back_end/tags', 'web_link_categorys') || active_for_app_auth('web_resource') || active_for_ob_auths_object("WebLinkCategory") do -%> <%= link_to content_tag(:i, nil, :class => 'icons-link') + t('admin.link'), panel_web_resource_back_end_web_links_path %> <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('web_links', '/panel/web_resource/back_end/tags', 'web_link_categorys')) do -%> <%= content_tag :li, link_to(t('admin.all_articles'), panel_web_resource_back_end_web_links_path), :class => active_for_action('web_links', 'index') %> <%= content_tag :li, link_to(t('announcement.add_new'), new_panel_web_resource_back_end_web_link_path), :class => active_for_action('web_links', 'new') %> - <%= content_tag :li, link_to(t('announcement.categories'), panel_web_resource_back_end_web_link_categorys_path), :class => active_for_action('web_link_categorys', 'index') %> + <%= content_tag :li, link_to(t('announcement.categories'), panel_web_resource_back_end_web_link_categorys_path), :class => (active_for_action('web_link_categorys', 'index') || active_for_ob_auths_object("WebLinkCategory")) %> <%= content_tag :li, link_to(t('announcement.tags'), panel_web_resource_back_end_tags_path), :class => active_for_action('/panel/web_resource/back_end/tags', 'index') %> <%= content_tag :li, link_to(t('admin.module.authorization'),admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {title: "web_resource"}))), :class => active_for_app_auth('web_resource') if (is_admin? rescue nil) %> <% end -%> diff --git a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_link_categorys_controller.rb b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_link_categorys_controller.rb index 46e8933f5..8c961cbab 100644 --- a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_link_categorys_controller.rb +++ b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_link_categorys_controller.rb @@ -1,5 +1,6 @@ class Panel::WebResource::BackEnd::WebLinkCategorysController < OrbitBackendController - + before_filter :for_app_manager,:except => [:index] + def index @web_link_categorys = WebLinkCategory.all @web_link_category = WebLinkCategory.new(:display => 'List') diff --git a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_links_controller.rb b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_links_controller.rb index 323b92fc6..af557bcb4 100644 --- a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_links_controller.rb +++ b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_links_controller.rb @@ -1,7 +1,7 @@ class Panel::WebResource::BackEnd::WebLinksController < OrbitBackendController before_filter :authenticate_user! # before_filter :for_app_manager,:except => [:index,:show] - # before_filter :for_app_sub_manager + before_filter :for_app_sub_manager,:except => [:index] def index @@ -134,6 +134,13 @@ class Panel::WebResource::BackEnd::WebLinksController < OrbitBackendController def get_categorys(id = nil) @web_link_categorys = (id ? WebLinkCategory.find(id).to_a : WebLinkCategory.excludes('disabled' => true)) + + @web_link_categorys = [] + if(is_manager? || is_admin?) + @web_link_categorys = (id ? WebLinkCategory.find(id).to_a : WebLinkCategory.excludes('disabled' => true)) + elsif is_sub_manager? + @web_link_categorys = WebLinkCategory.authed_for_user(current_user,'edit') + end end def get_tags