diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 7542ef3ee..b0194a2d8 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2698,10 +2698,9 @@ class UsersController < ApplicationController 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 - # 获取我的私有资源分享结果 - def get_course_private_resources author_id, user_course_ids, order, score - apply_id = ApplyResource.where("user_id =?", author_id).map{|ar| ar.attachment_id} - attachments = Attachment.where("user_id =? and attachment_id =?") + # 获取我的私有资源分享搜索结果 + 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}") end # 获取我的课程资源中搜索结果 @@ -2830,7 +2829,6 @@ class UsersController < ApplicationController end elsif params[:type] == "2" # 私有资源 apply_ids = ApplyResource.where("user_id =? and status =?", params[:id], 2).map { |ar| ar.attachment_id} - # apply_id = ApplyResource.where("user_id =?", author_id).map{|ar| ar.attachment_id} if params[:status] == "2" resource_type = "'Course'" elsif params[:status] == "3" @@ -2838,7 +2836,6 @@ class UsersController < ApplicationController elsif params[:status] == "5" resource_type = "'Principal'" else - # 公共资源库:所有公开资源或者我上传的私有资源 resource_type = "'Project','OrgSubfield','Principal','Course'" end @attachments = get_my_private_resources(apply_ids, resource_type, @order, @score) @@ -3022,6 +3019,19 @@ class UsersController < ApplicationController # 公共资源库:所有公开资源或者我上传的私有资源 @attachments = get_public_resources_search(user_course_ids, user_project_ids, @order, @score, search) end + elsif params[:type] == "2" # 私有资源 + apply_ids = ApplyResource.where("user_id =? and status =?", params[:id], 2).map { |ar| ar.attachment_id} + if params[:status] == "2" + resource_type = "'Course'" + elsif params[:status] == "3" + resource_type = "'Project'" + elsif params[:status] == "5" + resource_type = "'Principal'" + else + resource_type = "'Project','OrgSubfield','Principal','Course'" + end + @attachments = get_my_private_resources_search(apply_ids, resource_type, @order, @score, search) + @attachments end @status = params[:status] @type = params[:type] diff --git a/app/views/users/_resources_list.html.erb b/app/views/users/_resources_list.html.erb index 18d20cd60..63ef92667 100644 --- a/app/views/users/_resources_list.html.erb +++ b/app/views/users/_resources_list.html.erb @@ -11,7 +11,7 @@
  • <%= 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' %> - <% if attach.is_public == 0 && @type == "6" && attach.author != User.current %> + <% if attach.is_public == 0 && (@type == "6" || @type == "2") && attach.author != User.current %> 私有 <% end %>