From 3f77e2cdcfb5e1628c01419150dca7ccae9ff4f2 Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 18 May 2015 11:36:29 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=84=E6=BA=90=E6=9D=83=E9=99=90=E5=85=AC?= =?UTF-8?q?=E5=85=B1=E6=96=B9=E6=B3=95=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 14 ++++++++++++-- app/views/files/_project_file_list.html.erb | 4 +--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index bb62695c0..b6329c676 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -594,12 +594,22 @@ module ApplicationHelper end # 判断当前用户是否为项目管理员 - def is_project_manager?(user_id,project_id) + 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 = false + @result = true + end + return @result + end + + # 私有项目资源不能引用,不能设置公开私有 + # 公开项目资源可以应用,管理员和资源上传者拥有设置公开私有权限 + 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" + @result = true end return @result end diff --git a/app/views/files/_project_file_list.html.erb b/app/views/files/_project_file_list.html.erb index d3e383a4e..1042be584 100644 --- a/app/views/files/_project_file_list.html.erb +++ b/app/views/files/_project_file_list.html.erb @@ -20,10 +20,8 @@
<%= link_to_attachment file, :download => true,:text => truncate(file.filename,length: 35, omission: '...'), :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %> <% if User.current.logged? %> - <%#--私有项目资源不能引用,不能设置公开私有--%> - <%#--公开项目资源可以应用,管理员和资源上传者拥有设置公开私有权限--%> <%= link_to(l(:label_slected_to_other_project),quote_resource_show_project_project_file_path(project,file),:class => "f_l re_select",:remote => true) if has_project?(User.current,file) %> - <% 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 authority_pubilic_for_files(project, file) %> <%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open",:method => :post %>