delete unuse code

This commit is contained in:
BOHUNG 2019-09-28 21:39:47 +08:00
parent 4433d4d40d
commit d39daee2cd
2 changed files with 0 additions and 462 deletions

View File

@ -6,43 +6,14 @@ class Patchfilefield
# encoding: utf-8 # encoding: utf-8
include OrbitTag::Taggable include OrbitTag::Taggable
include OrbitCategory::Categorizable include OrbitCategory::Categorizable
#include Slug
field :font_array , :type => Hash, default:{} field :font_array , :type => Hash, default:{}
field :new_add_font, type: String, default:"" field :new_add_font, type: String, default:""
field :delete_font, type: String, default:"" field :delete_font, type: String, default:""
field :used_font , :type => Array, default:[] field :used_font , :type => Array, default:[]
field :un_used_font , :type => Array, default:[] field :un_used_font , :type => Array, default:[]
#field :title, as: :slug_title, type: String, localize: true
field :title ,type:String ,default:"" field :title ,type:String ,default:""
field :subtitle, localize: true field :subtitle, localize: true
field :text, localize: true field :text, localize: true
#field :create_user_id
#field :update_user_id
# field :public, :type => Boolean, :default => true
#field :postdate , :type => DateTime, :default => Time.now
#field :deadline , :type => DateTime
# field :rss2_sn
#field :approved, :type => Boolean, :default => false
#field :is_preview, :type => Boolean, :default => false
#field :expirable_created_at, type: DateTime
# field :rejected, :type => Boolean, :default => false
#field :reapproval, :type => Boolean, :default => false
# field :rejection_reason
#field :is_external_link, :type => Boolean, :default => false
#field :external_link
#field :email_id
#field :email_sent, :type => Boolean, :default => false
# field :email_sentdate , :type => DateTime
# field :email_member_ids
#field :other_mailaddress
# field :image_description, localize: true
# field :top_end_date, :type => DateTime
# mount_uploader :image, ImageUploader
#has_many :bulletin_links, :autosave => true, :dependent => :destroy
# has_many :bulletin_files, :autosave => true, :dependent => :destroy
#accepts_nested_attributes_for :bulletin_files, :allow_destroy => true
# accepts_nested_attributes_for :bulletin_links, :allow_destroy => true
# before_destroy :destroy_email # before_destroy :destroy_email
scope :can_display, ->{where(:is_hidden=>false,:is_preview => false).any_of({:postdate.lt=>Time.now, :deadline.gt=>Time.now},{:postdate.lt=>Time.now, :deadline=>nil}).order_by([:is_top, :desc],[:postdate, :desc])} scope :can_display, ->{where(:is_hidden=>false,:is_preview => false).any_of({:postdate.lt=>Time.now, :deadline.gt=>Time.now},{:postdate.lt=>Time.now, :deadline=>nil}).order_by([:is_top, :desc],[:postdate, :desc])}
scope :is_approved, ->{where(:approved => true)} scope :is_approved, ->{where(:approved => true)}
@ -61,7 +32,6 @@ class Patchfilefield
@end_character @end_character
if @index_of_font != nil if @index_of_font != nil
@inex_start_to_search = @index_of_font + @name_to_search.length @inex_start_to_search = @index_of_font + @name_to_search.length
#@str_start = 0 #if @str_start=0 =>not reach the start of font string
@str_start = @inex_start_to_search @str_start = @inex_start_to_search
if (@filedata[@inex_start_to_search] != "\'" && @filedata[@inex_start_to_search] != "\"") if (@filedata[@inex_start_to_search] != "\'" && @filedata[@inex_start_to_search] != "\"")
for @str_start in @inex_start_to_search..@filedata.length for @str_start in @inex_start_to_search..@filedata.length
@ -116,7 +86,6 @@ class Patchfilefield
@count = self.font_array.count @count = self.font_array.count
self.font_array = self.font_array.merge({@count =>{self.new_add_font.strip => true}}) self.font_array = self.font_array.merge({@count =>{self.new_add_font.strip => true}})
end end
#self.cuurent_used_font push true
self.new_add_font = "" self.new_add_font = ""
end end
end end
@ -243,7 +212,6 @@ class Patchfilefield
end end
puts self.used_font puts self.used_font
puts @filedata puts @filedata
#render :html => @delete_font_array.to_s+" "+ @filedata and return
@filetowrite.write(@filedata) @filetowrite.write(@filedata)
@filetowrite.close @filetowrite.close
@filetocover = File.open("config.js.erb","w") @filetocover = File.open("config.js.erb","w")

View File

@ -1,430 +0,0 @@
class MembersController < ApplicationController
def index
page_roles = OrbitHelper.page_categories
page_role_status = OrbitHelper.page_role_status
params = OrbitHelper.params
page = Page.where(:page_id => params[:page_id]).first rescue nil
fields_to_show = page.custom_array_field if !page.nil? rescue []
fields_to_show = [
{"key"=>"name", "type"=>"profile","sort_order"=>2,"link_to_show"=>true},
{"key"=>"email", "type"=>"profile"},
{"key"=>"office_tel", "type"=>"profile"}
] if fields_to_show.blank?
member_sort_position = OrbitHelper.member_sort_position
sort = nil
if !member_sort_position
# sort = "data['list_order']"
# else
# sort = fields_to_show
# .collect.with_index{|field,idx| {'sort_order'=>field['sort_order'], 'index'=>idx}}
# .select{|field|!field['sort_order'].blank?}
# .sort_by{|field|field['sort_order']}
# .collect.with_index{|field| "data['profile_data'][#{field['index']}]['sort_value'] rescue 0"}
# # sort = "[(data['first_name'][0])]"
# sort = '[('+sort.join('),(')+')]'
fields_to_show.each_with_index do |field, idx|
if field["key"] == "name"
# sort = "[(data['profile_data'][idx]['sort_value'] rescue 0)]"
sort = idx
end
end
end
if page_roles.include?("all")
roles = Role.all.asc(:key).collect do |role|
{ "title" => role.title, "id" => role.id }
end
else
page_role_status.each do |status_id|
page_roles << RoleStatus.find(status_id).role.id.to_s
end
roles = Role.where(:id.in => page_roles.uniq).asc(:key).collect do |role|
{ "title" => role.title, "id" => role.id, "status" => RoleStatus.where(:role_id=>role, :_id.in=>page_role_status).asc(:key).to_a }
end
end
tag = nil
role_list = []
roles.each do |role|
status_list = []
if !role['status'].blank?
role['status'].each do |status|
member_profiles = get_members_by_status(status, sort, fields_to_show, member_sort_position, params)
status_list << { "status-title" => status.title, "members" => member_profiles } if !member_profiles.blank?
end
else
# Members with status
role_status = RoleStatus.order_by(:key=>"asc").where(:role_id=>role['id'])
role_status_ids = role_status.collect{|status| status.id.to_s}
role_status.each do |status|
member_profiles = get_members_by_status(status, sort, fields_to_show, member_sort_position, params)
next if member_profiles.blank?
status_list << { "status-title" => status.title, "members" => member_profiles }
end
# Members without status
member_profiles = []
if params[:tag].blank?
MemberProfile.not_in(:role_status_ids.in=>role_status_ids).where(:role_ids.in=>[role['id']]).collect do |profile|
if profile.user.nil?
member_profiles << get_member_data(profile, fields_to_show)
elsif profile.user.approved
member_profiles << get_member_data(profile, fields_to_show)
end
end
else
tag = MemberTag.find(params[:tag]) rescue nil
MemberProfile.not_in(:role_status_ids.in=>role_status_ids).where(:role_ids.in=>[role['id']], :member_tag_ids.in => [tag.id]).collect do |profile|
if profile.user.nil?
member_profiles << get_member_data(profile, fields_to_show)
elsif profile.user.approved
member_profiles << get_member_data(profile, fields_to_show)
end
end if !tag.nil?
end
if member_sort_position
member_profiles = member_profiles.sort_by{|data| (data['list_order'])} rescue member_profiles
else
member_profiles = member_profiles.sort_by{|data| (data['profile_data'][sort]['sort_value'] rescue 0)} rescue member_profiles
end
status_list << { "status-title" => role['title'], "members" => member_profiles } if !member_profiles.blank?
end
role_list << { "role-title" => role['title'], "status-list" => status_list }
end
{
"roles" => role_list,
"extras" => {
"widget-title"=>((params[:tag].blank? ? t(:member_) : (tag.nil? ? "Tag not found" : t(:member_) + " - Filtered by <i>#{tag.title}</i>")) rescue t(:member_))
}
}
end
def get_members_by_status(status, sort=nil, fields_to_show, member_sort_position, params)
member_profiles = []
mps = []
if params[:tag].blank?
mps = status.member_profiles.asc(:first_name)
else
tag = MemberTag.find(params[:tag]) rescue nil
mps = status.member_profiles.where(:member_tag_ids.in => [tag.id]).asc(:first_name) if !tag.nil?
end
mps.each do |member|
if member.user.nil?
member_profiles << get_member_data(member, fields_to_show)
elsif member.user.approved
member_profiles << get_member_data(member, fields_to_show)
end
end
if member_sort_position
return member_profiles.sort_by{|data| (data['list_order'])} rescue member_profiles
else
return member_profiles.sort_by{|data| (data['profile_data'][sort]['sort_value'] rescue 0)} rescue member_profiles
end
end
def get_member_data(member, fields_to_show)
image = member.avatar.present? ? member.avatar.thumb.url : ActionController::Base.helpers.asset_path('member-pic.png')
{
'profile_data'=>member_data(member, fields_to_show),
'list_order' => member.position,
'name' => member.name,
'image'=>image,
"link_to_show" => OrbitHelper.url_to_show(member.to_param)
}
end
def show
params = OrbitHelper.params
member = MemberProfile.find_by(uid: params[:uid])
page = Page.where(:page_id => params[:page_id]).first rescue nil
profile_data = []
fields_to_show = []
fields_to_show = page.custom_array_field_for_show rescue []
#role status
member.roles.where(:disabled => false).asc("_id").collect do |role|
role_status = member.role_statuses.where(role_id: role.id).map{|t|t.title.to_s}.join(',') rescue ''
profile_data = profile_data.push({"key"=>"role_status", "title"=>"", "value"=> role_status, "title_class"=>"member-data-title-role-status", "value_class"=>"member-data-value-role-status"}) if !role_status.blank?
if fields_to_show.blank?
attribute_field = role.attribute_fields.where(:key => 'job_title').first
profile_data = profile_data + member_data(member, [{"id"=> attribute_field.id.to_s, "key"=> attribute_field.key, "type"=>"role"}]) if !attribute_field.blank? and !attribute_field.to_show.blank?
end
end
if fields_to_show.blank?
fields_to_show = [
{"key"=>"name", "type"=>"profile"},
{"key"=>"office_tel", "type"=>"profile"},
{"key"=>"email", "type"=>"profile"}
]
profile_data = profile_data + member_data(member, fields_to_show)
profile_fields_to_show = []
# member info
infos = MemberInfo.order('created_at DESC')
infos.each do |info|
info.member_profile_fields.each do |member_profile_field|
profile_fields_to_show << {"id"=> member_profile_field.id.to_s, "key"=> member_profile_field.key, "type"=>"custom"} if !member_profile_field.to_show.blank?
end
end
profile_data = profile_data + member_data(member, profile_fields_to_show)
# member role
role_fields_to_show = []
member.roles.where(:disabled => false).asc("_id").collect do |role|
role.attribute_fields.where(:key.ne => 'job_title').asc("_id").each do |attribute_field|
role_fields_to_show << {"id"=> attribute_field.id.to_s, "key"=> attribute_field.key, "type"=>"role"} if !attribute_field.to_show.blank?
end
end
profile_data = profile_data + member_data(member, role_fields_to_show)
else
profile_data = profile_data + member_data(member, fields_to_show)
auto = profile_data.select{|pd| pd if pd["key"] == "autobiography"}
if !auto.blank?
auto = auto.first
profile_data.delete(auto)
end
end
# member plugin
# plugins = (current_site.personal_plugins_sort.blank? ? OrbitApp::Plugin::Registration.all : OrbitApp::Plugin::Registration.sort_by_array(current_site.personal_plugins_sort)) rescue nil
if current_site.personal_plugins_sort.blank?
plugins = OrbitApp::Plugin::Registration.all rescue nil
else
plugin_list = OrbitApp::Plugin::Registration.all.collect{|p| p.module_app_name}
plugin_list = current_site.personal_plugins_sort | plugin_list
plugins = OrbitApp::Plugin::Registration.sort_by_array(plugin_list) rescue nil
end
plugin_list = plugins.collect.with_index do |plugin, idx|
intro = PersonalPluginIntro.find_by(member_profile_id: member.id, _type: "#{plugin.app_name}Intro") rescue nil
if intro.nil? or intro.complete_list
plugin_data = plugin.app_name.constantize.where(member_profile_id: member,:is_hidden=>false) rescue nil
# pd = plugin_data.collect do |p|
# slug_title = ["JournalPaper","WritingConference"].include?(plugin.app_name) ? p.create_link : p.slug_title
# {
# "data_title" => slug_title,
# "link_to_show" => OrbitHelper.url_to_plugin_show(p.to_param,plugin.module_app_name.underscore)
# }
# end
pd = []
has_plugin_method = plugin.app_name.constantize.respond_to?("get_plugin_datas_to_member") rescue false
if !has_plugin_method && (plugin.app_name == 'JournalPaper' or plugin.app_name == 'WritingConference' or plugin.app_name == 'Book')
pd_title = {}
temp_pds = plugin_data.sort_for_frontend rescue nil
temp_pds = plugin_data.where(:is_hidden=>false).desc(:year) if temp_pds.nil? # for old sites without plugins update
plugin_datas = temp_pds.collect do |p|
{
"pd_datas" => [{ "data_title" => "<a href='#{OrbitHelper.url_to_plugin_show(p.to_param,plugin.module_app_name.underscore)}' title='#{p.create_link}' target='_blank'>#{p.create_link}" }]
}
end
else
datas = plugin.app_name.constantize.get_plugin_datas_to_member(plugin_data)
pd_title = datas[0] rescue {}
plugin_datas = datas[1] rescue {}
end
end
if !intro.blank?
if !intro.brief_intro.blank?
pdi = []
pdi << {"data_intro_title" => intro.text.html_safe}
end
if intro.complete_list.blank?
complete_display = "hide"
pd_title = {}
plugin_datas = {}
end
if intro.brief_intro.blank?
brief_display = "hide"
pdi = {}
end
else
pdi = [{"data_intro_title" => ''}] if !plugin_datas.blank?
end
{
"plugin_data" => pd,
"pd_title" => pd_title,
"plugin_datas" => plugin_datas,
"plugin_data_intro" => pdi,
"complete_display" => complete_display,
"brief_display" => brief_display,
"plugin_name" => plugin.module_app_name.underscore,
"plugin_title" => t('module_name.'+plugin.module_app_name.underscore),
"plugin_class" => idx==0 ? "active" : ""
}
end
plugin_list = plugin_list.reject{|plugin| plugin['plugin_datas'].blank? and plugin['plugin_data_intro'].blank?}
vlog_module = ModuleApp.find_by_key("vlog") rescue nil
if !vlog_module.nil? && !member.user.nil?
plugin_data = VLog.where(create_user_id: member.user.id) rescue nil
if plugin_data.count > 0
datas = VLog.get_plugin_datas_to_member(plugin_data)
pd_title = datas[0] rescue {}
plugin_datas = datas[1] rescue {}
plugin_list << {
"plugin_data" => [],
"pd_title" => pd_title,
"plugin_datas" => plugin_datas,
"plugin_data_intro" => {},
"complete_display" => nil,
"brief_display" => nil,
"plugin_name" => vlog_module.get_registration.key,
"plugin_title" => t("vlog.vlog"),
"plugin_class" => ""
}
end
end
if !auto.blank?
if plugin_list.empty?
plugin_list << {"plugin_data"=>[], "pd_title"=>[{"plugin_data_title"=>auto["title"]}], "plugin_datas"=>[{"pd_datas"=>[{"data_title"=>auto["value"]}]}], "plugin_name" => auto["key"],"plugin_class" => "active", "plugin_title" => auto["title"], "plugin_data_intro"=>[{"data_intro_title"=>""}], "complete_display"=>nil, "brief_display"=>nil}
else
plugin_list.first["plugin_class"] = ""
plugin_list.unshift({"plugin_data"=>[], "pd_title"=>[{"plugin_data_title"=>auto["title"]}], "plugin_datas"=>[{"pd_datas"=>[{"data_title"=>auto["value"]}]}], "plugin_name" => auto["key"],"plugin_class" => "active", "plugin_title" => auto["title"], "plugin_data_intro"=>[{"data_intro_title"=>""}], "complete_display"=>nil, "brief_display"=>nil})
end
end
{
"plugins" => plugin_list,
"profile_data" => profile_data,
"data" => {
"image" => member.avatar.present? ? member.avatar.url : ActionController::Base.helpers.asset_path('member-pic.png'),
"name" => member.name
}
}
end
def member_data(member, fields_to_show)
profile_data = []
fields_to_show.each do |field|
case field['type']
when 'profile'
next if member.get_privacy_type_for_field(field["key"]) != "public"
field_data = member.get_attribute_data(field) rescue {}
when 'custom'
if !field['id'].blank?
next if member.get_privacy_type_for_field(field["id"]) != "public"
field_data = member.member_profile_field_values.find_by(:member_profile_field_id=>field['id'],:key=>field['key']).get_field_value rescue {"value" => "&nbsp;"}
else
field_data = member.member_profile_field_values.find_by(:key=>field['key']).get_field_value rescue {"value" => "&nbsp;"}
end
when 'role'
if !field['id'].blank?
next if member.get_privacy_type_for_field(field["id"]) != "public"
av = member.attribute_values.find_by(:attribute_field_id=>field['id'],:key=>field['key']) rescue nil
field_data = {"value" => "&nbsp;"}
if !av.nil?
r = av.attribute_field.role rescue nil
if !r.nil?
if member.roles.include?(r)
field_data = av.get_field_value rescue {"value" => "&nbsp;"}
else
field_data = {"value" => "&nbsp;"}
end
else
field_data = {"value" => "&nbsp;"}
end
else
field_data = {"value" => "&nbsp;"}
end
else
avs = member.attribute_values.where(:key=>field['key']) rescue nil
field_data = {"value" => "&nbsp;"}
avs.each do |av|
if !av.nil?
r = av.attribute_field.role rescue nil
if !r.nil?
if member.roles.include?(r)
field_data = av.get_field_value rescue {"value" => "&nbsp;"}
break
else
field_data = {"value" => "&nbsp;"}
end
else
field_data = {"value" => "&nbsp;"}
end
else
field_data = {"value" => "&nbsp;"}
end
end
end
end
next if field_data.blank? or field_data['value'].blank? or (OrbitHelper.params[:target_action] == "show" && field_data['value'] == "&nbsp;")
if field['sort_order']
field_data['sort_value'] = field_data['val'].blank? ? field_data['value'] : field_data['val']
if !field_data['sort_value'].is_a?(Hash)
if field_data['sort_value'].is_a?(Integer) || (field_data['sort_value'].is_i? rescue false)
field_data['sort_value'] = field_data['sort_value'].to_i rescue field_data['sort_value']
else
if I18n.locale == :zh_tw
field_data['sort_value'] = field_data['sort_value'].strip.encode("Big5") rescue "".encode("Big5")
end
end
end
end
@current_field_value = field_data['value']
if (@current_field_value.gsub('&nbsp;','').strip rescue nil) == ""
@locale = I18n.locale
@site_in_use_locales = current_site.in_use_locales
@new_field_data = Hash.new
@site_in_use_locales.each_with_index do |locale,i|
I18n.locale = locale
@new_field_data = member.get_attribute_data(field) rescue {}
break if @new_field_data['value'].to_s.gsub('&nbsp;','').strip !=""
end
field_data['value'] = @new_field_data['value'].nil? ? "&nbsp" :@new_field_data['value']
I18n.locale = @locale
end
if field['link_to_show']
if field_data['value'] == '&nbsp;' #需jquery刪除空白欄位
field_data['value'] = "" #若無網站連結,刪除實驗室網站字樣
field_data['title'] = "" #無網站連結,則不顯示
elsif field_data['value'].include? 'href='
field_data['value'] = "<a title='#{field_data['title']}'#{field_data['value']}</a>"
else
field_data['value'] = "<a title='#{field_data['value']}' href='#{OrbitHelper.url_to_show(member.to_param)}'>#{field_data['value']}</a>"
end
#field_data['value'] = "<a title='#{field_data['value']}' href='#{OrbitHelper.url_to_show(member.to_param)}'>#{field_data['value']}</a>"
end
if field['max_length']
field_data['value'] = (field_data['value'].length > field['max_length']) ? field_data['value'][0..field['max_length']]+'...' : field_data['value']
end
field_data['title_class'] = "member-data-title-"+field['key'].underscore.gsub('_','-')
field_data['value_class'] = "member-data-value-"+field['key'].underscore.gsub('_','-')
profile_data.push(field_data)
end
return profile_data
end
end