RE: Hide public projects for specific roles ยป hide_projects_v1.1.diff
| app/helpers/application_helper.rb (working copy) | ||
|---|---|---|
| 48 | 48 |   def link_to_user(user, options={})
 | 
| 49 | 49 | if user.is_a?(User) | 
| 50 | 50 | name = h(user.name(options[:format])) | 
| 51 |       if user.active? || (User.current.admin? && user.logged?)
 | |
| 51 |       if (user.active? || (User.current.admin? && user.logged?)) && (User.current.admin? && (not User.current.allowed_to?(:hide_public_projects, nil, :global => true)))
 | |
| 52 | 52 | link_to name, user_path(user), :class => user.css_classes | 
| 53 | 53 | else | 
| 54 | 54 | name | 
| app/helpers/projects_helper.rb (working copy) | ||
|---|---|---|
| 48 | 48 |  | 
| 49 | 49 | def render_project_action_links | 
| 50 | 50 | links = [] | 
| 51 | if User.current.allowed_to?(:add_project, nil, :global => true) | |
| 52 | links << link_to(l(:label_project_new), new_project_path, :class => 'icon icon-add') | |
| 51 | if (not User.current.allowed_to?(:hide_public_projects, nil, :global => true)) | |
| 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') | |
| 54 | end | |
| 55 | if User.current.allowed_to?(:view_issues, nil, :global => true) | |
| 56 | links << link_to(l(:label_issue_view_all), issues_path) | |
| 57 | end | |
| 58 | if User.current.allowed_to?(:view_time_entries, nil, :global => true) | |
| 59 | links << link_to(l(:label_overall_spent_time), time_entries_path) | |
| 60 | end | |
| 61 | links << link_to(l(:label_overall_activity), activity_path) | |
| 53 | 62 | end | 
| 54 | if User.current.allowed_to?(:view_issues, nil, :global => true) | |
| 55 | links << link_to(l(:label_issue_view_all), issues_path) | |
| 56 | end | |
| 57 | if User.current.allowed_to?(:view_time_entries, nil, :global => true) | |
| 58 | links << link_to(l(:label_overall_spent_time), time_entries_path) | |
| 59 | end | |
| 60 | links << link_to(l(:label_overall_activity), activity_path) | |
| 61 | 63 |     links.join(" | ").html_safe
 | 
| 62 | 64 | end | 
| 63 | 65 |  | 
| 64 | 66 | # Renders the projects index | 
| 65 | 67 | def render_project_hierarchy(projects) | 
| 66 | 68 | render_project_nested_lists(projects) do |project| | 
| 67 |       s = link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}")
 | |
| 68 | if project.description.present? | |
| 69 |         s << content_tag('div', textilizable(project.short_description, :project => project), :class => 'wiki description')
 | |
| 69 | 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)) | |
| 70 | s = "" | |
| 71 | else | |
| 72 |         s = link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}")
 | |
| 73 | if project.description.present? | |
| 74 |           s << content_tag('div', textilizable(project.short_description, :project => project), :class => 'wiki description')
 | |
| 75 | end | |
| 70 | 76 | end | 
| 71 | 77 | s | 
| 72 | 78 | end | 
| app/models/user.rb (copie de travail) | ||
|---|---|---|
| 555 | 555 | return [] if project.nil? || project.archived? | 
| 556 | 556 | if membership = membership(project) | 
| 557 | 557 | membership.roles.to_a | 
| 558 | elsif project.is_public? | |
| 558 |     elsif project.is_public? && !allowed_to?(:hide_public_projects, nil, :global => true)
 | |
| 559 | 559 | project.override_roles(builtin_role) | 
| 560 | 560 | else | 
| 561 | 561 | [] | 
| app/views/welcome/index.html.erb (working copy) | ||
|---|---|---|
| 11 | 11 | <% end %> | 
| 12 | 12 | <%= call_hook(:view_welcome_index_left, :projects => @projects) %> | 
| 13 | 13 | </div> | 
| 14 |  | |
| 14 | <!-- | |
| 15 | 15 | <div class="splitcontentright"> | 
| 16 | 16 | <% if @projects.any? %> | 
| 17 | 17 | <div class="projects box"> | 
| ... | ... | |
| 32 | 32 | <% end %> | 
| 33 | 33 | <%= call_hook(:view_welcome_index_right, :projects => @projects) %> | 
| 34 | 34 | </div> | 
| 35 |  | |
| 35 | --> | |
| 36 | 36 | <% content_for :header_tags do %> | 
| 37 | 37 | <%= auto_discovery_link_tag(:atom, {:controller => 'news', :action => 'index', :key => User.current.rss_key, :format => 'atom'},
 | 
| 38 | 38 |                                    :title => "#{Setting.app_title}: #{l(:label_news_latest)}") %>
 | 
| lib/redmine.rb (working copy) | ||
|---|---|---|
| 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
 |