parent
3c810a0cee
commit
df48d89881
|
@ -593,22 +593,37 @@ module ApplicationHelper
|
||||||
Project.project_tree(projects, &block)
|
Project.project_tree(projects, &block)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# 项目版本库可见权限判断
|
||||||
|
# 条件:1、modules中设置不可见或项目没有版本库;2、如果项目是私有或者项目版本库隐藏则必须是项目成员才可见
|
||||||
|
def visible_repository?(project)
|
||||||
|
@result = false
|
||||||
|
unless project.enabled_modules.where("name = 'repository'").empty? || project.repositories.count == 0
|
||||||
|
if (project.hidden_repo || !project.is_public?)
|
||||||
|
if User.current.member_of?(project)
|
||||||
|
@result = true
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@result = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return @result
|
||||||
|
end
|
||||||
|
|
||||||
# 判断当前用户是否为项目管理员
|
# 判断当前用户是否为项目管理员
|
||||||
def is_project_manager?(user_id, project_id)
|
def is_project_manager?(user_id, project_id)
|
||||||
@result = false
|
@result = false
|
||||||
mem = Member.where("user_id = ? and project_id = ?",user_id, project_id)
|
mem = Member.where("user_id = ? and project_id = ?",user_id, project_id)
|
||||||
unless mem.blank?
|
unless mem.blank?
|
||||||
mem.first.roles.to_s.include?("Manager")
|
@result = mem.first.roles.to_s.include?("Manager") ? true : false
|
||||||
@result = true
|
|
||||||
end
|
end
|
||||||
return @result
|
return @result
|
||||||
end
|
end
|
||||||
|
|
||||||
# 私有项目资源不能引用,不能设置公开私有
|
# 公开项目资源可以引用,admin和管理员和资源上传者拥有设置公开私有权限
|
||||||
# 公开项目资源可以应用,管理员和资源上传者拥有设置公开私有权限
|
|
||||||
def authority_pubilic_for_files(project, file)
|
def authority_pubilic_for_files(project, file)
|
||||||
@result = false
|
@result = false
|
||||||
if (is_project_manager?(User.current.id, @project.id) || file.author_id == User.current.id) && project_contains_attachment?(project,file) && file.container_id == project.id && file.container_type == "Project"
|
if (is_project_manager?(User.current.id, @project.id) || file.author_id == User.current.id || User.current.admin) &&
|
||||||
|
project_contains_attachment?(project,file) && file.container_id == project.id && file.container_type == "Project"
|
||||||
@result = true
|
@result = true
|
||||||
end
|
end
|
||||||
return @result
|
return @result
|
||||||
|
|
|
@ -39,20 +39,11 @@
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%# --版本库被设置成私有、module中设置不显示、没有创建版本库 三种情况不显示-- %>
|
<%# --版本库被设置成私有、module中设置不显示、没有创建版本库 三种情况不显示-- %>
|
||||||
<% unless @project.enabled_modules.where("name = 'repository'").empty? || @project.repositories.count == 0 %>
|
<% if visible_repository?(@project) %>
|
||||||
<% if @project.hidden_repo || !@project.is_public? %>
|
<div class="subNav">
|
||||||
<% if User.current.member_of?(@project) %>
|
<%= link_to l(:project_module_repository), {:controller => 'repositories', :action => 'show', :id => @project.id}, :class => "f14 c_blue02" %>
|
||||||
<div class="subNav">
|
<a class="subnav_num">(<%= @project.repositories.count %>)</a>
|
||||||
<%= link_to l(:project_module_repository), {:controller => 'repositories', :action => 'show', :id => @project.id}, :class => "f14 c_blue02" %>
|
</div>
|
||||||
<a class="subnav_num">(<%= @project.repositories.count %>)</a>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
<% else %>
|
|
||||||
<div class="subNav">
|
|
||||||
<%= link_to l(:project_module_repository), {:controller => 'repositories', :action => 'show', :id => @project.id}, :class => "f14 c_blue02" %>
|
|
||||||
<a class="subnav_num">(<%= @project.repositories.count %>)</a>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
<!-- more -->
|
<!-- more -->
|
||||||
<div class="subNav subNav_jiantou" id="expand_tools_expand" nhtype="toggle4cookie" data-id="expand_tool_more" data-target="#navContent" data-val="retract"><%= l(:label_project_more) %></div>
|
<div class="subNav subNav_jiantou" id="expand_tools_expand" nhtype="toggle4cookie" data-id="expand_tool_more" data-target="#navContent" data-val="retract"><%= l(:label_project_more) %></div>
|
||||||
|
|
Loading…
Reference in New Issue