From 96fe482d5001c09b0a2f6d690e76cb69a7490567 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Tue, 20 Nov 2012 20:20:59 +0800 Subject: [PATCH] for openness --- app/helpers/application_helper.rb | 7 +++++-- app/views/layouts/_side_bar_content.html.erb | 12 ++++++------ lib/orbit_controller_lib.rb | 2 +- .../panel/announcement/back_end/bulletins_helper.rb | 11 ++++++++--- .../announcement/back_end/bulletins/_form.html.erb | 2 +- .../panel/news/back_end/news_bulletins_controller.rb | 2 +- .../panel/news/back_end/news_bulletins_helper.rb | 2 +- 7 files changed, 23 insertions(+), 15 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 76f0f933..07d6b577 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -15,8 +15,11 @@ module ApplicationHelper end def create_guest_user - u = User.create(:name => "guest", :email => "guest_#{Time.now.to_i}#{rand(99)}@example.com") - u.admin = false + u = nil + User.without_callback(:create, :before, :initialize_desktop) do + u = User.create(:name => "guest", :email => "guest_#{Time.now.to_i}#{rand(99)}@example.com") + end + u.admin = false u.save(:validate => false) u end diff --git a/app/views/layouts/_side_bar_content.html.erb b/app/views/layouts/_side_bar_content.html.erb index 66e4542d..e9da4cf0 100644 --- a/app/views/layouts/_side_bar_content.html.erb +++ b/app/views/layouts/_side_bar_content.html.erb @@ -75,8 +75,8 @@ <%#= content_tag :li, link_to(t('admin.ad.all_banners'), admin_ad_banners_path), :class => active_for_action('ad_banners', 'index') %> <%#= content_tag :li, link_to(t('admin.ad.new_banner'), new_admin_ad_banner_path), :class => active_for_action('ad_banners', 'new') %> <%#= content_tag :li, link_to(t('admin.ad.new_image'), new_ad_image_admin_ad_banners_path), :class => active_for_action('ad_images', 'new') %> - <%= content_tag :li, link_to((t('gallery.categories') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, panel_gallery_back_end_gallery_categories_path), :class => active_for_action('gallery_categories','index') %> - <%= content_tag :li, link_to((t('gallery.tags') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, panel_gallery_back_end_tags_path), :class => active_for_action('/panel/gallery/back_end/tags', 'index') %> + <%= content_tag(:li, link_to((t('gallery.categories') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, panel_gallery_back_end_gallery_categories_path), :class => active_for_action('gallery_categories','index') )if (is_manager? rescue nil)%> + <%= content_tag :li, link_to((t('gallery.tags') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, panel_gallery_back_end_tags_path), :class => active_for_action('/panel/gallery/back_end/tags', 'index') if (is_manager? rescue nil) %> <%= content_tag :li, link_to((t('admin.module.authorization') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe,admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {key: "gallery"}))), :class => active_for_app_auth('gallery') if (is_admin? rescue nil) %> <% end -%> <% end %> @@ -85,9 +85,9 @@ <%= link_to content_tag(:i, nil, :class => 'icons-asset') + content_tag(:span, t('admin.archive')), panel_archive_back_end_archive_files_path %> <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('archive_files', 'tags', 'archive_file_categorys')) do -%> <%= content_tag :li, link_to((t('admin.all_articles') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, panel_archive_back_end_archive_files_path), :class => active_for_action('archive_file', 'index') %> - <%= content_tag :li, link_to((t('admin.add_new') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, new_panel_archive_back_end_archive_file_path), :class => active_for_action('archive_file', 'new') %> - <%= content_tag :li, link_to((t('admin.categories') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, panel_archive_back_end_archive_file_categorys_path), :class => active_for_action('archive_file_categorys', 'index') %> - <%= content_tag :li, link_to((t('admin.tags') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, panel_archive_back_end_tags_path), :class => active_for_action('tags', 'index') %> + <%= content_tag :li, link_to((t('admin.add_new') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, new_panel_archive_back_end_archive_file_path), :class => active_for_action('archive_file', 'new') if (is_admin? rescue nil)%> + <%= content_tag(:li, link_to((t('admin.categories') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, panel_archive_back_end_archive_file_categorys_path), :class => active_for_action('archive_file_categorys', 'index'))if (is_manager? rescue nil)%> + <%= content_tag :li, link_to((t('admin.tags') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, panel_archive_back_end_tags_path), :class => active_for_action('tags', 'index') if (is_manager? rescue nil)%> <% end -%> <% end -%> @@ -98,7 +98,7 @@ <%#= content_tag :li, link_to(t('admin.ad.new_banner'), new_admin_ad_banner_path), :class => active_for_action('ad_banners', 'new') %> <%#= content_tag :li, link_to(t('admin.ad.new_image'), new_ad_image_admin_ad_banners_path), :class => active_for_action('ad_images', 'new') %> <%= content_tag :li, link_to((t('admin.calendars') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, new_panel_calendar_back_end_cal_path), :class => active_for_action('cals','new') %> - <%= content_tag :li, link_to(t('admin.tags'), panel_calendar_back_end_tags_path), :class => active_for_action('/panel/calendar/back_end/tags', 'index') %> + <%= content_tag :li, link_to(t('admin.tags'), panel_calendar_back_end_tags_path), :class => active_for_action('/panel/calendar/back_end/tags', 'index')if (is_manager? rescue nil) %> <%#= content_tag :li, link_to(t('admin.module.authorization'),admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {key: "gallery"}))), :class => active_for_app_auth('gallery') if (is_admin? rescue nil) %> <% end -%> <% end %> diff --git a/lib/orbit_controller_lib.rb b/lib/orbit_controller_lib.rb index e8fd8e05..6a79515f 100644 --- a/lib/orbit_controller_lib.rb +++ b/lib/orbit_controller_lib.rb @@ -15,7 +15,7 @@ module OrbitControllerLib instance_variable_set(ivar_name, []) if(is_manager? || is_admin?) instance_variable_set(ivar_name, (id ? class_ref.admin_manager_all.find(id).to_a : class_ref.admin_manager_all)) - elsif is_sub_manager? + else #is_sub_manager? instance_variable_set(ivar_name, (class_ref.all)) end instance_variable_get(ivar_name) diff --git a/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb b/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb index 31e08fb4..7b145bd2 100644 --- a/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb +++ b/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb @@ -18,9 +18,14 @@ module Panel::Announcement::BackEnd::BulletinsHelper end def show_delete_link(bulletin) - by_bulletin = (bulletin.create_user_id == current_user.id) - by_user = (is_manager? or is_admin?) - by_bulletin or by_user + if !current_user.nil? + by_bulletin = (bulletin.create_user_id == current_user.id ) + by_user = (is_manager? or is_admin?) + by_bulletin or by_user + else + false + end + end def show_bulletin_title_at_index (bulletin) diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb index 1c2b57eb..e575e324 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb @@ -221,7 +221,7 @@ or diff --git a/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_bulletins_controller.rb b/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_bulletins_controller.rb index ff3ce975..8d34e2b3 100644 --- a/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_bulletins_controller.rb +++ b/vendor/built_in_modules/news/app/controllers/panel/news/back_end/news_bulletins_controller.rb @@ -56,7 +56,7 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController @news_bulletins = (params[:sort] || @filter) ? get_sorted_and_filtered("news_bulletin",:news_bulletin_category_id.in => @news_bulletin_category_ids) : get_viewable("news_bulletin",:news_bulletin_category_id.in => @news_bulletin_category_ids) - + @news_bulletin_link = NewsBulletinLink.new @link_url = panel_news_back_end_news_bulletins_path diff --git a/vendor/built_in_modules/news/app/helpers/panel/news/back_end/news_bulletins_helper.rb b/vendor/built_in_modules/news/app/helpers/panel/news/back_end/news_bulletins_helper.rb index 2ad6f7f9..aba740c6 100644 --- a/vendor/built_in_modules/news/app/helpers/panel/news/back_end/news_bulletins_helper.rb +++ b/vendor/built_in_modules/news/app/helpers/panel/news/back_end/news_bulletins_helper.rb @@ -17,7 +17,7 @@ module Panel::News::BackEnd::NewsBulletinsHelper end def news_show_delete_link(news_bulletin) - by_news_bulletin = (news_bulletin.create_user_id == current_user.id) + by_news_bulletin = current_user.nil? ? false : (news_bulletin.create_user_id == current_user.id) by_user = (is_manager? or is_admin?) by_news_bulletin or by_user end