@field=params[:org_subfield_id].nil??OrgSubfield.where("organization_id =? and field_type =?",params[:id].to_i,"Comptec").first:OrgSubfield.find(params[:org_subfield_id])
@type=params[:type]
if@type=="courses"||@type.nil?
@org_teachers=User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count
attachments=Attachment.where("(is_publish = 1 and is_public =1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course')) ").order("#{order.nil??'created_on':order}#{score}")
attachments=Attachment.where("(is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course')) ").order("#{order.nil??'created_on':order}#{score}")
end
# 获取公共资源搜索
@ -2637,6 +2729,16 @@ class UsersController < ApplicationController
attachments=Attachment.where("id in (#{apply_ids.empty??'0':apply_ids.join(',')}) and container_type in(#{resource_type})").order("#{order.nil??'created_on':order}#{score}")
attachments=Attachment.where("id in (#{apply_ids.empty??'0':apply_ids.join(',')}) and container_type in(#{resource_type}) and (filename like :p)",:p=>search).order("#{order.nil??'created_on':order}#{score}")
attchments=Attachment.where("(container_type = 'Course'and container_id is not null and is_publish = 1 and is_public =1)").order("#{order.nil??'created_on':order}#{score}")
attchments=Attachment.where("(container_type = 'Course'and container_id is not null and is_publish = 1)").order("#{order.nil??'created_on':order}#{score}")
attchments=Attachment.where("(container_type = 'Course'and container_id is not null and is_publish = 1 and is_public =1) and (filename like :p)",:p=>search).order("#{order.nil??'created_on':order}#{score}")
attchments=Attachment.where("(container_type = 'Course'and container_id is not null and is_publish = 1) and (filename like :p)",:p=>search).order("#{order.nil??'created_on':order}#{score}")
end
# 获取我的项目资源
@ -2670,12 +2772,12 @@ class UsersController < ApplicationController
attchments=Attachment.where("container_type = 'Project' and container_id is not null and is_public =1").order("#{order.nil??'created_on':order}#{score}")
attchments=Attachment.where("container_type = 'Project' and container_id is not null").order("#{order.nil??'created_on':order}#{score}")
attchments=Attachment.where("(container_type = 'Project' and container_id is not null and is_public =1) and (filename like :p)",:p=>search).order("#{order.nil??'created_on':order}#{score}")
attchments=Attachment.where("(container_type = 'Project' and container_id is not null) and (filename like :p)",:p=>search).order("#{order.nil??'created_on':order}#{score}")
end
# 获取我上传的附件
@ -2693,13 +2795,13 @@ class UsersController < ApplicationController
@ -2714,12 +2816,12 @@ class UsersController < ApplicationController
# 获取我的用户类型资源
defget_principal_resources_publicorder,score
attchments=Attachment.where("container_type = 'Principal'and container_id is not null and is_public =1").order("#{order.nil??'created_on':order}#{score}")
attchments=Attachment.where("container_type = 'Principal'and container_id is not null").order("#{order.nil??'created_on':order}#{score}")
attchments=Attachment.where("(container_type = 'Principal'and container_id is not null and is_public =1) and (filename like :p)",:p=>search).order("#{order.nil??'created_on':order}#{score}")
attchments=Attachment.where("(container_type = 'Principal'and container_id is not null) and (filename like :p)",:p=>search).order("#{order.nil??'created_on':order}#{score}")
end
# 资源库 分为全部 课程资源 项目资源 附件
@ -2734,7 +2836,7 @@ class UsersController < ApplicationController