注释掉申请私有资源功能
This commit is contained in:
parent
b38bd0c1e5
commit
197f054c18
|
@ -1022,34 +1022,20 @@ class UsersController < ApplicationController
|
||||||
|
|
||||||
#用户从资源库导入资源到作业
|
#用户从资源库导入资源到作业
|
||||||
def user_import_resource
|
def user_import_resource
|
||||||
if User.current.id.to_i != params[:id].to_i
|
@user = User.current
|
||||||
render_403
|
user_course_ids = @user.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
|
||||||
return
|
@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(',')}))").order("created_on desc")
|
||||||
@resource_id = params[:project_id].nil? ? (params[:course_id].nil? ? params[:subfield_file_id] : params[:course_id]) : params[:project_id]
|
|
||||||
@resource_type = params[:project_id].nil? ? (params[:course_id].nil? ? "SubfieldFile" : "Course") : "Project"
|
|
||||||
@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.is_delete == 0 && c.id}
|
|
||||||
user_project_ids = User.current.projects.map {|p| p.status != 9 && p.id } # user_org_ids = User.current.organizations.map {|o| o.id}
|
|
||||||
if(params[:type] == "1") # 我的资源
|
|
||||||
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
|
|
||||||
@attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score)
|
|
||||||
elsif (params[:type].blank? ||params[:type] == "6") # 公共资源
|
|
||||||
# 公共资源库:所有公开资源或者我上传的私有资源
|
|
||||||
@attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score)
|
|
||||||
end
|
|
||||||
@status = params[:status]
|
|
||||||
@type = params[:type]
|
@type = params[:type]
|
||||||
@homework_id = params[:homework_id]
|
@homework_id = params[:homework_id]
|
||||||
@limit = 10
|
@limit = 7
|
||||||
@is_remote = true
|
@is_remote = true
|
||||||
@seleted_resources = session[:seleted_resource_ids].nil? ? [] : session[:seleted_resource_ids]
|
|
||||||
@atta_count = @attachments.count
|
@atta_count = @attachments.count
|
||||||
@atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1
|
@atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1
|
||||||
@offset ||= @atta_pages.offset
|
@offset ||= @atta_pages.offset
|
||||||
|
@seleted_resources = session[:seleted_resource_ids].nil? ? [] : session[:seleted_resource_ids]
|
||||||
#@curse_attachments_all = @all_attachments[@offset, @limit]
|
#@curse_attachments_all = @all_attachments[@offset, @limit]
|
||||||
@attachments = paginateHelper @attachments,10
|
@attachments = paginateHelper @attachments,7
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
end
|
end
|
||||||
|
@ -1057,10 +1043,10 @@ class UsersController < ApplicationController
|
||||||
|
|
||||||
#引入资源列表根据类型过滤
|
#引入资源列表根据类型过滤
|
||||||
def user_resource_type
|
def user_resource_type
|
||||||
# if User.current.id.to_i != params[:id].to_i
|
if User.current.id.to_i != params[:id].to_i
|
||||||
# render_403
|
render_403
|
||||||
# return
|
return
|
||||||
# end
|
end
|
||||||
user_course_ids = User.current.courses.map { |c| c.is_delete == 0 && c.id}
|
user_course_ids = User.current.courses.map { |c| c.is_delete == 0 && c.id}
|
||||||
user_project_ids = User.current.projects.map {|p| p.status != 9 && p.id }
|
user_project_ids = User.current.projects.map {|p| p.status != 9 && p.id }
|
||||||
# user_org_ids = User.current.organizations.map {|o| o.id}
|
# user_org_ids = User.current.organizations.map {|o| o.id}
|
||||||
|
@ -1109,27 +1095,22 @@ class UsersController < ApplicationController
|
||||||
|
|
||||||
#引入资源列表根据关键词过滤
|
#引入资源列表根据关键词过滤
|
||||||
def user_ref_resource_search
|
def user_ref_resource_search
|
||||||
if User.current.id.to_i != params[:id].to_i
|
search = params[:search].to_s.strip.downcase
|
||||||
render_403
|
if(params[:type].blank? || params[:type] == "1") #全部
|
||||||
return
|
user_course_ids = User.current.courses.map { |c| c.is_delete == 0 && c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 取交集并查询
|
||||||
end
|
@attachments = Attachment.where("((author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
|
||||||
@resource_id = params[:mul_id]
|
" 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")
|
||||||
@resource_type = params[:mul_type]
|
elsif params[:type] == "2" #课程资源
|
||||||
@order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
|
|
||||||
@score = @b_sort == "desc" ? "asc" : "desc"
|
|
||||||
@user = User.current
|
|
||||||
@switch_search = params[:search].nil? ? " " : params[:search]
|
|
||||||
search = "%#{@switch_search.strip.downcase}%"
|
|
||||||
# 别人的资源库是没有权限去看的
|
|
||||||
if(params[:type] == "1") # 我的资源
|
|
||||||
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
|
|
||||||
user_course_ids = User.current.courses.map { |c| c.is_delete == 0 && c.id}
|
user_course_ids = User.current.courses.map { |c| c.is_delete == 0 && c.id}
|
||||||
user_project_ids = User.current.projects.map {|p| p.status != 9 && p.id }
|
@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")
|
||||||
# user_org_ids = User.current.organizations.map {|o| o.id}
|
elsif params[:type] == "3" #项目资源
|
||||||
@attachments = get_my_resources_search(params[:id], user_course_ids, user_project_ids, @order, @score, search)
|
@attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project' and (filename like '%#{search}%')").order("created_on desc")
|
||||||
elsif (params[:type].blank? || params[:type] == "6") # 公共资源
|
elsif params[:type] == "4" #附件
|
||||||
# 公共资源库:所有公开资源或者我上传的私有资源
|
@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 = get_public_resources_search(user_course_ids, user_project_ids, @order, @score, search)
|
elsif params[:type] == "5" #用户资源
|
||||||
|
@attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal' and (filename like '%#{search}%')").order("created_on desc")
|
||||||
|
elsif params[: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
|
||||||
|
@ -1139,7 +1120,7 @@ class UsersController < ApplicationController
|
||||||
@offset ||= @atta_pages.offset
|
@offset ||= @atta_pages.offset
|
||||||
@seleted_resources = session[:seleted_resource_ids].nil? ? [] : session[:seleted_resource_ids]
|
@seleted_resources = session[:seleted_resource_ids].nil? ? [] : session[:seleted_resource_ids]
|
||||||
#@curse_attachments_all = @all_attachments[@offset, @limit]
|
#@curse_attachments_all = @all_attachments[@offset, @limit]
|
||||||
@attachments = paginateHelper @attachments, 7
|
@attachments = paginateHelper @attachments,7
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
end
|
end
|
||||||
|
@ -2077,18 +2058,18 @@ class UsersController < ApplicationController
|
||||||
# 公共资源库:所有公开资源或者我上传的私有资源
|
# 公共资源库:所有公开资源或者我上传的私有资源
|
||||||
@attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score)
|
@attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score)
|
||||||
end
|
end
|
||||||
elsif params[:type] == "2"
|
# elsif params[:type] == "2"
|
||||||
apply_ids = ApplyResource.where("user_id =? and status =?", params[:id], 2).map { |ar| ar.attachment_id}
|
# apply_ids = ApplyResource.where("user_id =? and status =?", params[:id], 2).map { |ar| ar.attachment_id}
|
||||||
if params[:status] == "2"
|
# if params[:status] == "2"
|
||||||
resource_type = "'Course'"
|
# resource_type = "'Course'"
|
||||||
elsif params[:status] == "3"
|
# elsif params[:status] == "3"
|
||||||
resource_type = "'Project'"
|
# resource_type = "'Project'"
|
||||||
elsif params[:status] == "5"
|
# elsif params[:status] == "5"
|
||||||
resource_type = "'Principal'"
|
# resource_type = "'Principal'"
|
||||||
else
|
# else
|
||||||
resource_type = "'Project','OrgSubfield','Principal','Course'"
|
# resource_type = "'Project','OrgSubfield','Principal','Course'"
|
||||||
end
|
# end
|
||||||
@attachments = get_my_private_resources(apply_ids, resource_type, @order, @score)
|
# @attachments = get_my_private_resources(apply_ids, resource_type, @order, @score)
|
||||||
end
|
end
|
||||||
@type = params[:type]
|
@type = params[:type]
|
||||||
@limit = 25
|
@limit = 25
|
||||||
|
@ -2230,18 +2211,18 @@ class UsersController < ApplicationController
|
||||||
# 公共资源库:所有公开资源或者我上传的私有资源
|
# 公共资源库:所有公开资源或者我上传的私有资源
|
||||||
@attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score)
|
@attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score)
|
||||||
end
|
end
|
||||||
elsif params[:type] == "2"
|
# elsif params[:type] == "2"
|
||||||
apply_ids = ApplyResource.where("user_id =? and status =?", params[:id], 2).map { |ar| ar.attachment_id}
|
# apply_ids = ApplyResource.where("user_id =? and status =?", params[:id], 2).map { |ar| ar.attachment_id}
|
||||||
if params[:status] == "2"
|
# if params[:status] == "2"
|
||||||
resource_type = "'Course'"
|
# resource_type = "'Course'"
|
||||||
elsif params[:status] == "3"
|
# elsif params[:status] == "3"
|
||||||
resource_type = "'Project'"
|
# resource_type = "'Project'"
|
||||||
elsif params[:status] == "5"
|
# elsif params[:status] == "5"
|
||||||
resource_type = "'Principal'"
|
# resource_type = "'Principal'"
|
||||||
else
|
# else
|
||||||
resource_type = "'Project','OrgSubfield','Principal','Course'"
|
# resource_type = "'Project','OrgSubfield','Principal','Course'"
|
||||||
end
|
# end
|
||||||
@attachments = get_my_private_resources(apply_ids, resource_type, @order, @score)
|
# @attachments = get_my_private_resources(apply_ids, resource_type, @order, @score)
|
||||||
end
|
end
|
||||||
@status = params[:status]
|
@status = params[:status]
|
||||||
@type = params[:type]
|
@type = params[:type]
|
||||||
|
@ -2371,18 +2352,18 @@ class UsersController < ApplicationController
|
||||||
# 公共资源库:所有公开资源或者我上传的私有资源
|
# 公共资源库:所有公开资源或者我上传的私有资源
|
||||||
@attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score)
|
@attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score)
|
||||||
end
|
end
|
||||||
elsif params[:type] == "2"
|
# elsif params[:type] == "2"
|
||||||
apply_ids = ApplyResource.where("user_id =? and status =?", params[:id], 2).map { |ar| ar.attachment_id}
|
# apply_ids = ApplyResource.where("user_id =? and status =?", params[:id], 2).map { |ar| ar.attachment_id}
|
||||||
if params[:status] == "2"
|
# if params[:status] == "2"
|
||||||
resource_type = "'Course'"
|
# resource_type = "'Course'"
|
||||||
elsif params[:status] == "3"
|
# elsif params[:status] == "3"
|
||||||
resource_type = "'Project'"
|
# resource_type = "'Project'"
|
||||||
elsif params[:status] == "5"
|
# elsif params[:status] == "5"
|
||||||
resource_type = "'Principal'"
|
# resource_type = "'Principal'"
|
||||||
else
|
# else
|
||||||
resource_type = "'Project','OrgSubfield','Principal','Course'"
|
# resource_type = "'Project','OrgSubfield','Principal','Course'"
|
||||||
end
|
# end
|
||||||
@attachments = get_my_private_resources(apply_ids, resource_type, @order, @score)
|
# @attachments = get_my_private_resources(apply_ids, resource_type, @order, @score)
|
||||||
end
|
end
|
||||||
@type = params[:type]
|
@type = params[:type]
|
||||||
@limit = 25
|
@limit = 25
|
||||||
|
@ -2719,12 +2700,12 @@ class UsersController < ApplicationController
|
||||||
|
|
||||||
# 获取公共资源
|
# 获取公共资源
|
||||||
def get_public_resources user_course_ids, user_project_ids, order, score
|
def get_public_resources user_course_ids, user_project_ids, order, score
|
||||||
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}")
|
||||||
end
|
end
|
||||||
|
|
||||||
# 获取公共资源搜索
|
# 获取公共资源搜索
|
||||||
def get_public_resources_search user_course_ids, user_project_ids, order, score, search
|
def get_public_resources_search user_course_ids, user_project_ids, order, score, search
|
||||||
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
|
||||||
|
|
||||||
# 获取我的资源
|
# 获取我的资源
|
||||||
|
@ -2748,15 +2729,15 @@ class UsersController < ApplicationController
|
||||||
and is_publish = 1 and container_id is not null)" ).order("#{order.nil? ? 'created_on' : order} #{score}")
|
and is_publish = 1 and container_id is not null)" ).order("#{order.nil? ? 'created_on' : order} #{score}")
|
||||||
end
|
end
|
||||||
|
|
||||||
# 获取我的私有资源分享结果
|
# # 获取我的私有资源分享结果
|
||||||
def get_my_private_resources apply_ids, resource_type, order, score
|
# def get_my_private_resources apply_ids, resource_type, 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})").order("#{order.nil? ? 'created_on' : order} #{score}")
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
# 获取我的私有资源分享搜索结果
|
# # 获取我的私有资源分享搜索结果
|
||||||
def get_my_private_resources_search apply_ids, resource_type, order, score, search
|
# def get_my_private_resources_search apply_ids, resource_type, order, score, search
|
||||||
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}")
|
||||||
end
|
# end
|
||||||
|
|
||||||
# 获取我的课程资源中搜索结果
|
# 获取我的课程资源中搜索结果
|
||||||
def get_course_resources_search author_id, user_course_ids, order, score, search
|
def get_course_resources_search author_id, user_course_ids, order, score, search
|
||||||
|
@ -2767,12 +2748,12 @@ class UsersController < ApplicationController
|
||||||
|
|
||||||
# 获取公共资源中课程资源
|
# 获取公共资源中课程资源
|
||||||
def get_course_resources_public user_course_ids, order, score
|
def get_course_resources_public user_course_ids, 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}")
|
||||||
end
|
end
|
||||||
|
|
||||||
# 获取公共资源中课程资源搜索结果
|
# 获取公共资源中课程资源搜索结果
|
||||||
def get_course_resources_public_search user_course_ids, order, score, search
|
def get_course_resources_public_search user_course_ids, order, score, search
|
||||||
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
|
||||||
|
|
||||||
# 获取我的项目资源
|
# 获取我的项目资源
|
||||||
|
@ -2791,12 +2772,12 @@ class UsersController < ApplicationController
|
||||||
|
|
||||||
# 获取公共资源的项目资源
|
# 获取公共资源的项目资源
|
||||||
def get_project_resources_public user_project_ids, order, score
|
def get_project_resources_public user_project_ids, order, score
|
||||||
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}")
|
||||||
end
|
end
|
||||||
|
|
||||||
# 获取公共资源的项目资源搜索
|
# 获取公共资源的项目资源搜索
|
||||||
def get_project_resources_public_search user_project_ids, order, score, search
|
def get_project_resources_public_search user_project_ids, order, score, search
|
||||||
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
|
||||||
|
|
||||||
# 获取我上传的附件
|
# 获取我上传的附件
|
||||||
|
@ -2814,13 +2795,13 @@ class UsersController < ApplicationController
|
||||||
# 获取公共资源中我上传的附件
|
# 获取公共资源中我上传的附件
|
||||||
def get_attch_resources_public order, score
|
def get_attch_resources_public order, score
|
||||||
attchments = Attachment.where("container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal')
|
attchments = Attachment.where("container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal')
|
||||||
and container_id is not null").order("#{order.nil? ? 'created_on' : order} #{score}")
|
and container_id is not null and is_public =1").order("#{order.nil? ? 'created_on' : order} #{score}")
|
||||||
end
|
end
|
||||||
|
|
||||||
# 获取公共资源中我上传的附件
|
# 获取公共资源中我上传的附件
|
||||||
def get_attch_resources_public_search order, score, search
|
def get_attch_resources_public_search order, score, search
|
||||||
attchments = Attachment.where("(container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal')
|
attchments = Attachment.where("(container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal')
|
||||||
and container_id is not null) and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}")
|
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
|
||||||
|
|
||||||
# 获取我的用户类型资源
|
# 获取我的用户类型资源
|
||||||
|
@ -2835,12 +2816,12 @@ class UsersController < ApplicationController
|
||||||
|
|
||||||
# 获取我的用户类型资源
|
# 获取我的用户类型资源
|
||||||
def get_principal_resources_public order, score
|
def get_principal_resources_public order, 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}")
|
||||||
end
|
end
|
||||||
|
|
||||||
# 获取我的用户类型资源
|
# 获取我的用户类型资源
|
||||||
def get_principal_resources_public_search order, score, search
|
def get_principal_resources_public_search order, score, search
|
||||||
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
|
||||||
|
|
||||||
# 资源库 分为全部 课程资源 项目资源 附件
|
# 资源库 分为全部 课程资源 项目资源 附件
|
||||||
|
@ -2882,18 +2863,18 @@ class UsersController < ApplicationController
|
||||||
# 公共资源库:所有公开资源或者我上传的私有资源
|
# 公共资源库:所有公开资源或者我上传的私有资源
|
||||||
@attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score)
|
@attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score)
|
||||||
end
|
end
|
||||||
elsif params[:type] == "2" # 私有资源
|
# elsif params[:type] == "2" # 私有资源
|
||||||
apply_ids = ApplyResource.where("user_id =? and status =?", params[:id], 2).map { |ar| ar.attachment_id}
|
# apply_ids = ApplyResource.where("user_id =? and status =?", params[:id], 2).map { |ar| ar.attachment_id}
|
||||||
if params[:status] == "2"
|
# if params[:status] == "2"
|
||||||
resource_type = "'Course'"
|
# resource_type = "'Course'"
|
||||||
elsif params[:status] == "3"
|
# elsif params[:status] == "3"
|
||||||
resource_type = "'Project'"
|
# resource_type = "'Project'"
|
||||||
elsif params[:status] == "5"
|
# elsif params[:status] == "5"
|
||||||
resource_type = "'Principal'"
|
# resource_type = "'Principal'"
|
||||||
else
|
# else
|
||||||
resource_type = "'Project','OrgSubfield','Principal','Course'"
|
# resource_type = "'Project','OrgSubfield','Principal','Course'"
|
||||||
end
|
# end
|
||||||
@attachments = get_my_private_resources(apply_ids, resource_type, @order, @score)
|
# @attachments = get_my_private_resources(apply_ids, resource_type, @order, @score)
|
||||||
end
|
end
|
||||||
@status = params[:status]
|
@status = params[:status]
|
||||||
@type = params[:type]
|
@type = params[:type]
|
||||||
|
@ -3073,19 +3054,19 @@ class UsersController < ApplicationController
|
||||||
# 公共资源库:所有公开资源或者我上传的私有资源
|
# 公共资源库:所有公开资源或者我上传的私有资源
|
||||||
@attachments = get_public_resources_search(user_course_ids, user_project_ids, @order, @score, search)
|
@attachments = get_public_resources_search(user_course_ids, user_project_ids, @order, @score, search)
|
||||||
end
|
end
|
||||||
elsif params[:type] == "2" # 私有资源
|
# elsif params[:type] == "2" # 私有资源
|
||||||
apply_ids = ApplyResource.where("user_id =? and status =?", params[:id], 2).map { |ar| ar.attachment_id}
|
# apply_ids = ApplyResource.where("user_id =? and status =?", params[:id], 2).map { |ar| ar.attachment_id}
|
||||||
if params[:status] == "2"
|
# if params[:status] == "2"
|
||||||
resource_type = "'Course'"
|
# resource_type = "'Course'"
|
||||||
elsif params[:status] == "3"
|
# elsif params[:status] == "3"
|
||||||
resource_type = "'Project'"
|
# resource_type = "'Project'"
|
||||||
elsif params[:status] == "5"
|
# elsif params[:status] == "5"
|
||||||
resource_type = "'Principal'"
|
# resource_type = "'Principal'"
|
||||||
else
|
# else
|
||||||
resource_type = "'Project','OrgSubfield','Principal','Course'"
|
# resource_type = "'Project','OrgSubfield','Principal','Course'"
|
||||||
end
|
# end
|
||||||
@attachments = get_my_private_resources_search(apply_ids, resource_type, @order, @score, search)
|
# @attachments = get_my_private_resources_search(apply_ids, resource_type, @order, @score, search)
|
||||||
@attachments
|
# @attachments
|
||||||
end
|
end
|
||||||
@status = params[:status]
|
@status = params[:status]
|
||||||
@type = params[:type]
|
@type = params[:type]
|
||||||
|
|
|
@ -6,55 +6,20 @@
|
||||||
<% attachments.each do |attach| %>
|
<% attachments.each do |attach| %>
|
||||||
<ul class="resource-list" onmouseover="if($('#contextMenu').css('display') != 'block')$(this).children().css('background-color', '#e1e1e1')" onmouseout=" if($('#contextMenu').css('display') == 'none')$(this).children().css('background-color', 'white')">
|
<ul class="resource-list" onmouseover="if($('#contextMenu').css('display') != 'block')$(this).children().css('background-color', '#e1e1e1')" onmouseout=" if($('#contextMenu').css('display') == 'none')$(this).children().css('background-color', 'white')">
|
||||||
<li class="resource-list-checkbox fl">
|
<li class="resource-list-checkbox fl">
|
||||||
<% if private_attachment_allow(attach.id) && (@type == "6" || @type == "2") %>
|
|
||||||
<input name="checkbox1[]" type="checkbox" disabled="disabled" data-has-history="<%= attach.attachment_histories.count == 0 ? 'N' : 'Y' %>" data-deleteble="<%= User.current.id ==attach.author_id ? 'Y' : 'N' %>" onclick="checkAllBox($(this));" value="<%= attach.id%>" class="resourcesCheckbox" />
|
|
||||||
<% else %>
|
|
||||||
<input name="checkbox1[]" type="checkbox" data-has-history="<%= attach.attachment_histories.count == 0 ? 'N' : 'Y' %>" data-deleteble="<%= User.current.id ==attach.author_id ? 'Y' : 'N' %>" onclick="checkAllBox($(this));" value="<%= attach.id%>" class="resourcesCheckbox" />
|
<input name="checkbox1[]" type="checkbox" data-has-history="<%= attach.attachment_histories.count == 0 ? 'N' : 'Y' %>" data-deleteble="<%= User.current.id ==attach.author_id ? 'Y' : 'N' %>" onclick="checkAllBox($(this));" value="<%= attach.id%>" class="resourcesCheckbox" />
|
||||||
<% end %>
|
|
||||||
<!--<input name="checkbox2" type="checkbox" value="" class="resourcesCheckbox" />-->
|
<!--<input name="checkbox2" type="checkbox" value="" class="resourcesCheckbox" />-->
|
||||||
</li>
|
</li>
|
||||||
<li class="resource-list-name fl">
|
<li class="resource-list-name fl">
|
||||||
<% if private_attachment_allow(attach.id) %>
|
|
||||||
<a style="cursor: default" class = "resourcesBlack resource-list-middle hidden mw280" title="<%= attach.filename %>"><%= attach.filename %> </a>
|
|
||||||
<% else %>
|
|
||||||
<%= link_to truncate(attach.filename, :length => 30), download_named_attachment_path(attach.id, attach.filename), :title => attach.filename, :class => 'resourcesBlack resource-list-middle hidden mw280' %>
|
<%= link_to truncate(attach.filename, :length => 30), download_named_attachment_path(attach.id, attach.filename), :title => attach.filename, :class => 'resourcesBlack resource-list-middle hidden mw280' %>
|
||||||
<% end %>
|
|
||||||
<% if private_attachment_allow(attach.id) && (@type == "6" || @type == "2") %>
|
|
||||||
<img src="/images/locked.png" alt="私有" title="私有" class="resource-list-middle" height="16" width="16">
|
|
||||||
<% end %>
|
|
||||||
</li>
|
|
||||||
<li class="resource-list-apply fr" id="resource_apply_status_<%=attach.id %>">
|
|
||||||
<% if private_attachment_allow(attach.id) && (@type == "6" || @type == "2") %>
|
|
||||||
<% ah = attach.get_status_by_attach(User.current.id) %>
|
|
||||||
<% if ah.nil? %>
|
|
||||||
<%= link_to("请求分享", apply_resource_user_path(User.current.id, :attachment_id => attach.id), :class => 'green_btn_share c_white', :remote => true) %>
|
|
||||||
<% elsif ah == 1 %>
|
|
||||||
等待回复
|
|
||||||
<% elsif ah == 2 %>
|
|
||||||
可引用
|
|
||||||
<% elsif ah == 3 %>
|
|
||||||
已拒绝
|
|
||||||
<% end %>
|
|
||||||
<% else %>
|
|
||||||
<% ah = attach.get_status_by_attach(User.current.id) %>
|
|
||||||
<% if ah == 2 %>
|
|
||||||
可引用
|
|
||||||
<% else %>
|
|
||||||
--
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
|
||||||
</li>
|
</li>
|
||||||
<li class="resource-list-time fr"><%= format_date(attach.created_on) %></li>
|
<li class="resource-list-time fr"><%= format_date(attach.created_on) %></li>
|
||||||
<li class="resource-list-quote fr"><%= attach.quotes.nil? ? 0 : attach.quotes %></li>
|
<li class="resource-list-quote fr"><%= attach.quotes.nil? ? 0 : attach.quotes %></li>
|
||||||
<li class="resource-list-download fr"><%= attach.downloads %></li>
|
<li class="resource-list-download fr"><%= attach.downloads %></li>
|
||||||
<li style="display: none"><%= attach.author_id %></li>
|
<li style="display: none"><%= attach.author_id %></li>
|
||||||
<li class="resource-list-size fr"><%= (number_to_human_size(attach.filesize)).gsub("ytes", "") %></li>
|
<li class="resource-list-size fr"><%= (number_to_human_size(attach.filesize)).gsub("ytes", "") %></li>
|
||||||
<li class="resource-list-uploader fr hidden"><%=User.find(attach.author_id).realname.blank? ? User.find(attach.author_id).nickname : User.find(attach.author_id).realname %></li>
|
<li class="resource-list-uploader fr hidden"><%= User.find(attach.author_id).realname.blank? ? User.find(attach.author_id).nickname : User.find(attach.author_id).realname %></li>
|
||||||
<li class="resource-list-type fr"><%= get_resource_type(attach.container_type)%></li>
|
<li class="resource-list-type fr"><%= get_resource_type(attach.container_type)%></li>
|
||||||
<li class="resource-list-from fr hidden" title="<%= get_resource_origin(attach) %>"><%= get_resource_origin(attach) %></li>
|
<li class="resource-list-from fr hidden" title="<%= get_resource_origin(attach) %>"><%= get_resource_origin(attach) %></li>
|
||||||
<li style="display: none"><%= private_attachment_allow(attach.id) %></li>
|
|
||||||
<li style="display: none"><%= attach.get_apply_resource_status(attach.id, User.current.id) %></li>
|
|
||||||
<li style="display: none"><%= private_attachment_allow(attach.id) ? 0 : 1 %></li>
|
|
||||||
<li style="display: none"><%= attach.id %></li>
|
<li style="display: none"><%= attach.id %></li>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
|
@ -104,7 +69,7 @@
|
||||||
document.oncontextmenu = function() {return true;}
|
document.oncontextmenu = function() {return true;}
|
||||||
line.children().css("background-color",'white');
|
line.children().css("background-color",'white');
|
||||||
id = line.children().last().html();
|
id = line.children().last().html();
|
||||||
user_id = line.children().eq(6).html();
|
user_id = line.children().eq(5).html();
|
||||||
allow = line.children().eq(13).html();
|
allow = line.children().eq(13).html();
|
||||||
if( allow == 0){
|
if( allow == 0){
|
||||||
alert('您无权发送私有资源')
|
alert('您无权发送私有资源')
|
||||||
|
@ -219,7 +184,7 @@
|
||||||
}
|
}
|
||||||
line.children().css("background-color", 'white');
|
line.children().css("background-color", 'white');
|
||||||
id = line.children().last().html();
|
id = line.children().last().html();
|
||||||
user_id = line.children().eq(6).html();
|
user_id = line.children().eq(5).html();
|
||||||
if(user_id === '<%= User.current.id%>') {
|
if(user_id === '<%= User.current.id%>') {
|
||||||
if(line.children().first().children().data('hasHistory') == 'Y'){
|
if(line.children().first().children().data('hasHistory') == 'Y'){
|
||||||
alert('该资源存在历史版本,不能删除');
|
alert('该资源存在历史版本,不能删除');
|
||||||
|
@ -228,7 +193,7 @@
|
||||||
if (confirm('确定要删除资源"' + line.children().eq(1).children().attr('title').trim() + '"么?')) {
|
if (confirm('确定要删除资源"' + line.children().eq(1).children().attr('title').trim() + '"么?')) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'post',
|
type: 'post',
|
||||||
url: '<%= user_resource_delete_user_path(User.current.id)%>' + '?resource_id=' + id + '&type=<%=@type %>&status=<%=@status %>'
|
url: '<%= user_resource_delete_user_path(User.current.id) %>' + '?resource_id=' + id + '&type=<%= @type %>&status=<%= @status %>'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,22 +6,10 @@
|
||||||
<ul class="subjectRow">
|
<ul class="subjectRow">
|
||||||
<li class="subjectName fl hidden">
|
<li class="subjectName fl hidden">
|
||||||
<label>
|
<label>
|
||||||
<% if private_attachment_allow(attach.id) && (@type == "6" || @type == "2") %>
|
|
||||||
<input name="checkbox1[]" type="checkbox" disabled="disabled" data-has-history="<%= attach.attachment_histories.count == 0 ? 'N' : 'Y' %>" data-deleteble="<%= User.current.id ==attach.author_id ? 'Y' : 'N' %>" onclick="checkAllBox($(this));" value="<%= attach.id%>" class="mr5" style="vertical-align:middle;" />
|
|
||||||
<% else %>
|
|
||||||
<input name="checkbox1[]" type="checkbox" data-has-history="<%= attach.attachment_histories.count == 0 ? 'N' : 'Y' %>" data-deleteble="<%= User.current.id ==attach.author_id ? 'Y' : 'N' %>" onclick="checkAllBox($(this));" value="<%= attach.id%>" class="mr5" style="vertical-align:middle;" />
|
<input name="checkbox1[]" type="checkbox" data-has-history="<%= attach.attachment_histories.count == 0 ? 'N' : 'Y' %>" data-deleteble="<%= User.current.id ==attach.author_id ? 'Y' : 'N' %>" onclick="checkAllBox($(this));" value="<%= attach.id%>" class="mr5" style="vertical-align:middle;" />
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<span>
|
<span>
|
||||||
<% if private_attachment_allow(attach.id) %>
|
|
||||||
<a style="cursor: default" title="<%= attach.filename %>"><%= attach.filename %> </a>
|
|
||||||
<% else %>
|
|
||||||
<%= link_to truncate(attach.filename, :length => 30), download_named_attachment_path(attach.id, attach.filename), :title => attach.filename%>
|
<%= link_to truncate(attach.filename, :length => 30), download_named_attachment_path(attach.id, attach.filename), :title => attach.filename%>
|
||||||
<% end %>
|
|
||||||
</span>
|
</span>
|
||||||
<% if private_attachment_allow(attach.id) && (@type == "6" || @type == "2") %>
|
|
||||||
<img src="/images/locked.png" alt="私有" title="私有" class="resource-list-middle" height="16" width="16">
|
|
||||||
<% end %>
|
|
||||||
</label>
|
</label>
|
||||||
</li>
|
</li>
|
||||||
<li class="subjectType fl"><%= get_resource_type(attach.container_type)%></li>
|
<li class="subjectType fl"><%= get_resource_type(attach.container_type)%></li>
|
||||||
|
|
|
@ -19,13 +19,13 @@
|
||||||
<div class="resource-check-all">
|
<div class="resource-check-all">
|
||||||
<input id="checkboxAll" type="checkbox" value="" onclick="all_select();" class="resourcesCheckbox" />
|
<input id="checkboxAll" type="checkbox" value="" onclick="all_select();" class="resourcesCheckbox" />
|
||||||
</div>
|
</div>
|
||||||
<!--<a href="javascript:void(0);" class="replyGrey mr15" onclick="all_select();">全选</a> -->
|
<a href="javascript:void(0);" class="replyGrey mr15" onclick="all_select();">全选</a>
|
||||||
<a href="javascript:void(0);" class="replyGrey" onclick="batch_delete();">删除</a> </div>
|
<a href="javascript:void(0);" class="replyGrey" onclick="batch_delete();">删除</a> </div>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<div class="resourcesSelectSend mt10 fl">
|
<div class="resourcesSelectSend mt10 fl">
|
||||||
<!--<div class="resourcesSelectSendButton fl mr15 inactive-border" onclick="batch_send();">-->
|
<div class="resourcesSelectSendButton fl mr15 inactive-border" onclick="batch_send();">
|
||||||
<!--<!–<a href="javascript:void(0);" class="sendButtonBlue db inactive-text" data-remote="true">发送至</a>–>-->
|
<a href="javascript:void(0);" class="sendButtonBlue db inactive-text" data-remote="true">发送至</a>
|
||||||
<!--</div>-->
|
</div>
|
||||||
<div class="fl">选择 <span class="c_red" id="res_count">0</span> 个资源</div>
|
<div class="fl">选择 <span class="c_red" id="res_count">0</span> 个资源</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@
|
||||||
document.oncontextmenu = function() {return true;}
|
document.oncontextmenu = function() {return true;}
|
||||||
line.children().css("background-color",'white');
|
line.children().css("background-color",'white');
|
||||||
id = line.children().last().html();
|
id = line.children().last().html();
|
||||||
user_id = line.children().eq(6).html();
|
user_id = line.children().eq(5).html();
|
||||||
if(user_id === '<%= User.current.id %>') {
|
if(user_id === '<%= User.current.id %>') {
|
||||||
res_name = line.children().eq(1).children().attr('title');
|
res_name = line.children().eq(1).children().attr('title');
|
||||||
res_link = line.children().eq(1).html();
|
res_link = line.children().eq(1).html();
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<ul class="resource-list-tab mt10" id="resource_tip_list">
|
<ul class="resource-list-tab mt10" id="resource_tip_list">
|
||||||
<li class="resource-list-checkbox fl"> </li>
|
<li class="resource-list-checkbox fl"> </li>
|
||||||
<li class="resource-list-name fl">资源名称</li>
|
<li class="resource-list-name fl">资源名称</li>
|
||||||
<li class="resource-list-apply fr">操作</li>
|
<!--<li class="resource-list-apply fr">操作</li>-->
|
||||||
<li class="resource-list-time fr">
|
<li class="resource-list-time fr">
|
||||||
<%= link_to "上传时间", resource_search_user_path(:type => @type, :status => @status, :sort => @score, :order => "created_on", :search => " "), :class => "fl", :remote => true %>
|
<%= link_to "上传时间", resource_search_user_path(:type => @type, :status => @status, :sort => @score, :order => "created_on", :search => " "), :class => "fl", :remote => true %>
|
||||||
<% if @order == "created_on" %>
|
<% if @order == "created_on" %>
|
||||||
|
|
|
@ -55,9 +55,9 @@
|
||||||
<li class="fl resource-switch">
|
<li class="fl resource-switch">
|
||||||
<a href="<%= user_resource_user_path(@user, :type => '1', :status => 6) %>" class="resource-tab" id="my_resource_list" data-remote="true">我的资源</a>
|
<a href="<%= user_resource_user_path(@user, :type => '1', :status => 6) %>" class="resource-tab" id="my_resource_list" data-remote="true">我的资源</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="fl resource-switch">
|
<!--<li class="fl resource-switch">-->
|
||||||
<a href="<%= user_resource_user_path(@user, :type => '2', :status => 6) %>" class="resource-tab" id="private_resource_list" data-remote="true">申请资源</a>
|
<!--<a href="<%#= user_resource_user_path(@user, :type => '2', :status => 6) %>" class="resource-tab" id="private_resource_list" data-remote="true">申请资源</a>-->
|
||||||
</li>
|
<!--</li>-->
|
||||||
<li class="fl w680 border-bottom h34"> </li>
|
<li class="fl w680 border-bottom h34"> </li>
|
||||||
<li class="fr resource-banner-li border-bottom h34">
|
<li class="fr resource-banner-li border-bottom h34">
|
||||||
<div id="user_resource_type_filter">
|
<div id="user_resource_type_filter">
|
||||||
|
|
Loading…
Reference in New Issue