RE: Hide public projects for specific roles ยป hide_projects_v1.4.diff
app/helpers/application_helper.rb (copie de travail) | ||
---|---|---|
52 | 52 |
def link_to_user(user, options={}) |
53 | 53 |
if user.is_a?(User) |
54 | 54 |
name = h(user.name(options[:format])) |
55 |
if user.active? || (User.current.admin? && user.logged?)
|
|
55 |
if (user.active? || (User.current.admin? && user.logged?)) && (User.current.admin? && (not User.current.allowed_to?(:hide_public_projects, nil, :global => true)))
|
|
56 | 56 |
link_to name, user_path(user), :class => user.css_classes |
57 | 57 |
else |
58 | 58 |
name |
app/helpers/projects_helper.rb (copie de travail) | ||
---|---|---|
49 | 49 | |
50 | 50 |
def render_project_action_links |
51 | 51 |
links = "".html_safe |
52 |
if User.current.allowed_to?(:add_project, nil, :global => true) |
|
53 |
links << link_to(l(:label_project_new), new_project_path, :class => 'icon icon-add') |
|
52 |
if (not User.current.allowed_to?(:hide_public_projects, nil, :global => true) or User.current.admin?) |
|
53 |
if User.current.allowed_to?(:add_project, nil, :global => true) |
|
54 |
links << link_to(l(:label_project_new), new_project_path, :class => 'icon icon-add') |
|
55 |
end |
|
54 | 56 |
end |
55 | 57 |
links |
56 | 58 |
end |
... | ... | |
58 | 60 |
# Renders the projects index |
59 | 61 |
def render_project_hierarchy(projects) |
60 | 62 |
render_project_nested_lists(projects) do |project| |
61 |
s = link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'icon icon-fav my-project' : nil}") |
|
62 |
if project.description.present? |
|
63 |
s << content_tag('div', textilizable(project.short_description, :project => project), :class => 'wiki description') |
|
63 |
if (not User.current.logged?) || ((not User.current.admin) && (not User.current.member_of?(project)) && User.current.allowed_to?(:hide_public_projects, nil, :global => true)) |
|
64 |
s = "" |
|
65 |
else |
|
66 |
s = link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'icon icon-fav my-project' : nil}") |
|
67 |
if project.description.present? |
|
68 |
s << content_tag('div', textilizable(project.short_description, :project => project), :class => 'wiki description') |
|
69 |
end |
|
64 | 70 |
end |
65 | 71 |
s |
66 | 72 |
end |
app/models/project.rb (copie de travail) | ||
---|---|---|
194 | 194 |
statement_by_role = {} |
195 | 195 |
unless options[:member] |
196 | 196 |
role = user.builtin_role |
197 |
if role.allowed_to?(permission) |
|
197 |
if role.allowed_to?(permission) && !user.allowed_to?(:hide_public_projects, nil, :global => true)
|
|
198 | 198 |
s = "#{Project.table_name}.is_public = #{connection.quoted_true}" |
199 | 199 |
if user.id |
200 | 200 |
group = role.anonymous? ? Group.anonymous : Group.non_member |
app/models/user.rb (copie de travail) | ||
---|---|---|
580 | 580 |
return [] if project.nil? || project.archived? |
581 | 581 |
if membership = membership(project) |
582 | 582 |
membership.roles.to_a |
583 |
elsif project.is_public? |
|
583 |
elsif project.is_public? && !allowed_to?(:hide_public_projects, nil, :global => true)
|
|
584 | 584 |
project.override_roles(builtin_role) |
585 | 585 |
else |
586 | 586 |
[] |
... | ... | |
682 | 682 |
roles = roles_for_project(context) |
683 | 683 |
return false unless roles |
684 | 684 |
roles.any? {|role| |
685 |
(context.is_public? || role.member?) &&
|
|
685 |
((context.is_public? && !allowed_to?(:hide_public_projects, nil, :global => true)) || role.member?) &&
|
|
686 | 686 |
role.allowed_to?(action) && |
687 | 687 |
(block_given? ? yield(role, self) : true) |
688 | 688 |
} |
lib/redmine.rb (copie de travail) | ||
---|---|---|
76 | 76 |
# Permissions |
77 | 77 |
Redmine::AccessControl.map do |map| |
78 | 78 |
map.permission :view_project, {:projects => [:show], :activities => [:index]}, :public => true, :read => true |
79 |
map.permission :hide_public_projects, {:projects => [:show]}, :require => :loggedin |
|
79 | 80 |
map.permission :search_project, {:search => :index}, :public => true, :read => true |
80 | 81 |
map.permission :add_project, {:projects => [:new, :create]}, :require => :loggedin |
81 | 82 |
map.permission :edit_project, {:projects => [:settings, :edit, :update]}, :require => :member |