|
|
|
@ -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
|
|
|
|
|