RE: Hide public projects for specific roles ยป hide_projects_v1.0.diff
| app/helpers/application_helper.rb (working copy) | ||
|---|---|---|
|
def link_to_user(user, options={})
|
||
|
if user.is_a?(User)
|
||
|
name = h(user.name(options[:format]))
|
||
|
if user.active? || (User.current.admin? && user.logged?)
|
||
|
if (user.active? || (User.current.admin? && user.logged?)) && (User.current.admin? && (not User.current.allowed_to?(:hide_public_projects, nil, :global => true)))
|
||
|
link_to name, user_path(user), :class => user.css_classes
|
||
|
else
|
||
|
name
|
||
| app/helpers/projects_helper.rb (working copy) | ||
|---|---|---|
|
def render_project_action_links
|
||
|
links = []
|
||
|
if User.current.allowed_to?(:add_project, nil, :global => true)
|
||
|
links << link_to(l(:label_project_new), new_project_path, :class => 'icon icon-add')
|
||
|
if (not User.current.allowed_to?(:hide_public_projects, nil, :global => true))
|
||
|
if User.current.allowed_to?(:add_project, nil, :global => true)
|
||
|
links << link_to(l(:label_project_new), new_project_path, :class => 'icon icon-add')
|
||
|
end
|
||
|
if User.current.allowed_to?(:view_issues, nil, :global => true)
|
||
|
links << link_to(l(:label_issue_view_all), issues_path)
|
||
|
end
|
||
|
if User.current.allowed_to?(:view_time_entries, nil, :global => true)
|
||
|
links << link_to(l(:label_overall_spent_time), time_entries_path)
|
||
|
end
|
||
|
links << link_to(l(:label_overall_activity), activity_path)
|
||
|
end
|
||
|
if User.current.allowed_to?(:view_issues, nil, :global => true)
|
||
|
links << link_to(l(:label_issue_view_all), issues_path)
|
||
|
end
|
||
|
if User.current.allowed_to?(:view_time_entries, nil, :global => true)
|
||
|
links << link_to(l(:label_overall_spent_time), time_entries_path)
|
||
|
end
|
||
|
links << link_to(l(:label_overall_activity), activity_path)
|
||
|
links.join(" | ").html_safe
|
||
|
end
|
||
|
# Renders the projects index
|
||
|
def render_project_hierarchy(projects)
|
||
|
render_project_nested_lists(projects) do |project|
|
||
|
s = link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}")
|
||
|
if project.description.present?
|
||
|
s << content_tag('div', textilizable(project.short_description, :project => project), :class => 'wiki description')
|
||
|
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))
|
||
|
s = ""
|
||
|
else
|
||
|
s = link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}")
|
||
|
if project.description.present?
|
||
|
s << content_tag('div', textilizable(project.short_description, :project => project), :class => 'wiki description')
|
||
|
end
|
||
|
end
|
||
|
s
|
||
|
end
|
||
| app/views/welcome/index.html.erb (working copy) | ||
|---|---|---|
|
<% end %>
|
||
|
<%= call_hook(:view_welcome_index_left, :projects => @projects) %>
|
||
|
</div>
|
||
|
<!--
|
||
|
<div class="splitcontentright">
|
||
|
<% if @projects.any? %>
|
||
|
<div class="projects box">
|
||
| ... | ... | |
|
<% end %>
|
||
|
<%= call_hook(:view_welcome_index_right, :projects => @projects) %>
|
||
|
</div>
|
||
|
-->
|
||
|
<% content_for :header_tags do %>
|
||
|
<%= auto_discovery_link_tag(:atom, {:controller => 'news', :action => 'index', :key => User.current.rss_key, :format => 'atom'},
|
||
|
:title => "#{Setting.app_title}: #{l(:label_news_latest)}") %>
|
||
| lib/redmine.rb (working copy) | ||
|---|---|---|
|
# Permissions
|
||
|
Redmine::AccessControl.map do |map|
|
||
|
map.permission :view_project, {:projects => [:show], :activities => [:index]}, :public => true, :read => true
|
||
|
map.permission :hide_public_projects, {:projects => [:show]}, :require => :loggedin
|
||
|
map.permission :search_project, {:search => :index}, :public => true, :read => true
|
||
|
map.permission :add_project, {:projects => [:new, :create]}, :require => :loggedin
|
||
|
map.permission :edit_project, {:projects => [:settings, :edit, :update]}, :require => :member
|
||