@ -45,16 +45,28 @@ class FilesController < ApplicationController
end
defsearch
sort=""
@sort=""
@order=""
@is_remote=true
ifparams[:sort]
order_by=params[:sort].split(":")
@sort=order_by[0]
iforder_by.count>1
@order=order_by[1]
end
sort="#{@sort}#{@order}"
end
begin
@is_remote=true
q="%#{params[:name].strip}%"
#(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
ifparams[:insite]
@result=find_public_attacheq
@result=visable_attachemnts@result
@result=find_public_attacheq,sort
@result=visable_attachemnts_insite@result,@course
@searched_attach=paginateHelper@result,10
else
@result=find_course_attacheq,@course
@result=find_course_attacheq,@course,sort
@result=visable_attachemnts@result
@searched_attach=paginateHelper@result,10
end
@ -65,17 +77,24 @@ class FilesController < ApplicationController
end
end
deffind_course_attachekeywords,course
deffind_course_attachekeywords,course,sort=""
ifsort==""
sort="created_on DESC"
end
resultSet=Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' AND filename LIKE :like ",like:"%#{keywords}%").
reorder("created_on DESC")
reorder(sort)
#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")