63 lines
2.6 KiB
Ruby
63 lines
2.6 KiB
Ruby
# encoding: utf-8
|
|
module OrganizationsHelper
|
|
include ApplicationHelper
|
|
include FilesHelper
|
|
|
|
|
|
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
|
|
}
|
|
s + content_tag('ul', links,:class => 'wlist',:style=>'float:left !important', :id => "org_member_pagination_links" )
|
|
end
|
|
|
|
def get_default_name field
|
|
case field.name
|
|
when 'activity' then
|
|
return '动态'
|
|
when 'course' then
|
|
return '课程'
|
|
when 'project' then
|
|
return '项目'
|
|
end
|
|
end
|
|
|
|
def get_message_org(org_id, field_id)
|
|
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 2;")
|
|
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;")
|
|
end
|
|
|
|
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
|
|
|
|
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
|
|
|
|
# 从内容中获取路径
|
|
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
|
|
|
|
end
|