socialforge/app/helpers/organizations_helper.rb

122 lines
3.7 KiB
Ruby
Raw Normal View History

2015-11-05 17:57:07 +08:00
# encoding: utf-8
module OrganizationsHelper
2015-11-05 17:57:07 +08:00
include ApplicationHelper
2016-03-29 20:09:47 +08:00
include FilesHelper
2015-11-05 17:57:07 +08:00
def find_user_not_in_current_org_by_name org
if params[:q] && params[:q].lstrip.rstrip != ""
scope = Principal.active.sorted.not_member_of_org(org).like(params[:q])
else
scope = []
end
principals = paginateHelper scope,10
s = content_tag('ul', project_member_check_box_tags_ex('membership[user_ids][]', principals), :class => 'mb5', :id => 'principals')
links = pagination_links_full(@obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true){|text, parameters, options|
link_to text, org_member_autocomplete_org_member_index_path( parameters.merge(:q => params[:q],:flag => true,:org=>org, :format => 'js')), :remote => true
}
2015-11-12 19:37:28 +08:00
s + content_tag('ul', links,:class => 'wlist',:style=>'float:left !important', :id => "org_member_pagination_links" )
2015-11-05 17:57:07 +08:00
end
2015-11-12 09:32:00 +08:00
def get_default_name field
case field.name
when 'activity' then
return '动态'
when 'course' then
return '课程'
when 'project' then
return '项目'
end
end
2015-11-14 14:31:52 +08:00
2016-03-29 13:43:28 +08:00
def get_message_org(org_id, field_id)
2016-03-31 17:06:00 +08:00
OrgDocumentComment.find_by_sql("SELECT * FROM org_document_comments where organization_id = #{org_id} and org_subfield_id = #{field_id} and parent_id is null order by updated_at desc limit 8;")
2016-03-30 17:22:23 +08:00
end
def get_message_reply_org(org_id, ids)
# OrgDocumentComment.find_by_sql("SELECT * FROM org_document_comments where organization_id = #{org_id} and parent_id is not null order by updated_at desc limit 1;")
OrgDocumentComment.find_by_sql("SELECT * FROM org_document_comments where organization_id = #{org_id} and parent_id in (#{ids}) order by updated_at desc limit 1;")
2016-03-29 13:43:28 +08:00
end
2016-03-29 16:45:14 +08:00
def get_attach_org(field_id)
Attachment.find_by_sql("SELECT * FROM `attachments` where container_id =#{field_id} and container_type = 'OrgSubfield' and is_public =1 order by created_on limit 6;")
end
2016-03-29 20:09:47 +08:00
def get_attach_org2(field)
org_attachments = field.attachments
attachments = User.current.admin? ? org_attachments : visable_attachemnts(org_attachments)
return attachments.sort_by{|x| x.created_on}.reverse.first(6)
# Attachment.find_by_sql("SELECT * FROM `attachments` where container_id =#{field_id} and container_type = 'OrgSubfield' and is_public =1 order by created_on limit 6;")
end
2016-03-30 18:35:47 +08:00
# 从内容中获取路径
def get_image_path_from_content content
r = Regexp.new(/src="\/files\/uploads\/image(.+?)"/)
if r.match(content).nil?
image_path = nil
else
image_path = r.match(content)[1]
end
end
#排列下拉框
def subfield_status_option
type = []
option1 = []
2016-04-25 16:00:52 +08:00
option1 << "左上"
2016-03-31 16:19:59 +08:00
option1 << "1"
type << option1
option2 = []
2016-04-25 18:54:21 +08:00
option2 << "中一"
2016-04-25 16:00:52 +08:00
option2 << "2"
type << option2
2016-04-25 16:00:52 +08:00
option3 = []
2016-04-25 18:54:21 +08:00
option3 << "中二"
2016-04-25 16:00:52 +08:00
option3 << "3"
type << option3
option4 = []
2016-04-25 18:54:21 +08:00
option4 << "中下"
2016-04-25 16:00:52 +08:00
option4 << "4"
type << option4
option5 = []
option5 << "左下"
option5 << "5"
type << option5
option6 = []
option6 << "右上"
option6 << "6"
type << option6
option7 = []
option7 << "右中"
option7 << "7"
type << option7
option8 = []
option8 << "右下"
option8 << "8"
type << option8
type
end
2016-04-25 18:54:21 +08:00
def subfield_list_type subfield
case subfield.to_i
when 1
resulet = "左上"
when 2
resulet = "中一"
when 3
resulet = "中二"
when 4
resulet = "中下"
when 5
resulet = "左下"
when 6
resulet = "右上"
when 7
resulet = "右中"
when 8
resulet = "右下"
end
end
2015-01-30 14:11:35 +08:00
end