diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index b28fda55b..5c3503718 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -366,7 +366,7 @@ class AttachmentsController < ApplicationController end rescue NoMethodError @save_flag = false - @save_message = [] << l(:error_attachment_empty) + @save_message = [] << l(:label_course_empty_select) respond_to do |format| format.js end diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 6de800efc..251496e30 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -26,13 +26,15 @@ class FilesController < ApplicationController helper :sort include SortHelper + include FilesHelper helper :project_score def show_attachments obj - @all_attachments = [] + @attachments = [] obj.each do |container| - @all_attachments += container.attachments + @attachments += container.attachments end + @all_attachments = visable_attachemnts(@attachments) @limit = 10 @feedback_count = @all_attachments.count @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] @@ -48,9 +50,11 @@ class FilesController < ApplicationController #(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank? if params[:insite] @result = find_public_attache q + @result = visable_attachemnts @result @searched_attach = paginateHelper @result,10 else @result = find_course_attache q,@course + @result = visable_attachemnts @result @searched_attach = paginateHelper @result,10 end @@ -69,7 +73,7 @@ class FilesController < ApplicationController # StoresController#search 将每条文件都查出来,再次进行判断过滤。---> resultSet.to_a.map # 此时内容不多速度还可,但文件增长,每条判断多则进行3-4次表连接。 # 现在还木有思路 药丸 - resultSet = Attachment.where("attachments.container_type IS NOT NULL AND (is_public = 1 OR author_id = #{User.current.id}) AND filename LIKE :like ", like: "%#{keywords}%"). + resultSet = Attachment.where("attachments.container_type IS NOT NULL AND filename LIKE :like ", like: "%#{keywords}%"). reorder("created_on DESC") end diff --git a/app/helpers/files_helper.rb b/app/helpers/files_helper.rb index f1f4f06f4..cd7603c65 100644 --- a/app/helpers/files_helper.rb +++ b/app/helpers/files_helper.rb @@ -72,6 +72,16 @@ module FilesHelper result end + def visable_attachemnts attachments + result = [] + attachments.each do |attachment| + if attachment.is_public? || attachment.author_id == User.current.id + result << attachment + end + end + result + end + def get_qute_number attachment if attachment.copy_from.nil? return 0 diff --git a/app/views/files/_course_list.html.erb b/app/views/files/_course_list.html.erb index 51091caae..b8d0ad098 100644 --- a/app/views/files/_course_list.html.erb +++ b/app/views/files/_course_list.html.erb @@ -1,6 +1,6 @@ <% delete_allowed = User.current.allowed_to?(:manage_files, course) %>
共有 <%= User.current.member_of_course?(course) ? all_attachments.count : 0 %> 个资源
+共有 <%= all_attachments.count%> 个资源
<% end %> - + <% else %> + <%= link_to "选入我的课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true %> + <% end %> <% else %> - <%= link_to (file.is_public? ? "公开":"私有"),"javascript:void(0)",:class=>"f_l re_open" %> <% end %>
文件大小:<%= number_to_human_size(file.filesize) %>
<%= link_to( l(:button_delete), attachment_path(file), :data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "f_r re_de") if delete_allowed && file.container_id == @course.id && file.container_type == "Course"%> -<%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %> | 下载<%= file.downloads %> | 引用<%=get_qute_number file %>
+<%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %> | 下载<%= file.downloads %>