修改资源库全站搜索:
1、搜索条件为空的时候,不允许显示全部资源 2、全站搜索,非自己上传的资源不允许查看 3、全站搜索,项目管理员能设置公开权限的资源在全局搜索中也可以
This commit is contained in:
parent
2ac2884bf1
commit
379de18cd6
|
@ -67,9 +67,7 @@ class FilesController < ApplicationController
|
||||||
end
|
end
|
||||||
sort = "#{@sort} #{@order}"
|
sort = "#{@sort} #{@order}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# show_attachments [@course]
|
# show_attachments [@course]
|
||||||
|
|
||||||
begin
|
begin
|
||||||
q = "%#{params[:name].strip}%"
|
q = "%#{params[:name].strip}%"
|
||||||
#(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
|
#(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
|
||||||
|
@ -108,14 +106,18 @@ class FilesController < ApplicationController
|
||||||
end
|
end
|
||||||
sort = "#{@sort} #{@order}"
|
sort = "#{@sort} #{@order}"
|
||||||
end
|
end
|
||||||
|
|
||||||
begin
|
begin
|
||||||
q = "%#{params[:name].strip}%"
|
q = "%#{params[:name].strip}%"
|
||||||
#(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
|
#(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
|
||||||
if params[:insite]
|
if params[:insite]
|
||||||
@result = find_public_attache q,sort
|
if q == "%%"
|
||||||
@result = visable_attachemnts_insite @result,@project
|
@result = []
|
||||||
@searched_attach = paginateHelper @result,10
|
@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
|
else
|
||||||
@result = find_project_attache q,@project,sort
|
@result = find_project_attache q,@project,sort
|
||||||
@result = visable_attachemnts @result
|
@result = visable_attachemnts @result
|
||||||
|
|
|
@ -622,8 +622,8 @@ module ApplicationHelper
|
||||||
# 公开项目资源可以引用,admin和管理员和资源上传者拥有设置公开私有权限
|
# 公开项目资源可以引用,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 || User.current.admin) &&
|
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"
|
project_contains_attachment?(project,file) && file.container_id == project.id && file.container_type == "Project"
|
||||||
@result = true
|
@result = true
|
||||||
end
|
end
|
||||||
return @result
|
return @result
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
|
<% delete_allowed = User.current.allowed_to?(:manage_files, project) %>
|
||||||
<div class="re_con_top">
|
<div class="re_con_top">
|
||||||
<p class="f_l c_blue f_b f_14">共有 <%= all_attachments.count%> 个资源</p>
|
<p class="f_l c_blue f_b f_14">共有 <%= all_attachments.count%> 个资源</p>
|
||||||
<p class="f_r" style="color: #808080">
|
<p class="f_r" style="color: #808080">
|
||||||
|
@ -22,13 +22,13 @@
|
||||||
<% if User.current.logged? %>
|
<% if User.current.logged? %>
|
||||||
<% if (manage_allowed || file.author_id == User.current.id) && project_contains_attachment?(project,file) %>
|
<% 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) %>
|
<%= 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 %>
|
<% if authority_pubilic_for_files(project, file) && delete_allowed %>
|
||||||
<%= 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) %>
|
|
||||||
<span id="is_public_<%= file.id %>">
|
<span id="is_public_<%= file.id %>">
|
||||||
<%= 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 %>
|
<%= 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 %>
|
||||||
</span>
|
</span>
|
||||||
|
<% 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 %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue