代码更新
This commit is contained in:
parent
a10475fa65
commit
9aab10c05a
|
@ -824,20 +824,33 @@ class UsersController < ApplicationController
|
|||
user_course_ids = User.current.courses.map { |c| c.id}
|
||||
user_project_ids = User.current.projects.map {|p| p.id}
|
||||
# user_org_ids = User.current.organizations.map {|o| o.id}
|
||||
if(params[:type].blank? || params[:type] == "1") #全部
|
||||
if(params[:type].blank? || params[:type] == "1") # 我的资源
|
||||
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
|
||||
@attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, params[:order])
|
||||
elsif params[:type] == "2" # 课程资源
|
||||
@attachments = get_course_resources(params[:id], user_course_ids, params[:order])
|
||||
elsif params[:type] == "3" # 项目资源
|
||||
@attachments = get_project_resources(params[:id], user_project_ids, params[:order])
|
||||
elsif params[:type] == "4" #附件
|
||||
@attachments = get_attch_resources params[:id], params[:order]
|
||||
elsif params[:type] == "5" #用户资源
|
||||
@attachments = get_principal_resources params[:id], params[:order]
|
||||
if params[:status] == "2"
|
||||
@attachments = get_course_resources(params[:id], user_course_ids, @order, @score)
|
||||
elsif params[:status] == "3"
|
||||
@attachments = get_project_resources(params[:id], user_project_ids, @order, @score)
|
||||
elsif params[:status] == "4"
|
||||
@attachments = get_attch_resources(params[:id], @order, @score)
|
||||
elsif params[:status] == "5"
|
||||
@attachments = get_principal_resources(params[:id], @order, @score)
|
||||
else
|
||||
# 公共资源库:所有公开资源或者我上传的私有资源
|
||||
@attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score)
|
||||
end
|
||||
elsif params[:type] == "6" # 公共资源
|
||||
# 公共资源库:所有公开资源或者我上传的私有资源
|
||||
@attachments = get_public_resources(user_course_ids, user_project_ids, params[:order])
|
||||
if params[:status] == "2"
|
||||
@attachments = get_course_resources_public( user_course_ids, @order, @score)
|
||||
elsif params[:status] == "3"
|
||||
@attachments = get_project_resources_public(user_project_ids, @order, @score)
|
||||
elsif params[:status] == "4"
|
||||
@attachments = get_attch_resources_public(@order, @score)
|
||||
elsif params[:status] == "5"
|
||||
@attachments = get_principal_resources_public(@order, @score)
|
||||
else
|
||||
# 公共资源库:所有公开资源或者我上传的私有资源
|
||||
@attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score)
|
||||
end
|
||||
end
|
||||
@type = params[:type]
|
||||
@limit = 7
|
||||
|
@ -2503,16 +2516,19 @@ class UsersController < ApplicationController
|
|||
render_403
|
||||
return
|
||||
end
|
||||
@user = User.find(params[:id])
|
||||
@order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
|
||||
@score = @b_sort == "desc" ? "asc" : "desc"
|
||||
user_course_ids = User.current.courses.map { |c| c.id}
|
||||
user_project_ids = User.current.projects.map {|p| p.id}
|
||||
# user_org_ids = User.current.organizations.map {|o| o.id}
|
||||
user_project_ids = User.current.projects.map {|p| p.id} # 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, params[:order])
|
||||
@attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score)
|
||||
elsif params[:type] == "6" # 公共资源
|
||||
# 公共资源库:所有公开资源或者我上传的私有资源
|
||||
@attachments = get_public_resources(user_course_ids, user_project_ids, params[:order])
|
||||
@attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score)
|
||||
end
|
||||
@status = params[:status]
|
||||
@type = params[:type]
|
||||
@limit = 10
|
||||
@is_remote = true
|
||||
|
@ -2534,20 +2550,15 @@ class UsersController < ApplicationController
|
|||
render_403
|
||||
return
|
||||
end
|
||||
user_course_ids = User.current.courses.map { |c| c.id}
|
||||
user_project_ids = User.current.projects.map {|p| p.id}
|
||||
# user_org_ids = User.current.organizations.map {|o| o.id}
|
||||
if(params[:type].blank? || params[:type] == "1") # 我的资源
|
||||
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
|
||||
user_course_ids = User.current.courses.map { |c| c.id}
|
||||
user_project_ids = User.current.projects.map {|p| p.id}
|
||||
# user_org_ids = User.current.organizations.map {|o| o.id}
|
||||
@attachments = Attachment.where("((author_id = #{params[: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)) and (filename like :p)" ,:p => search).order("#{params[:order].nil? ? 'created_on' : params[:order]} desc")
|
||||
@attachments = get_my_resources_search(params[:id], user_course_ids, user_project_ids, @order, @score, search)
|
||||
elsif params[:type] == "6" # 公共资源
|
||||
# 公共资源库:所有公开资源或者我上传的私有资源
|
||||
@attachments = get_public_resources(user_course_ids, user_project_ids, params[:order])
|
||||
@attachments = get_public_resources_search(user_course_ids, user_project_ids, @order, @score, search)
|
||||
end
|
||||
@type = params[:type]
|
||||
@limit = 10
|
||||
|
|
Loading…
Reference in New Issue