Patch #24623 » atta.4.0.patch
| app/controllers/issues_controller.rb | ||
|---|---|---|
|
raise ::Unauthorized
|
||
|
end
|
||
|
call_hook(:controller_issues_new_before_save, { :params => params, :issue => @issue })
|
||
|
@issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads]))
|
||
|
@issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads])) if User.current.allowed_to?(:edit_attachments, @issue.project)
|
||
|
if @issue.save
|
||
|
call_hook(:controller_issues_new_after_save, { :params => params, :issue => @issue})
|
||
|
respond_to do |format|
|
||
| ... | ... | |
|
@issue.safe_attributes = attrs
|
||
|
if @issue.project
|
||
|
@issue.attachments = [] unless User.current.allowed_to?(:edit_attachments, @issue.project)
|
||
|
@issue.tracker ||= @issue.allowed_target_trackers.first
|
||
|
if @issue.tracker.nil?
|
||
|
if @issue.project.trackers.any?
|
||
| app/models/issue.rb | ||
|---|---|---|
|
has_many :relations_from, :class_name => 'IssueRelation', :foreign_key => 'issue_from_id', :dependent => :delete_all
|
||
|
has_many :relations_to, :class_name => 'IssueRelation', :foreign_key => 'issue_to_id', :dependent => :delete_all
|
||
|
acts_as_attachable :after_add => :attachment_added, :after_remove => :attachment_removed
|
||
|
acts_as_attachable :after_add => :attachment_added, :after_remove => :attachment_removed,
|
||
|
:view_permission => :view_attachments, :edit_permission => :edit_attachments, :delete_permission => :delete_attachments
|
||
|
acts_as_customizable
|
||
|
acts_as_watchable
|
||
|
acts_as_searchable :columns => ['subject', "#{table_name}.description"],
|
||
| ... | ... | |
|
self.status = issue.status
|
||
|
end
|
||
|
self.author = User.current
|
||
|
unless options[:attachments] == false
|
||
|
if options[:attachments] == true && User.current.allowed_to?(:view_attachments, issue.project)
|
||
|
self.attachments = issue.attachments.map do |attachement|
|
||
|
attachement.copy(:container => self)
|
||
|
end
|
||
| app/models/journal.rb | ||
|---|---|---|
|
detail.custom_field && detail.custom_field.visible_by?(project, user)
|
||
|
elsif detail.property == 'relation'
|
||
|
Issue.find_by_id(detail.value || detail.old_value).try(:visible?, user)
|
||
|
elsif detail.property == 'attachment'
|
||
|
user.allowed_to?(:view_attachments, project)
|
||
|
else
|
||
|
true
|
||
|
end
|
||
| app/models/mailer.rb | ||
|---|---|---|
|
end
|
||
|
# Builds a mail for notifying user about an issue update
|
||
|
def issue_edit(user, journal)
|
||
|
def issue_edit(user, journal, att=false)
|
||
|
issue = journal.journalized
|
||
|
redmine_headers 'Project' => issue.project.identifier,
|
||
|
'Issue-Id' => issue.id,
|
||
| ... | ... | |
|
@journal = journal
|
||
|
@journal_details = journal.visible_details
|
||
|
@issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue, :anchor => "change-#{journal.id}")
|
||
|
@att = att
|
||
|
mail :to => user,
|
||
|
:subject => s
|
||
| ... | ... | |
|
# Example:
|
||
|
# Mailer.deliver_issue_edit(journal)
|
||
|
def self.deliver_issue_edit(journal)
|
||
|
issue = journal.journalized.reload
|
||
|
users = journal.notified_users | journal.notified_watchers
|
||
|
users.select! do |user|
|
||
|
journal.notes? || journal.visible_details(user).any?
|
||
|
end
|
||
|
users.each do |user|
|
||
|
issue_edit(user, journal).deliver_later
|
||
|
issue_edit(user, journal, user.allowed_to?(:view_attachments, issue.project)).deliver_later
|
||
|
end
|
||
|
end
|
||
| app/views/issues/_edit.html.erb | ||
|---|---|---|
|
<%= call_hook(:view_issues_edit_notes_bottom, { :issue => @issue, :notes => @notes, :form => f }) %>
|
||
|
</fieldset>
|
||
|
<% if User.current.allowed_to?(:edit_attachments, @project) %>
|
||
|
<fieldset><legend><%= l(:label_attachment_plural) %></legend>
|
||
|
<% if @issue.attachments.any? && @issue.safe_attribute?('deleted_attachment_ids') %>
|
||
|
<div class="contextual"><%= link_to l(:label_edit_attachments), '#', :onclick => "$('#existing-attachments').toggle(); return false;" %></div>
|
||
| ... | ... | |
|
<%= render :partial => 'attachments/form', :locals => {:container => @issue} %>
|
||
|
</div>
|
||
|
</fieldset>
|
||
|
<% end %>
|
||
|
<% end %>
|
||
|
</div>
|
||
| app/views/issues/new.html.erb | ||
|---|---|---|
|
<%= check_box_tag 'link_copy', '1', @link_copy %>
|
||
|
</p>
|
||
|
<% end %>
|
||
|
<% if @copy_from && @copy_from.attachments.any? %>
|
||
|
<% if @copy_from && @copy_from.attachments.any? && User.current.allowed_to?(:view_attachments, @copy_from.project) %>
|
||
|
<p>
|
||
|
<label for="copy_attachments"><%= l(:label_copy_attachments) %></label>
|
||
|
<%= check_box_tag 'copy_attachments', '1', @copy_attachments %>
|
||
| ... | ... | |
|
</p>
|
||
|
<% end %>
|
||
|
<% if User.current.allowed_to?(:edit_attachments, @project) %>
|
||
|
<p id="attachments_form"><label><%= l(:label_attachment_plural) %></label><%= render :partial => 'attachments/form', :locals => {:container => @issue} %></p>
|
||
|
<% end %>
|
||
|
<div id="watchers_form_container">
|
||
|
<%= render :partial => 'issues/watchers_form' %>
|
||
| app/views/issues/show.api.rsb | ||
|---|---|---|
|
@issue.attachments.each do |attachment|
|
||
|
render_api_attachment(attachment, api)
|
||
|
end
|
||
|
end if include_in_api_response?('attachments')
|
||
|
end if include_in_api_response?('attachments') && User.current.allowed_to?(:view_attachments, @project)
|
||
|
api.array :relations do
|
||
|
@relations.each do |relation|
|
||
| app/views/issues/show.html.erb | ||
|---|---|---|
|
</div>
|
||
|
</div>
|
||
|
<% end %>
|
||
|
<% if @issue.attachments.any? %>
|
||
|
<% if @issue.attachments.any? && (User.current.allowed_to?(:view_attachments, @project)) %>
|
||
|
<hr />
|
||
|
<p><strong><%=l(:label_attachment_plural)%></strong></p>
|
||
|
<%= link_to_attachments @issue, :thumbnails => true %>
|
||
|
<%= link_to_attachments @issue, :thumbnails => true if User.current.allowed_to?(:view_attachments, @project) %>
|
||
|
<% end %>
|
||
|
<%= render_full_width_custom_fields_rows(@issue) %>
|
||
| app/views/mailer/_issue.html.erb | ||
|---|---|---|
|
<%= textilizable(issue, :description, :only_path => false) %>
|
||
|
<% if issue.attachments.any? %>
|
||
|
<% if issue.attachments.any? && @att %>
|
||
|
<fieldset class="attachments"><legend><%= l(:label_attachment_plural) %></legend>
|
||
|
<% issue.attachments.each do |attachment| %>
|
||
|
<%= link_to_attachment attachment, :download => true, :only_path => false %>
|
||
| app/views/mailer/_issue.text.erb | ||
|---|---|---|
|
----------------------------------------
|
||
|
<%= issue.description %>
|
||
|
<% if issue.attachments.any? -%>
|
||
|
<% if issue.attachments.any? && @att -%>
|
||
|
---<%= l(:label_attachment_plural).ljust(37, '-') %>
|
||
|
<% issue.attachments.each do |attachment| -%>
|
||
|
<%= attachment.filename %> (<%= number_to_human_size(attachment.filesize) %>)
|
||
| config/locales/en.yml | ||
|---|---|---|
|
permission_view_private_notes: View private notes
|
||
|
permission_set_notes_private: Set notes as private
|
||
|
permission_delete_issues: Delete issues
|
||
|
permission_view_attachments: View attachments
|
||
|
permission_edit_attachments: Edit attachments
|
||
|
permission_delete_attachments: Delete attachments
|
||
|
permission_manage_public_queries: Manage public queries
|
||
|
permission_save_queries: Save queries
|
||
|
permission_view_gantt: View gantt chart
|
||
| config/locales/pt-BR.yml | ||
|---|---|---|
|
permission_manage_members: Gerenciar membros
|
||
|
permission_edit_messages: Editar mensagens
|
||
|
permission_delete_issues: Excluir tarefas
|
||
|
permission_view_attachments: Ver arquivos anexos
|
||
|
permission_edit_attachments: Editar arquivos anexos
|
||
|
permission_delete_attachments: Apagar arquivos anexos
|
||
|
permission_view_issue_watchers: Ver lista de observadores
|
||
|
permission_manage_repository: Gerenciar repositório
|
||
|
permission_commit_access: Acesso do commit
|
||
| db/migrate/20161215142110_add_attachments_permissions.rb | ||
|---|---|---|
|
class AddAttachmentsPermissions < ActiveRecord::Migration[5.0]
|
||
|
def self.up
|
||
|
Role.all.each do |r|
|
||
|
r.add_permission!(:view_attachments) if r.has_permission?(:view_issues)
|
||
|
r.add_permission!(:edit_attachments) if r.has_permission?(:edit_issues)
|
||
|
r.add_permission!(:delete_attachments) if r.has_permission?(:edit_issues)
|
||
|
end
|
||
|
end
|
||
|
def self.down
|
||
|
Role.all.each do |r|
|
||
|
r.remove_permission!(:view_attachments)
|
||
|
r.remove_permission!(:edit_attachments)
|
||
|
r.remove_permission!(:delete_attachments)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| lib/plugins/acts_as_searchable/lib/acts_as_searchable.rb | ||
|---|---|---|
|
r |= fetch_ranks_and_ids(
|
||
|
search_scope(user, projects, options).
|
||
|
joins(:attachments).
|
||
|
where("#{Project.allowed_to_condition(user, :view_attachments)}", false).
|
||
|
where(search_tokens_condition(["#{Attachment.table_name}.filename", "#{Attachment.table_name}.description"], tokens, options[:all_words])),
|
||
|
options[:limit]
|
||
|
)
|
||
| lib/redmine.rb | ||
|---|---|---|
|
:queries => :index,
|
||
|
:reports => [:issue_report, :issue_report_details]},
|
||
|
:read => true
|
||
|
map.permission :add_issues, {:issues => [:new, :create], :attachments => :upload}
|
||
|
map.permission :edit_issues, {:issues => [:edit, :update, :bulk_edit, :bulk_update], :journals => [:new], :attachments => :upload}
|
||
|
map.permission :copy_issues, {:issues => [:new, :create, :bulk_edit, :bulk_update], :attachments => :upload}
|
||
|
map.permission :add_issues, {:issues => [:new, :create]}
|
||
|
map.permission :edit_issues, {:issues => [:edit, :update, :bulk_edit, :bulk_update], :journals => [:new]}
|
||
|
map.permission :copy_issues, {:issues => [:new, :create, :bulk_edit, :bulk_update]}
|
||
|
map.permission :manage_issue_relations, {:issue_relations => [:index, :show, :create, :destroy]}
|
||
|
map.permission :manage_subtasks, {}
|
||
|
map.permission :set_issues_private, {}
|
||
|
map.permission :set_own_issues_private, {}, :require => :loggedin
|
||
|
map.permission :add_issue_notes, {:issues => [:edit, :update], :journals => [:new], :attachments => :upload}
|
||
|
map.permission :add_issue_notes, {:issues => [:edit, :update], :journals => [:new]}
|
||
|
map.permission :edit_issue_notes, {:journals => [:edit, :update]}, :require => :loggedin
|
||
|
map.permission :edit_own_issue_notes, {:journals => [:edit, :update]}, :require => :loggedin
|
||
|
map.permission :view_private_notes, {}, :read => true, :require => :member
|
||
|
map.permission :set_notes_private, {}, :require => :member
|
||
|
map.permission :delete_issues, {:issues => :destroy}, :require => :member
|
||
|
# Attachments
|
||
|
map.permission :view_attachments, {}, :require => :member
|
||
|
map.permission :edit_attachments, {:attachments => :upload}, :require => :member
|
||
|
map.permission :delete_attachments, {:attachments => :destroy}, :require => :member
|
||
|
# Watchers
|
||
|
map.permission :view_issue_watchers, {}, :read => true
|
||
|
map.permission :add_issue_watchers, {:watchers => [:new, :create, :append, :autocomplete_for_user]}
|
||
| lib/redmine/export/pdf/issues_pdf_helper.rb | ||
|---|---|---|
|
end
|
||
|
end
|
||
|
|
||
|
if issue.attachments.any?
|
||
|
if issue.attachments.any? && User.current.allowed_to?(:view_attachments, @project)
|
||
|
pdf.SetFontStyle('B',9)
|
||
|
pdf.RDMCell(190,5, l(:label_attachment_plural), "B")
|
||
|
pdf.ln
|
||