This commit is contained in:
sw 2014-10-15 17:39:12 +08:00
commit 208940dd86
7 changed files with 22 additions and 25 deletions

View File

@ -256,13 +256,16 @@ class ApplicationController < ActionController::Base
end end
def authorize_attachment_download(ctrl = params[:controller], action = params[:action], global = false) def authorize_attachment_download(ctrl = params[:controller], action = params[:action], global = false)
if @attachment.container_type == "Memo" case @attachment.container_type
when "Memo"
allowed = User.current.allowed_to?(:memos_attachments_download,nil,:global => true) allowed = User.current.allowed_to?(:memos_attachments_download,nil,:global => true)
elsif @attachment.container_type == "Message" && !@project.nil? when "Message"
if @project
allowed = User.current.allowed_to?(:projects_attachments_download,@project,:global => false) allowed = User.current.allowed_to?(:projects_attachments_download,@project,:global => false)
elsif @attachment.container_type == "Message" && !@course.nil? elsif @course
allowed = User.current.allowed_to?(:course_attachments_download, @course, :global => false) allowed = User.current.allowed_to?(:course_attachments_download, @course, :global => false)
elsif @attachment.container_type == "contest" end
when "contest"
return true return true
else else
return true return true

View File

@ -402,13 +402,8 @@ class Attachment < ActiveRecord::Base
# Finds an attachment that matches the given token and that has no container # Finds an attachment that matches the given token and that has no container
def self.find_by_token(token) def self.find_by_token(token)
if token.to_s =~ /^(\d+)\.([0-9a-f]+)$/ attachment = find_by_token_only(token)
attachment_id, attachment_digest = $1, $2 attachment if attachment.container.nil?
attachment = Attachment.where(:id => attachment_id, :digest => attachment_digest).first
if attachment && attachment.container.nil?
attachment
end
end
end end
# Finds an attachment that matches the given token # Finds an attachment that matches the given token
@ -416,9 +411,6 @@ class Attachment < ActiveRecord::Base
if token.to_s =~ /^(\d+)\.([0-9a-f]+)$/ if token.to_s =~ /^(\d+)\.([0-9a-f]+)$/
attachment_id, attachment_digest = $1, $2 attachment_id, attachment_digest = $1, $2
attachment = Attachment.where(:id => attachment_id, :digest => attachment_digest).first attachment = Attachment.where(:id => attachment_id, :digest => attachment_digest).first
if attachment
attachment
end
end end
end end

View File

@ -11,3 +11,4 @@
<%= javascript_tag "$('#course_name').focus();" %> <%= javascript_tag "$('#course_name').focus();" %>
</div> </div>
<% end %> <% end %>
<% html_title(l(:label_course_new)) -%>

View File

@ -10,8 +10,8 @@
<%= @organize.description.html_safe unless @organize.nil?%> <%= @organize.description.html_safe unless @organize.nil?%>
</p> </p>
<div id="logo_link"> <div id="logo_link">
<% unless @companys.nil?%> <% unless @companies.nil?%>
<% @companys.each do |company| %> <% @companies.each do |company| %>
<span class="footer_logo_link"><%= link_to image_tag(url_to_avatar(company),:size=>"100x30",:alt=>company.name),company.url, :target => "_blank" %></span> <span class="footer_logo_link"><%= link_to image_tag(url_to_avatar(company),:size=>"100x30",:alt=>company.name),company.url, :target => "_blank" %></span>
<% end %> <% end %>
<% end %> <% end %>

View File

@ -98,4 +98,4 @@
</ul> </ul>
</div> </div>
<% html_title(l(:label_school_all)) -%>

View File

@ -69,3 +69,4 @@
} }
}); });
</script> </script>
<% html_title(l(:label_stores_index)) -%>