From 379de18cd6a4a015c112cf4d6b5c9e5c35f9f2ee Mon Sep 17 00:00:00 2001 From: huang Date: Sat, 23 May 2015 10:40:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B5=84=E6=BA=90=E5=BA=93?= =?UTF-8?q?=E5=85=A8=E7=AB=99=E6=90=9C=E7=B4=A2=EF=BC=9A=201=E3=80=81?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E6=9D=A1=E4=BB=B6=E4=B8=BA=E7=A9=BA=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99=EF=BC=8C=E4=B8=8D=E5=85=81=E8=AE=B8=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=85=A8=E9=83=A8=E8=B5=84=E6=BA=90=202=E3=80=81?= =?UTF-8?q?=E5=85=A8=E7=AB=99=E6=90=9C=E7=B4=A2=EF=BC=8C=E9=9D=9E=E8=87=AA?= =?UTF-8?q?=E5=B7=B1=E4=B8=8A=E4=BC=A0=E7=9A=84=E8=B5=84=E6=BA=90=E4=B8=8D?= =?UTF-8?q?=E5=85=81=E8=AE=B8=E6=9F=A5=E7=9C=8B=203=E3=80=81=E5=85=A8?= =?UTF-8?q?=E7=AB=99=E6=90=9C=E7=B4=A2=EF=BC=8C=E9=A1=B9=E7=9B=AE=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=91=98=E8=83=BD=E8=AE=BE=E7=BD=AE=E5=85=AC=E5=BC=80?= =?UTF-8?q?=E6=9D=83=E9=99=90=E7=9A=84=E8=B5=84=E6=BA=90=E5=9C=A8=E5=85=A8?= =?UTF-8?q?=E5=B1=80=E6=90=9C=E7=B4=A2=E4=B8=AD=E4=B9=9F=E5=8F=AF=E4=BB=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 14 ++++++++------ app/helpers/application_helper.rb | 4 ++-- app/views/files/_project_file_list.html.erb | 10 +++++----- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index aa2c9574b..0003f7586 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -67,9 +67,7 @@ class FilesController < ApplicationController end sort = "#{@sort} #{@order}" end - # show_attachments [@course] - begin q = "%#{params[:name].strip}%" #(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank? @@ -108,14 +106,18 @@ class FilesController < ApplicationController end sort = "#{@sort} #{@order}" end - begin q = "%#{params[:name].strip}%" #(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank? if params[:insite] - @result = find_public_attache q,sort - @result = visable_attachemnts_insite @result,@project - @searched_attach = paginateHelper @result,10 + if q == "%%" + @result = [] + @searched_attach = paginateHelper @result,10 + else + @result = find_public_attache q,sort + @result = visable_attachemnts_insite @result,@project + @searched_attach = paginateHelper @result,10 + end else @result = find_project_attache q,@project,sort @result = visable_attachemnts @result diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0836bf307..a07ff320d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -622,8 +622,8 @@ module ApplicationHelper # 公开项目资源可以引用,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 || User.current.admin) && - project_contains_attachment?(project,file) && file.container_id == project.id && file.container_type == "Project" + if (is_project_manager?(User.current.id, @project.id) && User.current.allowed_to?(:manage_files, project)) || 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 diff --git a/app/views/files/_project_file_list.html.erb b/app/views/files/_project_file_list.html.erb index d32d2319f..35aa36195 100644 --- a/app/views/files/_project_file_list.html.erb +++ b/app/views/files/_project_file_list.html.erb @@ -1,4 +1,4 @@ - +<% delete_allowed = User.current.allowed_to?(:manage_files, project) %>

共有 <%= all_attachments.count%> 个资源

@@ -22,13 +22,13 @@ <% if User.current.logged? %> <% if (manage_allowed || file.author_id == User.current.id) && project_contains_attachment?(project,file) %> <%= 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) %> - <% else %> - <%= link_to(l(:label_slected_to_project),quote_resource_show_project_project_file_path(project,file),:class => "f_l re_select",:remote => true) if has_project?(User.current,file) %> - <% end %> - <% if authority_pubilic_for_files(project, file) %> + <% if authority_pubilic_for_files(project, file) && delete_allowed %> <%= 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 %> + <% end %> + <% else %> + <%= link_to(l(:label_slected_to_project),quote_resource_show_project_project_file_path(project,file),:class => "f_l re_select",:remote => true) if has_project?(User.current,file) %> <% end %> <% end %>