diff --git a/app/controllers/admin/object_auths_new_interface_controller.rb b/app/controllers/admin/object_auths_new_interface_controller.rb index 427ec722..6c33ff71 100644 --- a/app/controllers/admin/object_auths_new_interface_controller.rb +++ b/app/controllers/admin/object_auths_new_interface_controller.rb @@ -1,4 +1,4 @@ -class Admin::ObjectAuthsNewInterfaceController < ApplicationController +class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController include OrbitCoreLib::PermissionUnility layout "new_admin" before_filter :force_order @@ -33,8 +33,9 @@ class Admin::ObjectAuthsNewInterfaceController < ApplicationController protected def update_setting_by_params + user_sat = [] oa = ObjectAuth.find params[:ob_auth][:id] - user_sat = User.find params[:users].keys + user_sat += User.find params[:users].keys if params.has_key? :users users_to_new = user_sat - oa.auth_users users_to_remove = oa.auth_users - user_sat diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 4d8d6d48..1455619a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -8,6 +8,10 @@ class ApplicationController < ActionController::Base helper :all before_filter :set_locale, :set_site + def set_current_user + User.current = current_user + end + def front_end_available(module_app_title='') app_controller = ModuleApp.first(conditions: {:key => module_app_title} ) unless app_controller.enable_frontend? diff --git a/app/controllers/orbit_backend_controller.rb b/app/controllers/orbit_backend_controller.rb index bdddfb43..cfa46847 100644 --- a/app/controllers/orbit_backend_controller.rb +++ b/app/controllers/orbit_backend_controller.rb @@ -10,6 +10,7 @@ class OrbitBackendController< ApplicationController def setup_vars @app_title = request.fullpath.split('/')[2] + @app_title = request.fullpath.split('/')[1] if(@app_title == "back_end") @module_app = ModuleApp.first(conditions: {:key => @app_title} ) end diff --git a/app/helpers/admin/page_content_helper.rb b/app/helpers/admin/page_content_helper.rb new file mode 100644 index 00000000..9f2b22e0 --- /dev/null +++ b/app/helpers/admin/page_content_helper.rb @@ -0,0 +1,18 @@ +module Admin::PageContentHelper +include ActionView::Helpers::UrlHelper + + + def show_page_context_edit_auth_link(page_context) + type = 'Edit' +# debugger +# a=1 + oa = page_context.get_object_auth_by_title(type) + if oa.nil? + page_context.object_auths.new(title: type ).save rescue + oa = page_context.get_object_auth_by_title(type) + end +# link_to t('announcement.bulletin.cate_auth'), edit_admin_object_auth_path(oa) + link_to t('admin.page_context.ob_auth.edit'),admin_object_auth_ob_auth_path(oa) + end + +end \ No newline at end of file diff --git a/app/models/ad_banner.rb b/app/models/ad_banner.rb index 39112960..e1013c2f 100644 --- a/app/models/ad_banner.rb +++ b/app/models/ad_banner.rb @@ -1,4 +1,5 @@ class AdBanner + include OrbitCoreLib::ObjectAuthable include Mongoid::Document include Mongoid::Timestamps include Mongoid::MultiParameterAttributes @@ -14,6 +15,15 @@ class AdBanner FX_TYPES = ["blindX","blindY","blindZ","cover","curtainX","curtainY","fade","fadeZoom","growX","growY","scrollUp","scrollDown","scrollLeft","scrollRight","scrollHorz","scrollVert","shuffle","slideX","slideY","toss","turnUp","turnDown","turnLeft","turnRight","uncover","wipe","zoom"] attr_writer :transition_sec + + AfterObjectAuthUrl = '/panel/page_content/back_end/page_contexts' + APP_NAME = 'ad_banners' + ObjectAuthTitlesOptions = %W{edit} + + def pp_object + title + end + def transition_sec self.transition_msec/1000 rescue nil end diff --git a/app/models/object_auth.rb b/app/models/object_auth.rb index ae3fd701..d1c1c673 100644 --- a/app/models/object_auth.rb +++ b/app/models/object_auth.rb @@ -2,6 +2,7 @@ class ObjectAuth < PrototypeAuth include OrbitCoreLib::ObjectTokenUnility validates_uniqueness_of :title ,:scope => [:obj_authable_type,:obj_authable_id] #{ |c| } belongs_to :obj_authable, polymorphic: true + after_save :check_user_has_app_auth # > - Something.find_with_auth(query) # > - or Something.find(query).auth def auth_obj @@ -9,4 +10,15 @@ class ObjectAuth < PrototypeAuth class_obj.find self.obj_authable_id end + def check_user_has_app_auth + sub_managing_users = auth_obj.app_auth.sub_managing_users + app_auth = auth_obj.app_auth + self.auth_users.each do |auth_user| + if !sub_managing_users.include? auth_user && !auth_user.admin? + app_auth.assign_sub_manager(auth_user,User.current) + app_auth.save! + end + end + end + end \ No newline at end of file diff --git a/app/models/user/user.rb b/app/models/user/user.rb index d74a543b..2a2dbd86 100644 --- a/app/models/user/user.rb +++ b/app/models/user/user.rb @@ -20,6 +20,14 @@ class User belongs_to :role has_and_belongs_to_many :sub_roles accepts_nested_attributes_for :attribute_values, :allow_destroy => true + + def self.current + Thread.current[:user] + end + + def self.current=(user) + Thread.current[:user] = user + end def avb_apps sub_role_ids_ary=self.sub_roles.collect{|t| t.id} diff --git a/app/views/admin/object_auths_new_interface/setting.html.erb b/app/views/admin/object_auths_new_interface/setting.html.erb index ae5096ba..f5d17370 100644 --- a/app/views/admin/object_auths_new_interface/setting.html.erb +++ b/app/views/admin/object_auths_new_interface/setting.html.erb @@ -27,7 +27,7 @@