diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index ca7f8e040..6de800efc 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -69,7 +69,7 @@ class FilesController < ApplicationController # StoresController#search 将每条文件都查出来,再次进行判断过滤。---> resultSet.to_a.map # 此时内容不多速度还可,但文件增长,每条判断多则进行3-4次表连接。 # 现在还木有思路 药丸 - resultSet = Attachment.where("attachments.container_type IS NOT NULL AND filename LIKE :like ", like: "%#{keywords}%"). + 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}%"). reorder("created_on DESC") end diff --git a/app/views/files/_course_list.html.erb b/app/views/files/_course_list.html.erb index 554a3aea5..df0e837f2 100644 --- a/app/views/files/_course_list.html.erb +++ b/app/views/files/_course_list.html.erb @@ -21,12 +21,13 @@
<%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %> - <% if is_course_teacher(User.current,@course) %> + <% if is_course_teacher(User.current,@course) && User.current.id == file.author_id %> <%= link_to "选入我的课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true %> <%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open",:method => :post %> <% else %> + <%= link_to "选入我的课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true %> <%= link_to (file.is_public? ? "公开":"私有"),"javascript:void(0)",:class=>"f_l re_open" %> <% end %>
diff --git a/db/migrate/20141120091234_add_column_copyfrom_to_attachment.rb b/db/migrate/20141120091234_add_column_copyfrom_to_attachment.rb new file mode 100644 index 000000000..cc8444f6d --- /dev/null +++ b/db/migrate/20141120091234_add_column_copyfrom_to_attachment.rb @@ -0,0 +1,5 @@ +class AddColumnCopyfromToAttachment < ActiveRecord::Migration + def change + add_column("attachments","copy_from",:integer) + end +end