diff --git a/app/models/attachment.rb b/app/models/attachment.rb index f7fb9b1aa..0f728fc00 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -442,7 +442,12 @@ class Attachment < ActiveRecord::Base def self.attach_filesex(obj, attachments,attachment_type) - result = obj.save_attachmentsex(attachments, User.current,attachment_type) + if obj.is_public? + public_status = true + else + public_status = false + end + result = obj.save_attachmentsex(attachments, User.current,attachment_type, public_status) obj.attach_saved_attachments result end diff --git a/app/views/files/_course_list.html.erb b/app/views/files/_course_list.html.erb index 9e88cb2fd..3c6d545db 100644 --- a/app/views/files/_course_list.html.erb +++ b/app/views/files/_course_list.html.erb @@ -33,9 +33,16 @@ <%= link_to("选入我的其他课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select c_lorange",:remote => true) if has_course?(User.current,file) %> <% if delete_allowed && file.container_id == @course.id && file.container_type == "Course" %> - - <%= 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 c_blue",:method => :post %> - + <% if @course.is_public? %> + + <%= 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 c_blue",:method => :post %> + + <% else %> + + 私有 + + <% end %> + <% else %> <% end %> diff --git a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb index 377f2b112..9378013f9 100644 --- a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb +++ b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb @@ -93,13 +93,13 @@ module Redmine end end - def save_attachmentsex(attachments, author=User.current,attachment_type) + def save_attachmentsex(attachments, author=User.current,attachment_type, public_status) @curattachment_type = attachment_type - result = save_attachments(attachments,author) + result = save_attachments(attachments,author, public_status) result end - def save_attachments(attachments, author=User.current) + def save_attachments(attachments, author=User.current,public_status) # 清除临时文件 if attachments tempAttach = attachments[:dummy] @@ -140,11 +140,16 @@ module Redmine end end end - if a && !attachment['is_public_checkbox'] + if public_status + if a && !attachment['is_public_checkbox'] + a.is_public = false + elsif a && attachment['is_public_checkbox'] + a.is_public = true + end + else a.is_public = false - elsif a && attachment['is_public_checkbox'] - a.is_public = true end + set_attachment_public(a) if a next unless a a.description = attachment['description'].to_s.strip