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("(is_publish = 1 and is_public =1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course')) ").order("created_on desc")
end
# 获取我的资源
@ -2359,7 +2357,7 @@ class UsersController < ApplicationController
# 获取公共资源课程
defget_course_resources_publicuser_course_ids
attchments=Attachment.where("(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")
attchments=Attachment.where("(container_type = 'Course'and container_id is not null and is_publish = 1 and is_public =1)").order("created_on desc")
end
# 获取我的项目资源
@ -2369,7 +2367,7 @@ class UsersController < ApplicationController
# 获取公共资源的项目资源
defget_project_resources_publicuser_project_ids
attchments=Attachment.where("(container_type = 'Project') 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")
attchments=Attachment.where("container_type = 'Project' and container_id is not null and is_public =1").order("created_on desc")
end
# 获取我上传的附件
@ -2379,7 +2377,7 @@ class UsersController < ApplicationController
attchments=Attachment.where("container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal') and container_id is not null and is_public =1").order("created_on desc")
end
# 获取我的用户类型资源
@ -2389,7 +2387,7 @@ class UsersController < ApplicationController
attchments=Attachment.where("container_type = 'Principal'and container_id is not null and is_public =1").order("created_on desc")
end
# 资源库 分为全部 课程资源 项目资源 附件
@ -2621,9 +2619,7 @@ class UsersController < ApplicationController
end
elsifparams[:type]=="6"#全部资源
# 公共资源库:所有公开资源或者我上传的私有资源
@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)) and (filename like :p)",:p=>search).order("created_on desc")
@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("created_on desc")