Patch #24623 » 0015-Implements-permissions-and-restrictions-to-issue-att-fix-4.0.patch
app/controllers/issues_controller.rb | ||
---|---|---|
86 | 86 |
@journals = @issue.visible_journals_with_index |
87 | 87 |
@changesets = @issue.changesets.visible.preload(:repository, :user).to_a |
88 | 88 |
@relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? } |
89 |
@attachments = @issue.attachments_visible?(User.current) ? @issue.attachments : [] |
|
89 | 90 | |
90 | 91 |
if User.current.wants_comments_in_reverse_order? |
91 | 92 |
@journals.reverse! |
... | ... | |
126 | 127 |
raise ::Unauthorized |
127 | 128 |
end |
128 | 129 |
call_hook(:controller_issues_new_before_save, { :params => params, :issue => @issue }) |
129 |
@issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads])) |
|
130 |
if @issue.attachments_addable?(User.current) |
|
131 |
@issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads])) |
|
132 |
end |
|
130 | 133 |
if @issue.save |
131 | 134 |
call_hook(:controller_issues_new_after_save, { :params => params, :issue => @issue}) |
132 | 135 |
respond_to do |format| |
... | ... | |
163 | 166 | |
164 | 167 |
def update |
165 | 168 |
return unless update_issue_from_params |
166 |
@issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads])) |
|
169 |
if @issue.attachments_addable?(User.current) |
|
170 |
@issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads])) |
|
171 |
end |
|
167 | 172 |
saved = false |
168 | 173 |
begin |
169 | 174 |
saved = save_issue_with_child_records |
... | ... | |
264 | 269 |
@versions = target_projects.map {|p| p.shared_versions.open}.reduce(:&) |
265 | 270 |
@categories = target_projects.map {|p| p.issue_categories}.reduce(:&) |
266 | 271 |
if @copy |
267 |
@attachments_present = @issues.detect {|i| i.attachments.any?}.present? |
|
272 |
@attachments_present = @issues.detect {|i| i.attachments.any? && i.attachments_visible?(User.current)}.present?
|
|
268 | 273 |
@subtasks_present = @issues.detect {|i| !i.leaf?}.present? |
269 | 274 |
@watchers_present = User.current.allowed_to?(:add_issue_watchers, @projects) && Watcher.where(:watchable_type => 'Issue', :watchable_id => @issues.map(&:id)).exists? |
270 | 275 |
end |
... | ... | |
327 | 332 |
end |
328 | 333 |
journal = issue.init_journal(User.current, params[:notes]) |
329 | 334 |
issue.safe_attributes = attributes |
335 |
issue.attachments = [] unless issue.attachments_addable?(User.current) if @copy |
|
330 | 336 |
call_hook(:controller_issues_bulk_edit_before_save, { :params => params, :issue => issue }) |
331 | 337 |
if issue.save |
332 | 338 |
saved_issues << issue |
... | ... | |
545 | 551 | |
546 | 552 |
@priorities = IssuePriority.active |
547 | 553 |
@allowed_statuses = @issue.new_statuses_allowed_to(User.current) |
554 |
@issue.attachments = [] unless @issue.attachments_addable?(User.current) |
|
548 | 555 |
end |
549 | 556 | |
550 | 557 |
# Saves @issue and a time_entry from the parameters |
app/models/issue.rb | ||
---|---|---|
38 | 38 |
has_many :relations_from, :class_name => 'IssueRelation', :foreign_key => 'issue_from_id', :dependent => :delete_all |
39 | 39 |
has_many :relations_to, :class_name => 'IssueRelation', :foreign_key => 'issue_to_id', :dependent => :delete_all |
40 | 40 | |
41 |
acts_as_attachable :after_add => :attachment_added, :after_remove => :attachment_removed |
|
41 |
acts_as_attachable :after_add => :attachment_added, :after_remove => :attachment_removed, |
|
42 |
:view_permission => :view_attachments, :edit_permission => :edit_attachments, |
|
43 |
:delete_permission => :delete_attachments |
|
44 | ||
42 | 45 |
acts_as_customizable |
43 | 46 |
acts_as_watchable |
44 | 47 |
acts_as_searchable :columns => ['subject', "#{table_name}.description"], |
... | ... | |
181 | 184 |
user_tracker_permission?(user, :edit_issues) |
182 | 185 |
end |
183 | 186 | |
187 |
# Overrides Redmine::Acts::Attachable::InstanceMethods#attachments_editable? |
|
188 |
def attachments_visible?(user=User.current) |
|
189 |
user_tracker_permission?(user, :view_attachments) |
|
190 |
end |
|
191 | ||
192 |
# Returns true if user or current user is allowed to add the attachment to the issue |
|
193 |
def attachments_addable?(user=User.current) |
|
194 |
user_tracker_permission?(user, :add_attachments) |
|
195 |
end |
|
196 | ||
184 | 197 |
# Overrides Redmine::Acts::Attachable::InstanceMethods#attachments_editable? |
185 | 198 |
def attachments_editable?(user=User.current) |
186 |
attributes_editable?(user) |
|
199 |
user_tracker_permission?(user, :edit_attachments) |
|
200 |
end |
|
201 | ||
202 |
# Overrides Redmine::Acts::Attachable::InstanceMethods#attachments_editable? |
|
203 |
def attachments_deletable?(user=User.current) |
|
204 |
user_tracker_permission?(user, :delete_attachments) |
|
187 | 205 |
end |
188 | 206 | |
189 | 207 |
# Returns true if user or current user is allowed to add notes to the issue |
... | ... | |
273 | 291 |
self.status = issue.status |
274 | 292 |
end |
275 | 293 |
self.author = User.current |
276 |
unless options[:attachments] == false
|
|
294 |
if options[:attachments] == true && issue.attachments_visible?(user=User.current)
|
|
277 | 295 |
self.attachments = issue.attachments.map do |attachement| |
278 | 296 |
attachement.copy(:container => self) |
279 | 297 |
end |
... | ... | |
1632 | 1650 |
copy.parent_issue_id = copied_issue_ids[child.parent_id] |
1633 | 1651 |
copy.fixed_version_id = nil unless child.fixed_version.present? && child.fixed_version.status == 'open' |
1634 | 1652 |
copy.assigned_to = nil unless child.assigned_to_id.present? && child.assigned_to.status == User::STATUS_ACTIVE |
1653 |
copy.attachments = [] unless copy.attachments_addable?(User.current) |
|
1635 | 1654 |
unless copy.save |
1636 | 1655 |
logger.error "Could not copy subtask ##{child.id} while copying ##{@copied_from.id} to ##{id} due to validation errors: #{copy.errors.full_messages.join(', ')}" if logger |
1637 | 1656 |
next |
app/models/journal.rb | ||
---|---|---|
88 | 88 |
detail.custom_field && detail.custom_field.visible_by?(project, user) |
89 | 89 |
elsif detail.property == 'relation' |
90 | 90 |
Issue.find_by_id(detail.value || detail.old_value).try(:visible?, user) |
91 |
elsif detail.property == 'attachment' |
|
92 |
self.issue.attachments_visible?(User.current) |
|
91 | 93 |
else |
92 | 94 |
true |
93 | 95 |
end |
app/models/mailer.rb | ||
---|---|---|
93 | 93 |
end |
94 | 94 | |
95 | 95 |
# Builds a mail for notifying user about an issue update |
96 |
def issue_edit(user, journal) |
|
96 |
def issue_edit(user, journal, att=false)
|
|
97 | 97 |
issue = journal.journalized |
98 | 98 |
redmine_headers 'Project' => issue.project.identifier, |
99 | 99 |
'Issue-Id' => issue.id, |
... | ... | |
110 | 110 |
@journal = journal |
111 | 111 |
@journal_details = journal.visible_details |
112 | 112 |
@issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue, :anchor => "change-#{journal.id}") |
113 |
@att = att |
|
113 | 114 | |
114 | 115 |
mail :to => user, |
115 | 116 |
:subject => s |
... | ... | |
125 | 126 |
journal.notes? || journal.visible_details(user).any? |
126 | 127 |
end |
127 | 128 |
users.each do |user| |
128 |
issue_edit(user, journal).deliver_later |
|
129 |
issue_edit(user, journal, journal.issue.attachments_visible?(user)).deliver_later
|
|
129 | 130 |
end |
130 | 131 |
end |
131 | 132 |
app/views/issues/_edit.html.erb | ||
---|---|---|
39 | 39 |
<%= call_hook(:view_issues_edit_notes_bottom, { :issue => @issue, :notes => @notes, :form => f }) %> |
40 | 40 |
</fieldset> |
41 | 41 | |
42 |
<% if @issue.attachments_addable?(User.current) %> |
|
42 | 43 |
<fieldset><legend><%= l(:label_attachment_plural) %></legend> |
43 |
<% if @issue.attachments.any? && @issue.safe_attribute?('deleted_attachment_ids') %>
|
|
44 |
<% if @attachments.any? && @issue.safe_attribute?('deleted_attachment_ids') %> |
|
44 | 45 |
<div class="contextual"><%= link_to l(:label_edit_attachments), '#', :onclick => "$('#existing-attachments').toggle(); return false;" %></div> |
45 | 46 |
<div id="existing-attachments" style="<%= @issue.deleted_attachment_ids.blank? ? 'display:none;' : '' %>"> |
46 |
<% @issue.attachments.each do |attachment| %>
|
|
47 |
<% @attachments.each do |attachment| %> |
|
47 | 48 |
<span class="existing-attachment"> |
48 | 49 |
<%= text_field_tag '', attachment.filename, :class => "icon icon-attachment filename", :disabled => true %> |
49 | 50 |
<label> |
... | ... | |
62 | 63 |
<%= render :partial => 'attachments/form', :locals => {:container => @issue} %> |
63 | 64 |
</div> |
64 | 65 |
</fieldset> |
66 |
<% end %> |
|
65 | 67 |
<% end %> |
66 | 68 |
</div> |
67 | 69 | |
... | ... | |
76 | 78 |
<%= hidden_field_tag 'issue_count', @issue_count if @issue_count %> |
77 | 79 | |
78 | 80 |
<% end %> |
79 |
app/views/issues/index.api.rsb | ||
---|---|---|
29 | 29 |
api.array :attachments do |
30 | 30 |
issue.attachments.each do |attachment| |
31 | 31 |
render_api_attachment(attachment, api) |
32 |
end |
|
32 |
end if issue.attachments_visible?
|
|
33 | 33 |
end if include_in_api_response?('attachments') |
34 | 34 | |
35 | 35 |
api.array :relations do |
app/views/issues/new.html.erb | ||
---|---|---|
18 | 18 |
</p> |
19 | 19 |
<% end %> |
20 | 20 |
<% if @copy_from && @copy_from.attachments.any? %> |
21 |
<p> |
|
21 |
<p style="<%= "display: none;" unless @copy_from.attachments_visible?(User.current) && @issue.attachments_addable?(User.current) %>">
|
|
22 | 22 |
<label for="copy_attachments"><%= l(:label_copy_attachments) %></label> |
23 | 23 |
<%= check_box_tag 'copy_attachments', '1', @copy_attachments %> |
24 | 24 |
</p> |
... | ... | |
30 | 30 |
</p> |
31 | 31 |
<% end %> |
32 | 32 | |
33 |
<p id="attachments_form"><label><%= l(:label_attachment_plural) %></label><%= render :partial => 'attachments/form', :locals => {:container => @issue} %></p> |
|
33 |
<p id="attachments_form" style="<%= "display: none;" unless @issue.attachments_addable?(User.current) %>"><label><%= l(:label_attachment_plural) %></label><%= render :partial => 'attachments/form', :locals => {:container => @issue} %></p>
|
|
34 | 34 | |
35 | 35 |
<div id="watchers_form_container"> |
36 | 36 |
<%= render :partial => 'issues/watchers_form' %> |
app/views/issues/new.js.erb | ||
---|---|---|
5 | 5 |
<% when "issue_category_id" %> |
6 | 6 |
$('#issue_assigned_to_id').find('option').first().html('<%= escape_javascript(@issue.category.try(:assigned_to).try(:name)).presence || ' '.html_safe %>'); |
7 | 7 |
<% end %> |
8 |
<% if @issue.attachments_addable?(User.current) %> |
|
9 |
<% if @copy_from.attachments_visible?(User.current) %> |
|
10 |
$('#copy_attachments').parent().show(); |
|
11 |
<% else %> |
|
12 |
$('#copy_attachments').parent().hide(); |
|
13 |
<% end %> |
|
14 |
$('#attachments_form').show(); |
|
15 |
<% else %> |
|
16 |
$('#copy_attachments').parent().hide(); |
|
17 |
$('#attachments_form').hide(); |
|
18 |
<% end %> |
app/views/issues/show.api.rsb | ||
---|---|---|
32 | 32 |
render_api_issue_children(@issue, api) if include_in_api_response?('children') |
33 | 33 | |
34 | 34 |
api.array :attachments do |
35 |
@issue.attachments.each do |attachment|
|
|
35 |
@attachments.each do |attachment| |
|
36 | 36 |
render_api_attachment(attachment, api) |
37 | 37 |
end |
38 | 38 |
end if include_in_api_response?('attachments') |
app/views/issues/show.html.erb | ||
---|---|---|
84 | 84 | |
85 | 85 |
<p><strong><%=l(:field_description)%></strong></p> |
86 | 86 |
<div class="wiki"> |
87 |
<%= textilizable @issue, :description, :attachments => @issue.attachments %>
|
|
87 |
<%= textilizable @issue, :description, :attachments => @attachments %> |
|
88 | 88 |
</div> |
89 | 89 |
</div> |
90 | 90 |
<% end %> |
91 |
<% if @issue.attachments.any? %>
|
|
91 |
<% if @attachments.any? %> |
|
92 | 92 |
<hr /> |
93 | 93 |
<p><strong><%=l(:label_attachment_plural)%></strong></p> |
94 | 94 |
<%= link_to_attachments @issue, :thumbnails => true %> |
app/views/mailer/_issue.html.erb | ||
---|---|---|
4 | 4 | |
5 | 5 |
<%= textilizable(issue, :description, :only_path => false) %> |
6 | 6 | |
7 |
<% if issue.attachments.any? %> |
|
7 |
<% if issue.attachments.any? && @att %>
|
|
8 | 8 |
<fieldset class="attachments"><legend><%= l(:label_attachment_plural) %></legend> |
9 | 9 |
<% issue.attachments.each do |attachment| %> |
10 | 10 |
<%= link_to_attachment attachment, :download => true, :only_path => false %> |
app/views/mailer/_issue.text.erb | ||
---|---|---|
5 | 5 |
---------------------------------------- |
6 | 6 |
<%= issue.description %> |
7 | 7 | |
8 |
<% if issue.attachments.any? -%> |
|
8 |
<% if issue.attachments.any? && @att -%>
|
|
9 | 9 |
---<%= l(:label_attachment_plural).ljust(37, '-') %> |
10 | 10 |
<% issue.attachments.each do |attachment| -%> |
11 | 11 |
<%= attachment.filename %> (<%= number_to_human_size(attachment.filesize) %>) |
app/views/roles/_form.html.erb | ||
---|---|---|
67 | 67 | |
68 | 68 |
<div id="role-permissions-trackers" class="view_issues_shown"> |
69 | 69 |
<h3><%= l(:label_issue_tracking) %></h3> |
70 |
<% permissions = %w(view_issues add_issues edit_issues add_issue_notes delete_issues) %> |
|
70 |
<% permissions = %w(view_issues add_issues edit_issues add_issue_notes delete_issues view_attachments add_attachments edit_attachments delete_attachments) %>
|
|
71 | 71 | |
72 | 72 |
<div class="autoscroll"> |
73 | 73 |
<table class="list"> |
config/locales/en.yml | ||
---|---|---|
492 | 492 |
permission_view_private_notes: View private notes |
493 | 493 |
permission_set_notes_private: Set notes as private |
494 | 494 |
permission_delete_issues: Delete issues |
495 |
permission_view_attachments: View attachments |
|
496 |
permission_add_attachments: Add attachments |
|
497 |
permission_edit_attachments: Edit attachments |
|
498 |
permission_delete_attachments: Delete attachments |
|
495 | 499 |
permission_manage_public_queries: Manage public queries |
496 | 500 |
permission_save_queries: Save queries |
497 | 501 |
permission_view_gantt: View gantt chart |
config/locales/pt-BR.yml | ||
---|---|---|
782 | 782 |
permission_manage_members: Gerenciar membros |
783 | 783 |
permission_edit_messages: Editar mensagens |
784 | 784 |
permission_delete_issues: Excluir tarefas |
785 |
permission_view_attachments: Ver arquivos anexos |
|
786 |
permission_add_attachments: Adicionar arquivos anexos |
|
787 |
permission_edit_attachments: Editar arquivos anexos |
|
788 |
permission_delete_attachments: Apagar arquivos anexos |
|
785 | 789 |
permission_view_issue_watchers: Ver lista de observadores |
786 | 790 |
permission_manage_repository: Gerenciar repositório |
787 | 791 |
permission_commit_access: Acesso do commit |
db/migrate/20161215142110_add_attachments_permissions.rb | ||
---|---|---|
1 |
class AddAttachmentsPermissions < ActiveRecord::Migration[4.2] |
|
2 |
def self.up |
|
3 |
Role.all.each do |r| |
|
4 |
r.add_permission!(:view_attachments) if r.has_permission?(:view_issues) |
|
5 |
r.add_permission!(:add_attachments) if r.has_permission?(:add_issues) |
|
6 |
r.add_permission!(:edit_attachments) if r.has_permission?(:edit_issues) |
|
7 |
r.add_permission!(:delete_attachments) if r.has_permission?(:delete_issues) |
|
8 |
end |
|
9 |
end |
|
10 | ||
11 |
def self.down |
|
12 |
Role.all.each do |r| |
|
13 |
r.remove_permission!(:view_attachments) |
|
14 |
r.remove_permission!(:add_attachments) |
|
15 |
r.remove_permission!(:edit_attachments) |
|
16 |
r.remove_permission!(:delete_attachments) |
|
17 |
end |
|
18 |
end |
|
19 |
end |
lib/plugins/acts_as_searchable/lib/acts_as_searchable.rb | ||
---|---|---|
134 | 134 |
r |= fetch_ranks_and_ids( |
135 | 135 |
search_scope(user, projects, options). |
136 | 136 |
joins(:attachments). |
137 |
where("#{Project.allowed_to_condition(user, :view_attachments)}", false). |
|
137 | 138 |
where(search_tokens_condition(["#{Attachment.table_name}.filename", "#{Attachment.table_name}.description"], tokens, options[:all_words])), |
138 | 139 |
options[:limit] |
139 | 140 |
) |
lib/redmine.rb | ||
---|---|---|
99 | 99 |
:queries => :index, |
100 | 100 |
:reports => [:issue_report, :issue_report_details]}, |
101 | 101 |
:read => true |
102 |
map.permission :add_issues, {:issues => [:new, :create], :attachments => :upload}
|
|
103 |
map.permission :edit_issues, {:issues => [:edit, :update, :bulk_edit, :bulk_update], :journals => [:new], :attachments => :upload}
|
|
104 |
map.permission :copy_issues, {:issues => [:new, :create, :bulk_edit, :bulk_update], :attachments => :upload}
|
|
102 |
map.permission :add_issues, {:issues => [:new, :create]} |
|
103 |
map.permission :edit_issues, {:issues => [:edit, :update, :bulk_edit, :bulk_update], :journals => [:new]} |
|
104 |
map.permission :copy_issues, {:issues => [:new, :create, :bulk_edit, :bulk_update]} |
|
105 | 105 |
map.permission :manage_issue_relations, {:issue_relations => [:index, :show, :create, :destroy]} |
106 | 106 |
map.permission :manage_subtasks, {} |
107 | 107 |
map.permission :set_issues_private, {} |
108 | 108 |
map.permission :set_own_issues_private, {}, :require => :loggedin |
109 |
map.permission :add_issue_notes, {:issues => [:edit, :update], :journals => [:new], :attachments => :upload}
|
|
109 |
map.permission :add_issue_notes, {:issues => [:edit, :update], :journals => [:new]} |
|
110 | 110 |
map.permission :edit_issue_notes, {:journals => [:edit, :update]}, :require => :loggedin |
111 | 111 |
map.permission :edit_own_issue_notes, {:journals => [:edit, :update]}, :require => :loggedin |
112 | 112 |
map.permission :view_private_notes, {}, :read => true, :require => :member |
113 | 113 |
map.permission :set_notes_private, {}, :require => :member |
114 | 114 |
map.permission :delete_issues, {:issues => :destroy}, :require => :member |
115 |
# Attachments |
|
116 |
map.permission :add_attachments, {:attachments => :upload} |
|
117 |
map.permission :view_attachments, {} |
|
118 |
map.permission :edit_attachments, {} |
|
119 |
map.permission :delete_attachments, {:attachments => :destroy}, :require => :member |
|
115 | 120 |
# Watchers |
116 | 121 |
map.permission :view_issue_watchers, {}, :read => true |
117 | 122 |
map.permission :add_issue_watchers, {:watchers => [:new, :create, :append, :autocomplete_for_user]} |
lib/redmine/export/pdf/issues_pdf_helper.rb | ||
---|---|---|
45 | 45 |
pdf.SetFontStyle('',8) |
46 | 46 |
pdf.RDMMultiCell(190, 5, "#{format_time(issue.created_on)} - #{issue.author}") |
47 | 47 |
pdf.ln |
48 |
|
|
48 | ||
49 | 49 |
left = [] |
50 | 50 |
left << [l(:field_status), issue.status] |
51 | 51 |
left << [l(:field_priority), issue.priority] |
52 | 52 |
left << [l(:field_assigned_to), issue.assigned_to] unless issue.disabled_core_fields.include?('assigned_to_id') |
53 | 53 |
left << [l(:field_category), issue.category] unless issue.disabled_core_fields.include?('category_id') |
54 | 54 |
left << [l(:field_fixed_version), issue.fixed_version] unless issue.disabled_core_fields.include?('fixed_version_id') |
55 |
|
|
55 | ||
56 | 56 |
right = [] |
57 | 57 |
right << [l(:field_start_date), format_date(issue.start_date)] unless issue.disabled_core_fields.include?('start_date') |
58 | 58 |
right << [l(:field_due_date), format_date(issue.due_date)] unless issue.disabled_core_fields.include?('due_date') |
59 | 59 |
right << [l(:field_done_ratio), "#{issue.done_ratio}%"] unless issue.disabled_core_fields.include?('done_ratio') |
60 | 60 |
right << [l(:field_estimated_hours), l_hours(issue.estimated_hours)] unless issue.disabled_core_fields.include?('estimated_hours') |
61 | 61 |
right << [l(:label_spent_time), l_hours(issue.total_spent_hours)] if User.current.allowed_to?(:view_time_entries, issue.project) |
62 |
|
|
62 | ||
63 | 63 |
rows = left.size > right.size ? left.size : right.size |
64 | 64 |
while left.size < rows |
65 | 65 |
left << nil |
... | ... | |
73 | 73 |
custom_field_values.each_with_index do |custom_value, i| |
74 | 74 |
(i < half ? left : right) << [custom_value.custom_field.name, show_value(custom_value, false)] |
75 | 75 |
end |
76 |
|
|
76 | ||
77 | 77 |
if pdf.get_rtl |
78 | 78 |
border_first_top = 'RT' |
79 | 79 |
border_last_top = 'LT' |
... | ... | |
85 | 85 |
border_first = 'L' |
86 | 86 |
border_last = 'R' |
87 | 87 |
end |
88 |
|
|
88 | ||
89 | 89 |
rows = left.size > right.size ? left.size : right.size |
90 | 90 |
rows.times do |i| |
91 | 91 |
heights = [] |
... | ... | |
100 | 100 |
item = right[i] |
101 | 101 |
heights << pdf.get_string_height(60, item ? item.last.to_s : "") |
102 | 102 |
height = heights.max |
103 |
|
|
103 | ||
104 | 104 |
item = left[i] |
105 | 105 |
pdf.SetFontStyle('B',9) |
106 | 106 |
pdf.RDMMultiCell(35, height, item ? "#{item.first}:" : "", (i == 0 ? border_first_top : border_first), '', 0, 0) |
107 | 107 |
pdf.SetFontStyle('',9) |
108 | 108 |
pdf.RDMMultiCell(60, height, item ? item.last.to_s : "", (i == 0 ? border_last_top : border_last), '', 0, 0) |
109 |
|
|
109 | ||
110 | 110 |
item = right[i] |
111 | 111 |
pdf.SetFontStyle('B',9) |
112 | 112 |
pdf.RDMMultiCell(35, height, item ? "#{item.first}:" : "", (i == 0 ? border_first_top : border_first), '', 0, 0) |
113 | 113 |
pdf.SetFontStyle('',9) |
114 | 114 |
pdf.RDMMultiCell(60, height, item ? item.last.to_s : "", (i == 0 ? border_last_top : border_last), '', 0, 2) |
115 |
|
|
115 | ||
116 | 116 |
pdf.set_x(base_x) |
117 | 117 |
end |
118 |
|
|
118 | ||
119 | 119 |
pdf.SetFontStyle('B',9) |
120 | 120 |
pdf.RDMCell(35+155, 5, l(:field_description), "LRT", 1) |
121 | 121 |
pdf.SetFontStyle('',9) |
122 |
|
|
122 | ||
123 | 123 |
# Set resize image scale |
124 | 124 |
pdf.set_image_scale(1.6) |
125 | 125 |
text = textilizable(issue, :description, |
... | ... | |
157 | 157 |
pdf.ln |
158 | 158 |
end |
159 | 159 |
end |
160 |
|
|
160 | ||
161 | 161 |
relations = issue.relations.select { |r| r.other_issue(issue).visible? } |
162 | 162 |
unless relations.empty? |
163 | 163 |
truncate_length = (!is_cjk? ? 80 : 60) |
... | ... | |
185 | 185 |
end |
186 | 186 |
pdf.RDMCell(190,5, "", "T") |
187 | 187 |
pdf.ln |
188 |
|
|
188 | ||
189 | 189 |
if issue.changesets.any? && |
190 | 190 |
User.current.allowed_to?(:view_changesets, issue.project) |
191 | 191 |
pdf.SetFontStyle('B',9) |
... | ... | |
205 | 205 |
pdf.ln |
206 | 206 |
end |
207 | 207 |
end |
208 |
|
|
208 | ||
209 | 209 |
if assoc[:journals].present? |
210 | 210 |
pdf.SetFontStyle('B',9) |
211 | 211 |
pdf.RDMCell(190,5, l(:label_history), "B") |
... | ... | |
234 | 234 |
pdf.ln |
235 | 235 |
end |
236 | 236 |
end |
237 |
|
|
238 |
if issue.attachments.any? |
|
237 | ||
238 |
if issue.attachments.any? && issue.attachments_visible?(User.current)
|
|
239 | 239 |
pdf.SetFontStyle('B',9) |
240 | 240 |
pdf.RDMCell(190,5, l(:label_attachment_plural), "B") |
241 | 241 |
pdf.ln |
... | ... | |
261 | 261 |
pdf.footer_date = format_date(User.current.today) |
262 | 262 |
pdf.set_auto_page_break(false) |
263 | 263 |
pdf.add_page("L") |
264 |
|
|
264 | ||
265 | 265 |
# Landscape A4 = 210 x 297 mm |
266 | 266 |
page_height = pdf.get_page_height # 210 |
267 | 267 |
page_width = pdf.get_page_width # 297 |
... | ... | |
269 | 269 |
right_margin = pdf.get_original_margins['right'] # 10 |
270 | 270 |
bottom_margin = pdf.get_footer_margin |
271 | 271 |
row_height = 4 |
272 |
|
|
272 | ||
273 | 273 |
# column widths |
274 | 274 |
table_width = page_width - right_margin - left_margin |
275 | 275 |
col_width = [] |
... | ... | |
277 | 277 |
col_width = calc_col_width(issues, query, table_width, pdf) |
278 | 278 |
table_width = col_width.inject(0, :+) |
279 | 279 |
end |
280 |
|
|
280 | ||
281 | 281 |
# use full width if the description or last_notes are displayed |
282 | 282 |
if table_width > 0 && (query.has_column?(:description) || query.has_column?(:last_notes)) |
283 | 283 |
col_width = col_width.map {|w| w * (page_width - right_margin - left_margin) / table_width} |
284 | 284 |
table_width = col_width.inject(0, :+) |
285 | 285 |
end |
286 |
|
|
286 | ||
287 | 287 |
# title |
288 | 288 |
pdf.SetFontStyle('B',11) |
289 | 289 |
pdf.RDMCell(190, 8, title) |
... | ... | |
317 | 317 |
end |
318 | 318 |
previous_group = group |
319 | 319 |
end |
320 |
|
|
320 | ||
321 | 321 |
# fetch row values |
322 | 322 |
col_values = fetch_row_values(issue, query, level) |
323 |
|
|
323 | ||
324 | 324 |
# make new page if it doesn't fit on the current one |
325 | 325 |
base_y = pdf.get_y |
326 | 326 |
max_height = get_issues_to_pdf_write_cells(pdf, col_values, col_width) |
... | ... | |
330 | 330 |
render_table_header(pdf, query, col_width, row_height, table_width) |
331 | 331 |
base_y = pdf.get_y |
332 | 332 |
end |
333 |
|
|
333 | ||
334 | 334 |
# write the cells on page |
335 | 335 |
issues_to_pdf_write_cells(pdf, col_values, col_width, max_height) |
336 | 336 |
pdf.set_y(base_y + max_height) |
337 |
|
|
337 | ||
338 | 338 |
if query.has_column?(:description) && issue.description? |
339 | 339 |
pdf.set_x(10) |
340 | 340 |
pdf.set_auto_page_break(true, bottom_margin) |
... | ... | |
349 | 349 |
pdf.set_auto_page_break(false) |
350 | 350 |
end |
351 | 351 |
end |
352 |
|
|
352 | ||
353 | 353 |
if issues.size == Setting.issues_export_limit.to_i |
354 | 354 |
pdf.SetFontStyle('B',10) |
355 | 355 |
pdf.RDMCell(0, row_height, '...') |