diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index eb35d32d4..722522a76 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2273,9 +2273,19 @@ class UsersController < ApplicationController 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") end + # 获取公共资源课程 + def get_course_resources_public user_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") + end + # 获取我的项目资源 def get_project_resources author_id, user_project_ids - attchments = Attachment.where("author_id = #{author_id} and container_type = 'Project'").order("created_on desc") + attchments = Attachment.where("(author_id = #{author_id} and container_type = 'Project') or (container_type = 'Course' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1) ").order("created_on desc") + end + + # 获取公共资源的项目资源 + def get_project_resources_public user_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") end # 获取我上传的附件 @@ -2283,11 +2293,21 @@ class UsersController < ApplicationController attchments = Attachment.where("author_id = #{author_id} and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal')").order("created_on desc") end + # 获取公共资源中我上传的附件 + def get_attch_resources_public + attchments = Attachment.where("container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal')").order("created_on desc") + end + # 获取我的用户类型资源 def get_principal_resources author_id attchments = Attachment.where("author_id = #{author_id} and container_type = 'Principal'").order("created_on desc") end + # 获取我的用户类型资源 + def get_principal_resources_public + attchments = Attachment.where("container_type = 'Principal'").order("created_on desc") + end + # 资源库 分为全部 课程资源 项目资源 附件 def user_resource # 别人的资源库是没有权限去看的 @@ -2300,7 +2320,18 @@ class UsersController < ApplicationController # user_org_ids = User.current.organizations.map {|o| o.id} if(params[:type].blank? || params[:type] == "1") # 我的资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 - @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids) + if params[:status] == 2 + @attachments = get_course_resources(params[:id], user_course_ids) + elsif params[:status] == "3" + @attachments = get_project_resources(params[:id], user_project_ids) + elsif params[:status] == "4" + @attachments = get_attch_resources params[:id] + elsif params[:status] == "5" + @attachments = get_principal_resources params[:id] + else + # 公共资源库:所有公开资源或者我上传的私有资源 + @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids) + end elsif params[:type] == "2" # 课程资源 @attachments = get_course_resources(params[:id], user_course_ids) elsif params[:type] == "3" # 项目资源 @@ -2310,9 +2341,20 @@ class UsersController < ApplicationController elsif params[:type] == "5" #用户资源 @attachments = get_principal_resources params[:id] elsif params[:type] == "6" # 公共资源 - # 公共资源库:所有公开资源或者我上传的私有资源 - @attachments = get_public_resources(user_course_ids, user_project_ids) + if params[:status] == "2" + @attachments = get_course_resources_public( user_course_ids) + elsif params[:status] == "3" + @attachments = get_project_resources_public(user_project_ids) + elsif params[:status] == "4" + @attachments = get_attch_resources_public + elsif params[:status] == "5" + @attachments = get_principal_resources_public + else + # 公共资源库:所有公开资源或者我上传的私有资源 + @attachments = get_public_resources(user_course_ids, user_project_ids) + end end + @status = params[:status] @type = params[:type] @limit = 25 @is_remote = true diff --git a/app/views/users/_import_resource_info.html.erb b/app/views/users/_import_resource_info.html.erb index 7b613a962..63fc15ef6 100644 --- a/app/views/users/_import_resource_info.html.erb +++ b/app/views/users/_import_resource_info.html.erb @@ -1,5 +1,10 @@ -