Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
This commit is contained in:
commit
2cc458eafd
|
@ -593,22 +593,37 @@ module ApplicationHelper
|
|||
Project.project_tree(projects, &block)
|
||||
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)
|
||||
@result = false
|
||||
mem = Member.where("user_id = ? and project_id = ?",user_id, project_id)
|
||||
unless mem.blank?
|
||||
mem.first.roles.to_s.include?("Manager")
|
||||
@result = true
|
||||
@result = mem.first.roles.to_s.include?("Manager") ? true : false
|
||||
end
|
||||
return @result
|
||||
end
|
||||
|
||||
# 私有项目资源不能引用,不能设置公开私有
|
||||
# 公开项目资源可以应用,管理员和资源上传者拥有设置公开私有权限
|
||||
# 公开项目资源可以引用,admin和管理员和资源上传者拥有设置公开私有权限
|
||||
def authority_pubilic_for_files(project, file)
|
||||
@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
|
||||
end
|
||||
return @result
|
||||
|
|
|
@ -39,21 +39,12 @@
|
|||
</div>
|
||||
<% end %>
|
||||
<%# --版本库被设置成私有、module中设置不显示、没有创建版本库 三种情况不显示-- %>
|
||||
<% 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) %>
|
||||
<% if visible_repository?(@project) %>
|
||||
<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 %>
|
||||
<% 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 %>
|
||||
<!-- 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>
|
||||
<ul class="navContent" id="navContent">
|
||||
|
|
Loading…
Reference in New Issue