Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
This commit is contained in:
commit
aa7c058fc7
|
@ -51,7 +51,7 @@ class FilesController < ApplicationController
|
||||||
#(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
|
#(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
|
||||||
if params[:insite]
|
if params[:insite]
|
||||||
@result = find_public_attache q
|
@result = find_public_attache q
|
||||||
@result = visable_attachemnts @result
|
@result = visable_attachemnts_insite @result,@course
|
||||||
@searched_attach = paginateHelper @result,10
|
@searched_attach = paginateHelper @result,10
|
||||||
else
|
else
|
||||||
@result = find_course_attache q,@course
|
@result = find_course_attache q,@course
|
||||||
|
@ -66,8 +66,9 @@ class FilesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_course_attache keywords,course
|
def find_course_attache keywords,course
|
||||||
resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' AND filename LIKE :like ", like: "%#{keywords}%").
|
resultSet = Attachment.where("(attachments.container_type = 'Course'And attachments.container_id = '#{course.id}') OR (attachments.container_type = 'HomeworkAttach' AND ) AND filename LIKE :like ", like: "%#{keywords}%").
|
||||||
reorder("created_on DESC")
|
reorder("created_on DESC")
|
||||||
|
#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
|
end
|
||||||
|
|
||||||
def find_public_attache keywords
|
def find_public_attache keywords
|
||||||
|
|
|
@ -93,6 +93,27 @@ module FilesHelper
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def visable_attachemnts_incourse attachments
|
||||||
|
result = []
|
||||||
|
attachments.each do |attachment|
|
||||||
|
if attachment.is_public? || (attachment.author.member_of_course?(Course.find(attachment.container_id)))|| attachment.author_id == User.current.id
|
||||||
|
result << attachment
|
||||||
|
end
|
||||||
|
end
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
|
def visable_attachemnts_insite attachments,course
|
||||||
|
result = []
|
||||||
|
attachments.each do |attachment|
|
||||||
|
if attachment.is_public? || (attachment.container_type == "Course" && attachment.container_id == course.id && attachment.author.member_of_course?(Course.find(attachment.container_id)))|| attachment.author_id == User.current.id
|
||||||
|
result << attachment
|
||||||
|
end
|
||||||
|
end
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
def get_qute_number attachment
|
def get_qute_number attachment
|
||||||
if attachment.copy_from
|
if attachment.copy_from
|
||||||
result = Attachment.find_by_sql("select count(*) as number from attachments where copy_from = #{attachment.copy_from}")
|
result = Attachment.find_by_sql("select count(*) as number from attachments where copy_from = #{attachment.copy_from}")
|
||||||
|
|
Loading…
Reference in New Issue