资源库搜索问题

This commit is contained in:
lizanle 2015-08-19 09:20:39 +08:00
parent 3836cfb40b
commit e7f818deb9
1 changed files with 4 additions and 4 deletions

View File

@ -1146,25 +1146,25 @@ class UsersController < ApplicationController
# @attachments = Attachment.where("author_id = #{params[:id]} and container_type not in ('Version','PhoneAppVersion','StudentWork') and is_public = 1 and (filename like '%#{search}%') ").order("created_on desc")
# end
if(params[:type].nil? || params[:type] == "1") #全部
if User.current.id == params[:id]
if User.current.id.to_i == params[:id].to_i
@attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like '%#{search}%') ").order("created_on desc")
else
@attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like '%#{search}%') ").order("created_on desc")
end
elsif params[:type] == "2" #课程资源
if User.current.id == params[:id]
if User.current.id.to_i == params[:id].to_i
@attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Course' and (filename like '%#{search}%')").order("created_on desc")
else
@attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Course' and (filename like '%#{search}%') ").order("created_on desc")
end
elsif params[:type] == "3" #项目资源
if User.current.id == params[:id]
if User.current.id.to_i == params[:id].to_i
@attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project' and (filename like '%#{search}%')").order("created_on desc")
else
@attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Project' and (filename like '%#{search}%') ").order("created_on desc")
end
elsif params[:type] == "4" #附件
if User.current.id == params[:id]
if User.current.id.to_i == params[:id].to_i
@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")
else
@attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like '%#{search}%')").order("created_on desc")