@ -134,8 +134,12 @@ class FilesController < ApplicationController
ifsort==""
sort="created_on DESC"
end
ifkeywords!="%%"
resultSet=Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' AND filename LIKE :like ",like:"%#{keywords}%").
reorder(sort)
else
resultSet=Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' ").reorder(sort)
end
#resultSet = Attachment.find_by_sql("SELECT `attachments`.* FROM `attachments` LEFT OUTER JOIN `homework_attaches` ON `attachments`.container_type = 'HomeworkAttach' AND `attachments`.container_id = `homework_attaches`.id LEFT OUTER JOIN `homework_for_courses` ON `homework_attaches`.bid_id = `homework_for_courses`.bid_id LEFT OUTER JOIN `homework_for_courses` AS H_C ON `attachments`.container_type = 'Bid' AND `attachments`.container_id = H_C.bid_id WHERE (`homework_for_courses`.course_id = 117 OR H_C.course_id = 117 OR (`attachments`.container_type = 'Course' AND `attachments`.container_id = 117)) AND `attachments`.filename LIKE '%#{keywords}%'").reorder("created_on DESC")
end
@ -547,7 +551,7 @@ class FilesController < ApplicationController
@message_alls=ForgeMessage.where("forge_message_type =? and user_id =?","AppliedProject",@user).order("created_at desc")
@message_alls=ForgeMessage.where("forge_message_type in ('ProjectInvite', 'AppliedProject') and user_id =?",@user).order("created_at desc")
when'homework'
@message_alls=CourseMessage.where("course_message_type in ('HomeworkCommon','StudentWorksScore','JournalsForMessage') and user_id =?",@user).order("created_at desc")
when'course_message'
@message_alls=CourseMessage.where("course_message_type =? and user_id =?","Message",@user).order("created_at desc")