From 2589179fcac39875f9a7085586359a362f2cb469 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 21 Aug 2015 16:57:44 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E7=99=BB?= =?UTF-8?q?=E9=99=86=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/base_users_new.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/base_users_new.html.erb b/app/views/layouts/base_users_new.html.erb index e9b7ddb12..e4fe188d2 100644 --- a/app/views/layouts/base_users_new.html.erb +++ b/app/views/layouts/base_users_new.html.erb @@ -149,7 +149,7 @@ From 033aea28c57b71037d91ca1bf27abc7abdf0bc16 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 21 Aug 2015 17:05:54 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=96=B0=E6=88=90=E5=91=98=E6=B3=A8?= =?UTF-8?q?=E5=86=8C=E7=9A=84=E6=97=B6=E5=80=99=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 3c163fada..9e5886f3d 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1374,21 +1374,21 @@ class UsersController < ApplicationController if User.current.id.to_i == params[:id].to_i user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 @attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ - "or (container_type = 'Course' and container_id in (#{user_course_ids.join(',')}))").order("created_on desc") + "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc") else user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #Ta的资源库的话,应该是他上传的公开资源 加上 他加入的所有我可见课程里的公开资源 @attachments = Attachment.where("(author_id = #{params[:id]} and is_public = 1 " + "and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) " + - "or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.join(',')}))").order("created_on desc") + "or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc") end elsif params[:type] == "2" #课程资源 if User.current.id.to_i == params[:id].to_i user_course_ids = User.current.courses.map { |c| c.id} - @attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.join(',')})) ").order("created_on desc") + @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(',')})) ").order("created_on desc") else user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中 @attachments = Attachment.where("(author_id = #{params[:id]} and is_public = 1 and container_type = 'Course')"+ - "or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.join(',')}))").order("created_on desc") + "or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc") end elsif params[:type] == "3" #项目资源 if User.current.id.to_i == params[:id].to_i @@ -1424,22 +1424,22 @@ class UsersController < ApplicationController if User.current.id.to_i == params[:id].to_i user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 取交集并查询 @attachments = Attachment.where("((author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ - " or (container_type = 'Course' and container_id in (#{user_course_ids.join(',')}))) and (filename like '%#{search}%') ").order("created_on desc") + " 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") else user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中 @attachments = Attachment.where("((author_id = #{params[:id]} and is_public = 1 and container_type in" + " ('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon'))"+ - " or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.join(',')})) )" + + " or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) )" + " and (filename like '%#{search}%') ").order("created_on desc") end elsif params[:type] == "2" #课程资源 if User.current.id.to_i == params[:id].to_i user_course_ids = User.current.courses.map { |c| c.id} - @attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.join(',')})) ").order("created_on desc") + @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(',')})) ").order("created_on desc") else user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中 @attachments = Attachment.where("((author_id = #{params[:id]} and is_public = 1 and container_type = 'Course') "+ - "or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.join(',')})) )"+ + "or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) )"+ " and (filename like '%#{search}%') ").order("created_on desc") end elsif params[:type] == "3" #项目资源