This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
orbit-4-1/lib/orbit_controller_lib.rb

45 lines
1.7 KiB
Ruby
Raw Normal View History

2012-07-05 08:00:45 +00:00
module OrbitControllerLib
module DivisionForDisable
2012-07-06 10:11:55 +00:00
# def get_disable_object_by_user(object_class)
# if is_admin? or is_manager?
# object_class.admin_manager_all
# else
# object_class.all
# end
# end
def get_categories_for_index(object_class,id = nil)
class_ref = object_class.constantize
ivar_name = "@#{object_class.to_s.underscore.pluralize}"
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?
instance_variable_set(ivar_name, (class_ref.all))
2012-07-05 08:00:45 +00:00
end
2012-07-06 10:11:55 +00:00
instance_variable_get(ivar_name)
2012-07-05 08:00:45 +00:00
end
2012-07-06 10:11:55 +00:00
def get_categorys(object_class,id = nil,func_authed_for_sub_manager = 'submit')
class_ref = object_class.constantize
# ivar_name = "@#{object_class.to_s.underscore.pluralize}"
ivar_name = "@#{object_class.to_s.underscore}s"
instance_variable_set(ivar_name, [])
@bulletin_categorys = []
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))
instance_variable_set(ivar_name, (id ? class_ref.all.find(id).to_a : class_ref.all))
elsif is_sub_manager?
instance_variable_set(ivar_name, class_ref.all.authed_for_user(current_user,func_authed_for_sub_manager))
end
if instance_variable_get(ivar_name).empty? && params[:action] != "index"
flash[:alert] = t("announcement.error.no_avilb_cate_for_posting")
redirect_to :action => :index
end
end
2012-07-05 08:00:45 +00:00
end
end