@attachments=Attachment.where("((author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
end
" or (container_type = 'Course' and container_id in (#{user_course_ids.empty??'0':user_course_ids.join(',')}))) and (filename like '%#{search}%') ").order("created_on desc")
@attachments=Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty??'0':user_course_ids.join(',')})) and (filename like '%#{search}%') ").order("created_on desc")
@attachments=Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like '%#{search}%')").order("created_on desc")
@attachments=Attachment.where("author_id = #{params[:id]} and container_type = 'Principal' and (filename like '%#{search}%')").order("created_on desc")
elsifparams[:type]=="6"#公共资源
@attachments=Attachment.where("(is_public =1 and is_publish = 1 and container_id is not null)"+"or (author_id = #{params[:id]} and is_publish = 0)").order("created_on desc")
end
end
@type=params[:type]
@type=params[:type]
@limit=7
@limit=7
@ -2058,18 +2063,18 @@ class UsersController < ApplicationController
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}")
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') and (filename like :p)",:p=>search).order("#{order.nil??'created_on':order}#{score}")
attachments=Attachment.where("is_publish = 1 and is_public = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course') and (filename like :p)",:p=>search).order("#{order.nil??'created_on':order}#{score}")
end
end
# 获取我的资源
# 获取我的资源
@ -2729,15 +2734,15 @@ 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})").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}")
# 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)").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) 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) and (filename like :p)",:p=>search).order("#{order.nil??'created_on':order}#{score}")
end
end
# 获取我的项目资源
# 获取我的项目资源
@ -2772,12 +2777,12 @@ class UsersController < ApplicationController
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").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}")
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}")
end
end
# 获取我上传的附件
# 获取我上传的附件
@ -2795,13 +2800,13 @@ class UsersController < ApplicationController
@ -2816,12 +2821,12 @@ class UsersController < ApplicationController
# 获取我的用户类型资源
# 获取我的用户类型资源
defget_principal_resources_publicorder,score
defget_principal_resources_publicorder,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 is_public =1 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 (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 is_public =1) and (filename like :p)",:p=>search).order("#{order.nil??'created_on':order}#{score}")
end
end
# 资源库 分为全部 课程资源 项目资源 附件
# 资源库 分为全部 课程资源 项目资源 附件
@ -2863,18 +2868,18 @@ class UsersController < ApplicationController