Feature #17747 » private_role_redmine_3.2ter.patch
app/controllers/reports_controller.rb (working copy) | ||
---|---|---|
24 | 24 |
@versions = @project.shared_versions.sort |
25 | 25 |
@priorities = IssuePriority.all.reverse |
26 | 26 |
@categories = @project.issue_categories |
27 |
@assignees = (Setting.issue_group_assignment? ? @project.principals : @project.users).sort |
|
28 |
@authors = @project.users.sort |
|
27 |
## begin patch private role |
|
28 |
#@assignees = (Setting.issue_group_assignment? ? @project.principals : @project.users).sort |
|
29 |
@assignees = (Setting.issue_group_assignment? ? @project.principals : @project.users.visible).sort |
|
30 |
#@authors = @project.users.sort |
|
31 |
@authors = @project.users.visible.sort |
|
32 |
## end patch private role |
|
29 | 33 |
@subprojects = @project.descendants.visible |
30 | 34 | |
31 | 35 |
@issues_by_tracker = Issue.by_tracker(@project) |
... | ... | |
63 | 67 |
@report_title = l(:field_category) |
64 | 68 |
when "assigned_to" |
65 | 69 |
@field = "assigned_to_id" |
66 |
@rows = (Setting.issue_group_assignment? ? @project.principals : @project.users).sort |
|
70 |
## begin patch private role |
|
71 |
#@rows = (Setting.issue_group_assignment? ? @project.principals : @project.users).sort |
|
72 |
@rows = (Setting.issue_group_assignment? ? @project.principals : @project.users).visible.sort |
|
73 |
## end patch private role |
|
67 | 74 |
@data = Issue.by_assigned_to(@project) |
68 | 75 |
@report_title = l(:field_assigned_to) |
69 | 76 |
when "author" |
70 | 77 |
@field = "author_id" |
71 |
@rows = @project.users.sort |
|
78 |
## begin patch private role |
|
79 |
#@rows = @project.users.sort |
|
80 |
@rows = @project.users.visible.sort |
|
81 |
## end patch private role |
|
72 | 82 |
@data = Issue.by_author(@project) |
73 | 83 |
@report_title = l(:field_author) |
74 | 84 |
when "subproject" |
app/controllers/users_controller.rb (working copy) | ||
---|---|---|
63 | 63 | |
64 | 64 |
def show |
65 | 65 |
unless @user.visible? |
66 |
render_404 |
|
66 |
## begin patch private role (revert revision 13584 - if user with private role (or non-member?) acts on issue, user should be visible) |
|
67 |
#render_404 |
|
68 |
render_403 |
|
69 |
## end patch private role |
|
67 | 70 |
return |
68 | 71 |
end |
69 | 72 |
app/models/principal.rb (working copy) | ||
---|---|---|
54 | 54 |
active |
55 | 55 |
else |
56 | 56 |
# self and members of visible projects |
57 |
active.where("#{table_name}.id = ? OR #{table_name}.id IN (SELECT user_id FROM #{Member.table_name} WHERE project_id IN (?))", |
|
57 |
## begin patch private role |
|
58 |
#active.where("#{table_name}.id = ? OR #{table_name}.id IN (SELECT user_id FROM #{Member.table_name} WHERE project_id IN (?))", |
|
59 |
active.where("#{table_name}.id = ? OR #{table_name}.id IN (" + |
|
60 |
"SELECT m.user_id FROM #{Member.table_name} m" + |
|
61 |
" INNER JOIN #{MemberRole.table_name} mr ON m.id = mr.member_id" + |
|
62 |
" INNER JOIN #{Role.table_name} r ON mr.role_id = r.id" + |
|
63 |
" WHERE m.project_id IN (?) AND r.name NOT LIKE 'private.%')", |
|
64 |
## end patch private role |
|
58 | 65 |
user.id, user.visible_project_ids |
59 | 66 |
) |
60 | 67 |
end |
app/models/project.rb (working copy) | ||
---|---|---|
479 | 479 |
# Returns a hash of project users grouped by role |
480 | 480 |
def users_by_role |
481 | 481 |
members.includes(:user, :roles).inject({}) do |h, m| |
482 |
m.roles.each do |r| |
|
482 |
## begin patch private role |
|
483 |
#m.roles.each do |r| |
|
484 |
m.roles.non_private.each do |r| |
|
485 |
## end patch private role |
|
483 | 486 |
h[r] ||= [] |
484 | 487 |
h[r] << m.user |
485 | 488 |
end |
... | ... | |
510 | 513 | |
511 | 514 |
@assignable_users ||= Principal. |
512 | 515 |
active. |
516 |
## begin patch private role |
|
517 |
visible. |
|
518 |
## end patch private role |
|
513 | 519 |
joins(:members => :roles). |
514 | 520 |
where(:type => types, :members => {:project_id => id}, :roles => {:assignable => true}). |
515 | 521 |
uniq. |
app/models/role.rb (working copy) | ||
---|---|---|
50 | 50 |
] |
51 | 51 | |
52 | 52 |
scope :sorted, lambda { order(:builtin, :position) } |
53 |
scope :givable, lambda { order(:position).where(:builtin => 0) } |
|
53 |
## begin patch private role |
|
54 |
#scope :givable, lambda { order(:position).where(:builtin => 0) } |
|
55 |
scope :givable, lambda { |
|
56 |
if User.current.admin? |
|
57 |
order(:position).where(:builtin => 0) |
|
58 |
else |
|
59 |
order(:position).non_private.where(:builtin => 0) |
|
60 |
end |
|
61 |
} |
|
62 | ||
63 |
scope :non_private, lambda { |
|
64 |
if User.current.admin? |
|
65 |
all |
|
66 |
else |
|
67 |
all.where("#{table_name}.name NOT LIKE 'private.%'") |
|
68 |
end |
|
69 |
} |
|
70 |
## end patch private role |
|
71 | ||
54 | 72 |
scope :builtin, lambda { |*args| |
55 | 73 |
compare = (args.first == true ? 'not' : '') |
56 | 74 |
where("#{compare} builtin = 0") |