comparison app/models/.svn/text-base/mail_handler.rb.svn-base @ 120:cd2282d2aa55 cannam

Merge from the default branch. Note that this is not a valid SVN repository any more (use default, redmine-1.1 etc for SVN updates).
author Chris Cannam
date Thu, 13 Jan 2011 14:33:08 +0000
parents af80e5618e9b 8661b858af72
children eeebe205a056
comparison
equal deleted inserted replaced
118:b859cc0c4fa1 120:cd2282d2aa55
233 # Destructively extracts the value for +attr+ in +text+ 233 # Destructively extracts the value for +attr+ in +text+
234 # Returns nil if no matching keyword found 234 # Returns nil if no matching keyword found
235 def extract_keyword!(text, attr, format=nil) 235 def extract_keyword!(text, attr, format=nil)
236 keys = [attr.to_s.humanize] 236 keys = [attr.to_s.humanize]
237 if attr.is_a?(Symbol) 237 if attr.is_a?(Symbol)
238 keys << l("field_#{attr}", :default => '', :locale => user.language) if user 238 keys << l("field_#{attr}", :default => '', :locale => user.language) if user && user.language.present?
239 keys << l("field_#{attr}", :default => '', :locale => Setting.default_language) 239 keys << l("field_#{attr}", :default => '', :locale => Setting.default_language) if Setting.default_language.present?
240 end 240 end
241 keys.reject! {|k| k.blank?} 241 keys.reject! {|k| k.blank?}
242 keys.collect! {|k| Regexp.escape(k)} 242 keys.collect! {|k| Regexp.escape(k)}
243 format ||= '.+' 243 format ||= '.+'
244 text.gsub!(/^(#{keys.join('|')})[ \t]*:[ \t]*(#{format})\s*$/i, '') 244 text.gsub!(/^(#{keys.join('|')})[ \t]*:[ \t]*(#{format})\s*$/i, '')