Feature #16561 » add-private-files.diff
app/controllers/files_controller.rb | ||
---|---|---|
42 | 42 | |
43 | 43 |
def create |
44 | 44 |
container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id])) |
45 |
attachments = Attachment.attach_files(container, params[:attachments]) |
|
45 | ||
46 |
attachments_params = params[:attachments] |
|
47 |
attachments_params.each{|_,v| v.merge!('private' => true)} if params[:private].to_i == 1 |
|
48 | ||
49 |
attachments = Attachment.attach_files(container, attachments_params) |
|
46 | 50 |
render_attachment_warning_if_needed(container) |
47 | 51 | |
48 | 52 |
if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added') |
app/views/attachments/_form.html.erb | ||
---|---|---|
24 | 24 |
:description_placeholder => l(:label_optional_description) |
25 | 25 |
} %> |
26 | 26 |
(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) |
27 | ||
28 |
<% if controller_name == 'files' && User.current.allowed_to?(:manage_private_files, @project) %> |
|
29 |
<br /> |
|
30 |
<%= label_tag :private %> |
|
31 |
<%= check_box_tag :private %> |
|
32 |
<% end %> |
|
27 | 33 |
</span> |
28 | 34 | |
29 | 35 |
<% content_for :header_tags do %> |
app/views/files/index.html.erb | ||
---|---|---|
13 | 13 |
<%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc') %> |
14 | 14 |
<%= sort_header_tag('downloads', :caption => l(:label_downloads_abbr), :default_order => 'desc') %> |
15 | 15 |
<th>MD5</th> |
16 |
<th><%= l(:field_type) %></th> |
|
16 | 17 |
<th></th> |
17 | 18 |
</tr></thead> |
18 | 19 |
<tbody> |
... | ... | |
26 | 27 |
</tr> |
27 | 28 |
<% end -%> |
28 | 29 |
<% container.attachments.each do |file| %> |
29 |
<tr class="file <%= cycle("odd", "even") %>"> |
|
30 |
<td class="filename"><%= link_to_attachment file, :download => true, :title => file.description %></td> |
|
31 |
<td class="created_on"><%= format_time(file.created_on) %></td> |
|
32 |
<td class="filesize"><%= number_to_human_size(file.filesize) %></td> |
|
33 |
<td class="downloads"><%= file.downloads %></td> |
|
34 |
<td class="digest"><%= file.digest %></td> |
|
35 |
<td class="buttons"> |
|
36 |
<%= link_to(image_tag('delete.png'), attachment_path(file), |
|
37 |
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %> |
|
38 |
</td> |
|
39 |
</tr> |
|
30 |
<% next if file.is_private && !User.current.allowed_to?(:view_private_files, @project) %> |
|
31 |
<tr class="file <%= cycle("odd", "even") %>"> |
|
32 |
<td class="filename"><%= link_to_attachment file, :download => true, :title => file.description %></td> |
|
33 |
<td class="created_on"><%= format_time(file.created_on) %></td> |
|
34 |
<td class="filesize"><%= number_to_human_size(file.filesize) %></td> |
|
35 |
<td class="downloads"><%= file.downloads %></td> |
|
36 |
<td class="digest"><%= file.digest %></td> |
|
37 |
<td><%= file.is_private ? l('field_is_private') : l('field_is_public') %></td> |
|
38 |
<td class="buttons"> |
|
39 |
<%= link_to(image_tag('delete.png'), attachment_path(file), |
|
40 |
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %> |
|
41 |
</td> |
|
42 |
</tr> |
|
40 | 43 |
<% end |
41 | 44 |
reset_cycle %> |
42 | 45 |
<% end %> |
config/locales/en.yml | ||
---|---|---|
449 | 449 |
permission_edit_documents: Edit documents |
450 | 450 |
permission_delete_documents: Delete documents |
451 | 451 |
permission_manage_files: Manage files |
452 |
permission_manage_private_files: Manage private files |
|
452 | 453 |
permission_view_files: View files |
454 |
permission_view_private_files: View private files |
|
453 | 455 |
permission_manage_wiki: Manage wiki |
454 | 456 |
permission_rename_wiki_pages: Rename wiki pages |
455 | 457 |
permission_delete_wiki_pages: Delete wiki pages |
config/locales/pl.yml | ||
---|---|---|
695 | 695 |
permission_manage_boards: Zarządzanie forami |
696 | 696 |
permission_manage_categories: Zarządzanie kategoriami zagadnień |
697 | 697 |
permission_manage_files: Zarządzanie plikami |
698 |
permission_manage_private_files: Zarządzanie plikami prywatnymi |
|
698 | 699 |
permission_manage_issue_relations: Zarządzanie powiązaniami zagadnień |
699 | 700 |
permission_manage_members: Zarządzanie uczestnikami |
700 | 701 |
permission_manage_news: Zarządzanie komunikatami |
... | ... | |
711 | 712 |
permission_view_changesets: Podgląd zmian |
712 | 713 |
permission_view_documents: Podgląd dokumentów |
713 | 714 |
permission_view_files: Podgląd plików |
715 |
permission_view_private_files: Podgląd plików prywatnych |
|
714 | 716 |
permission_view_gantt: Podgląd diagramu Gantta |
715 | 717 |
permission_view_issue_watchers: Podgląd listy obserwatorów |
716 | 718 |
permission_view_messages: Podgląd wiadomości |
... | ... | |
971 | 973 |
field_issues_visibility: Issues visibility |
972 | 974 |
label_issues_visibility_all: All issues |
973 | 975 |
permission_set_own_issues_private: Set own issues public or private |
974 |
field_is_private: Private
|
|
976 |
field_is_private: Prywatny
|
|
975 | 977 |
permission_set_issues_private: Set issues public or private |
976 | 978 |
label_issues_visibility_public: All non private issues |
977 | 979 |
text_issues_destroy_descendants_confirmation: This will also delete %{count} subtask(s). |
lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb | ||
---|---|---|
79 | 79 |
if attachments.is_a?(Array) |
80 | 80 |
attachments.each do |attachment| |
81 | 81 |
next unless attachment.is_a?(Hash) |
82 |
a = nil |
|
83 | 82 |
if file = attachment['file'] |
84 | 83 |
next unless file.size > 0 |
85 |
a = Attachment.create(:file => file, :author => author) |
|
84 |
Attachment.create do |a| |
|
85 |
a.file = file |
|
86 |
a.author = author |
|
87 |
a.is_private = true if attachment['private'] == true |
|
88 |
end |
|
86 | 89 |
elsif token = attachment['token'] |
87 | 90 |
a = Attachment.find_by_token(token) |
88 | 91 |
next unless a |
89 | 92 |
a.filename = attachment['filename'] unless attachment['filename'].blank? |
90 | 93 |
a.content_type = attachment['content_type'] |
94 |
a.is_private = true if attachment['private'] == true |
|
91 | 95 |
end |
92 | 96 |
next unless a |
93 | 97 |
a.description = attachment['description'].to_s.strip |
lib/redmine.rb | ||
---|---|---|
155 | 155 |
map.project_module :files do |map| |
156 | 156 |
map.permission :manage_files, {:files => [:new, :create], :attachments => :upload}, :require => :loggedin |
157 | 157 |
map.permission :view_files, {:files => :index, :versions => :download}, :read => true |
158 |
map.permission :manage_private_files, {:files => [:new, :create], :attachments => :upload}, :public => false, :require => :member |
|
159 |
map.permission :view_private_files, {:files => [:index, :versions => :download]}, :public => false, :require => :member, :read => true |
|
158 | 160 |
end |
159 | 161 | |
160 | 162 |
map.project_module :wiki do |map| |
- « Previous
- 1
- 2
- Next »