@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(',')})) ").order("created_on desc")
elsifparams[:type]=="3"# 项目资源
elsifparams[:type]=="3"# 项目资源
@attachments=Attachment.where("author_id = #{params[:id]} and container_type = 'Project'").order("created_on desc")
@attachments=Attachment.where("author_id = #{params[:id]} and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc")
@attachments=get_attch_resourcesparams[:id]
elsifparams[:type]=="5"#用户资源
elsifparams[:type]=="5"#用户资源
@attachments=Attachment.where("author_id = #{params[:id]} and container_type = 'Principal'").order("created_on desc")
@attachments=get_principal_resourcesparams[:id]
elsifparams[:type]=="6"# 公共资源
elsifparams[:type]=="6"# 公共资源
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")
"or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty??'0':user_course_ids.join(',')}))").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(',')})) ").order("created_on desc")
@attachments=Attachment.where("(author_id = #{params[:id]} and is_public = 1 and container_type = 'Course')"+
"or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty??'0':user_course_ids.join(',')}))").order("created_on desc")
@attachments=Attachment.where("author_id = #{params[:id]} and container_type = 'Project'").order("created_on desc")
else
@attachments=Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Project' ").order("created_on desc")
end
elsifparams[:type]=="4"#附件
elsifparams[:type]=="4"#附件
ifUser.current.id.to_i==params[:id].to_i
@attachments=get_attch_resourcesparams[:id]
@attachments=Attachment.where("author_id = #{params[:id]} and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc")
elsifparams[:type]=="5"#用户资源
else
@attachments=get_principal_resourcesparams[:id]
@attachments=Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc")
end
elsifparams[:type]=="5"#附件
ifUser.current.id.to_i==params[:id].to_i
@attachments=Attachment.where("author_id = #{params[:id]} and container_type ='Principal'").order("created_on desc")
else
@attachments=Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type ='Principal'").order("created_on desc")
end
elsifparams[:type]=="6"# 公共资源
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")
"or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty??'0':user_course_ids.join(',')}))").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(',')})) ").order("created_on desc")
@attachments=Attachment.where("(author_id = #{params[:id]} and is_public = 1 and container_type = 'Course')"+
"or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty??'0':user_course_ids.join(',')}))").order("created_on desc")
attachments=Attachment.where("(is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course')) "+
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty??'0':user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)"+
"or (container_type = 'Project' and container_id in (#{user_project_ids.empty??'0':user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)").order("created_on desc")
attachments=Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty??'0':user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)"+
"or (container_type = 'Project' and container_id in (#{user_project_ids.empty??'0':user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)").order("created_on desc")
end
# 获取我的课程资源
defget_course_resourcesauthor_id,user_course_ids
attchments=Attachment.where("(author_id = #{author_id} and container_type = 'Course' and is_publish = 1) or (container_type = 'Course' and container_id in (#{user_course_ids.empty??'0':user_course_ids.join(',')}) and is_publish = 1) ").order("created_on desc")
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty??'0':user_course_ids.join(',')}) and is_publish = 1)"+
"or (container_type = 'Project' and container_id in (#{user_project_ids.empty??'0':user_project_ids.join(',')}) and is_publish = 1)").order("created_on desc")
elsifparams[:type]=="2"# 课程资源
elsifparams[:type]=="2"# 课程资源
@attachments=Attachment.where("(author_id = #{params[:id]} and container_type = 'Course' and is_publish = 1) or (container_type = 'Course' and container_id in (#{user_course_ids.empty??'0':user_course_ids.join(',')}) and is_publish = 1) ").order("created_on desc")