From 09c462ebad05354c83ecbce9a1cd18b6b0a61c35 Mon Sep 17 00:00:00 2001 From: huang Date: Sun, 15 May 2016 08:50:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=84=E6=BA=90=E4=BB=A3=E7=A0=81=E8=BF=98?= =?UTF-8?q?=E5=8E=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index a81ade3fa..dd1d8f876 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2618,9 +2618,6 @@ class UsersController < ApplicationController # 获取我的资源 def get_my_resources author_id, user_course_ids, user_project_ids, order, score - unless author_id.to_i.to_s == author_id - author_id = User.find_by_login(author_id).id - end attachments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('OrgSubfield','Principal','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)" ).order("#{order.nil? ? 'created_on' : order} #{score}") @@ -2628,7 +2625,6 @@ class UsersController < ApplicationController # 获取我的资源查询结果 def get_my_resources_search (author_id, user_course_ids, user_project_ids, order, score, search) - author_id = User.find_by_login(author_id).id @attachments = Attachment.where("((author_id = #{author_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("#{order.nil? ? 'created_on' : order} #{score}") @@ -2636,7 +2632,6 @@ class UsersController < ApplicationController # 获取我的课程资源 def get_course_resources author_id, user_course_ids, order, score - author_id = User.find_by_login(author_id).id attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Course')"+ "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)" ).order("#{order.nil? ? 'created_on' : order} #{score}") @@ -2644,7 +2639,6 @@ class UsersController < ApplicationController # 获取我的课程资源中搜索结果 def get_course_resources_search author_id, user_course_ids, order, score, search - author_id = User.find_by_login(author_id).id attchments = Attachment.where("((author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Course')"+ "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)) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}") @@ -2662,7 +2656,6 @@ class UsersController < ApplicationController # 获取我的项目资源 def get_project_resources author_id, user_project_ids, order, score - author_id = User.find_by_login(author_id).id attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Project') "+ "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)").order("#{order.nil? ? 'created_on' : order} #{score}") @@ -2670,7 +2663,6 @@ class UsersController < ApplicationController # 获取我的项目资源搜索 def get_project_resources_search author_id, user_project_ids, order, score, search - author_id = User.find_by_login(author_id).id attchments = Attachment.where("((author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Project') "+ "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("#{order.nil? ? 'created_on' : order} #{score}") @@ -2688,14 +2680,12 @@ class UsersController < ApplicationController # 获取我上传的附件 def get_attch_resources author_id, order, score - author_id = User.find_by_login(author_id).id attchments = Attachment.where("(author_id = #{author_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'))").order("#{order.nil? ? 'created_on' : order} #{score}") end # 获取我上传的附件搜索结果 def get_attch_resources_search author_id, order, score, search - author_id = User.find_by_login(author_id).id attchments = Attachment.where("(author_id = #{author_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')) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}") end @@ -2714,13 +2704,11 @@ class UsersController < ApplicationController # 获取我的用户类型资源 def get_principal_resources author_id, order, score - author_id = User.find_by_login(author_id).id attchments = Attachment.where("author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Principal'").order("#{order.nil? ? 'created_on' : order} #{score}") end # 获取我的用户类型资源搜索 def get_principal_resources_search author_id, order, score, search - author_id = User.find_by_login(author_id).id attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Principal') and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}") end