some fixes

This commit is contained in:
Wojciech Todryk 2011-09-10 13:49:42 +02:00
parent f3a3c6bded
commit a1352b9402
5 changed files with 29 additions and 21 deletions

View file

@ -83,8 +83,10 @@ class MessagesController < ApplicationController
# FIXME missing fields # FIXME missing fields
@from = mail.From.addrs.presence #@from = mail.From.addrs.presence
@to = mail.To.addrs.presence #@to = mail.To.addrs.presence
@from = @message.from_addr
@to = @message.to_addr
@cc = mail.Cc.presence @cc = mail.Cc.presence
@bcc = mail.Bcc.presence @bcc = mail.Bcc.presence
#@subject = mail.Subject #@subject = mail.Subject

View file

@ -15,8 +15,8 @@ module MessagesHelper
end end
def address_formatter(addr,mode) def address_formatter(addr,mode)
s = "" s = ""
return s if addr.nil?
length = $defaults["msg_address_length"].to_i length = $defaults["msg_address_length"].to_i
case mode case mode
@ -26,12 +26,13 @@ module MessagesHelper
s.length >= length ? s = s[0,length]+"..." : s s.length >= length ? s = s[0,length]+"..." : s
return h(s) return h(s)
when :show when :show
addr = addr[0].charseted.gsub(/\"/,"") #addr = addr[0].charseted.gsub(/\"/,"")
return h(addr) return h(addr)
when :raw when :raw
#fs = addr.gsub(/\"/,"").split(/</) #fs = addr.gsub(/\"/,"").split(/</)
#fs[0].size.zero? ? s = fs[1] : s << fs[0] + " <" + fs[1] + ">" #fs[0].size.zero? ? s = fs[1] : s << fs[0] + " <" + fs[1] + ">"
return addr s = h(addr)
return s
end end
end end
@ -49,19 +50,22 @@ module MessagesHelper
def subject_formatter(message,mode) def subject_formatter(message,mode)
if message.subject.size.zero?
s = t(:no_subject,:scope=>:message)
else
case mode case mode
when :index when :index
if message.subject.nil? or message.subject.size.zero?
s = t(:no_subject,:scope=>:message)
else
length = $defaults["msg_subject_length"].to_i length = $defaults["msg_subject_length"].to_i
message.subject.length >= length ? s = message.subject[0,length]+"..." : s = message.subject message.subject.length >= length ? s = message.subject[0,length]+"..." : s = message.subject
end
link_to s,{:controller => 'messages', :action => 'show', :id => message.uid} , :title => message.subject link_to s,{:controller => 'messages', :action => 'show', :id => message.uid} , :title => message.subject
when :show when :show
if message.subject.nil? or message.subject.size.zero?
t(:no_subject,:scope=>:message)
else
message.subject message.subject
end end
end end
end end
def attachment_formatter(message) def attachment_formatter(message)

View file

@ -46,6 +46,8 @@ class Message < ActiveRecord::Base
mail.To.nil? ? to = nil : to = mail.To.charseted mail.To.nil? ? to = nil : to = mail.To.charseted
mail.Subject.nil? ? subject = nil : subject = mail.Subject.charseted mail.Subject.nil? ? subject = nil : subject = mail.Subject.charseted
#logger.custom('subject',mail.Subject.encoded)
#logger.custom('subject',subject)
#logger.custom('mail',mail.inspect) #logger.custom('mail',mail.inspect)
create( create(

View file

@ -45,7 +45,7 @@ module Mail
class Field class Field
def charseted def charseted
begin begin
if encoded =~ /\=\?([\w\-]+)\?/ if value =~ /\=\?([\w\-]+)\?/
source_charset = $1 source_charset = $1
if source_charset.upcase == 'UTF-8' if source_charset.upcase == 'UTF-8'
return decoded return decoded
@ -63,7 +63,7 @@ module Mail
class Address class Address
def charseted def charseted
begin begin
if encoded =~ /\=\?([\w\-]+)\?/ if value =~ /\=\?([\w\-]+)\?/
source_charset = $1 source_charset = $1
if source_charset.upcase == 'UTF-8' if source_charset.upcase == 'UTF-8'
return decoded return decoded

View file

@ -2,7 +2,7 @@
<span class="title"><%= t(:attachments,:scope=>:message) %></span> <span class="title"><%= t(:attachments,:scope=>:message) %></span>
<% if not @attachments.size.zero? %> <% if not @attachments.size.zero? %>
<% trclass = :even %> <% trclass = :even %>
<table> <table class="table">
<% @attachments.each do |a| %> <% @attachments.each do |a| %>
<tr class="<%= trclass.to_s %>"> <tr class="<%= trclass.to_s %>">
<%= render :partial => 'messages/file_attach', :object => a %> <%= render :partial => 'messages/file_attach', :object => a %>