diff options
author | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2011-11-24 09:43:01 +0000 |
---|---|---|
committer | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2011-11-24 09:43:01 +0000 |
commit | f936b7b5a4ecd335f0464adb07d629d7c4f6b081 (patch) | |
tree | 70837876ecff9a57b291caec9a3c74fdb15f4e6c /lib | |
parent | be29227c12da043996cf05a489fa6b7ef26bea81 (diff) | |
download | redmine-f936b7b5a4ecd335f0464adb07d629d7c4f6b081.tar.gz redmine-f936b7b5a4ecd335f0464adb07d629d7c4f6b081.zip |
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/redmine/export/pdf.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/redmine/export/pdf.rb b/lib/redmine/export/pdf.rb index b5b4a4386..593398961 100644 --- a/lib/redmine/export/pdf.rb +++ b/lib/redmine/export/pdf.rb @@ -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 |