Project

General

Profile

RE: Hide public projects for specific roles ยป hide_projects_v1.3.diff

Fabio Peruzzo, 2018-09-19 13:59

View differences:

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
plugins/progressive_projects_list/lib/progressive/projects_helper_patch.rb 2017-04-12 16:14:44.000000000 +0200
2 2
  def self.included(base) # :nodoc:
3 3
    base.class_eval do
4 4

  
5
      def render_project_hierarchy_with_progress_bars(projects)
5
    def render_project_hierarchy_with_progress_bars(projects)
6 6
        render_project_nested_lists(projects) do |project|
7
          s = link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}")
8
          if !progressive_setting?(:show_only_for_my_projects) || User.current.member_of?(project)
9
            if progressive_setting?(:show_project_menu)
10
              s << render_project_menu(project) + '<br />'.html_safe
11
            end
12
            if project.description.present? && progressive_setting?(:show_project_description)
13
              s << content_tag('div', textilizable(project.short_description, :project => project), :class => 'wiki description')
14
            end
15
            if progressive_setting?(:show_project_progress) && User.current.allowed_to?(:view_issues, project)
16
              s << render_project_progress_bars(project)
7
          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))
8
            s = ""
9
          else
10
            s = link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}")
11
            if !progressive_setting?(:show_only_for_my_projects) || User.current.member_of?(project)
12
              if progressive_setting?(:show_project_menu)
13
                s << render_project_menu(project) + '<br />'.html_safe
14
              end
15
              if project.description.present? && progressive_setting?(:show_project_description)
16
                s << content_tag('div', textilizable(project.short_description, :project => project), :class => 'wiki description')
17
              end
18
              if progressive_setting?(:show_project_progress) && User.current.allowed_to?(:view_issues, project)
19
                s << render_project_progress_bars(project)
20
              end
17 21
            end
18 22
          end
19 23
          s
......
69 73
unless ProjectsHelper.include? Progressive::ProjectsHelperPatch
70 74
  ProjectsHelper.send(:include, Progressive::ProjectsHelperPatch)
71 75
end
76

  
    (1-1/1)