pdf: lib: add the method to return attachment from filename and encoding (#3261)

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7912 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA
2011-11-24 09:43:01 +00:00
parent be29227c12
commit f936b7b5a4
3 changed files with 76 additions and 0 deletions
+13
View File
@@ -517,6 +517,19 @@ module Redmine
end
txt
end
def self.attach(attachments, filename, encoding)
filename_utf8 = Redmine::CodesetUtil.to_utf8(filename, encoding)
atta = nil
if filename_utf8 =~ /^[^\/"]+\.(gif|jpg|jpe|jpeg|png)$/i
atta = Attachment.latest_attach(attachments, filename_utf8)
end
if atta && atta.readable? && atta.visible?
return atta
else
return nil
end
end
end
end
end