some fixes
This commit is contained in:
parent
a1352b9402
commit
639d223629
|
@ -5,15 +5,8 @@ class ApplicationController < ActionController::Base
|
|||
protect_from_forgery
|
||||
|
||||
before_filter :load_defaults,:current_user,:set_locale
|
||||
|
||||
before_filter :plugins_configuration
|
||||
|
||||
# rescue_from ActiveRecord::RecordNotFound do
|
||||
# logger.custom('record_not_found','exc')
|
||||
# reset_session
|
||||
# redirect_to :controller=>'user', :action => 'login'
|
||||
# end
|
||||
|
||||
def load_defaults
|
||||
$defaults ||= YAML::load(File.open(Rails.root.join('config','defaults.yml')))
|
||||
end
|
||||
|
@ -68,44 +61,6 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
end
|
||||
|
||||
def self.decode_quoted(text,unknown_charset = $defaults["msg_unknown_charset"])
|
||||
begin
|
||||
if text.match(/\=\?.+\?\w\?.+\?\=/).nil?
|
||||
after = Iconv.conv('UTF-8',unknown_charset,text)
|
||||
#after = text
|
||||
else
|
||||
|
||||
# FIXME support multiple showing of =?xxx?=
|
||||
|
||||
|
||||
after = text
|
||||
match = text.match(/\=\?.+\?\w\?.+\?\=/).to_s
|
||||
f = match.split(/\?/)
|
||||
case f[2].downcase
|
||||
when 'q':
|
||||
replace = f[3].gsub(/_/," ").unpack("M").first
|
||||
when 'b':
|
||||
replace = f[3].gsub(/_/," ").unpack("m").first
|
||||
else
|
||||
replace = match
|
||||
end
|
||||
match.gsub!(/\?/,'\?')
|
||||
match.gsub!(/\)/,'\)')
|
||||
after = text.gsub(/#{match}/,replace)
|
||||
|
||||
if f[1].downcase != 'utf-8'
|
||||
after = Iconv.conv('UTF-8',f[1],after)
|
||||
end
|
||||
|
||||
end
|
||||
#logger.custom('after',after)
|
||||
return after
|
||||
rescue Exception => e
|
||||
logger.error("Class Message: #{e.to_s}: T: #{text} M: #{match} R: #{replace} A: #{after}")
|
||||
return text
|
||||
end
|
||||
end
|
||||
|
||||
def prepare_compose_buttons
|
||||
@buttons = []
|
||||
@buttons << {:text => 'send',:scope=>:compose,:image => 'email.png'}
|
||||
|
@ -122,7 +77,6 @@ class ApplicationController < ActionController::Base
|
|||
files.each do |f|
|
||||
@attachments << {:name => File.basename(f).gsub!(/#{@current_user.username}_/,"") , :size => File.stat(f).size }
|
||||
end
|
||||
logger.custom('a',@attachments.inspect)
|
||||
end
|
||||
|
||||
def get_system_folders
|
||||
|
|
|
@ -65,7 +65,9 @@ class MessagesController < ApplicationController
|
|||
end
|
||||
|
||||
def compose
|
||||
#before_filter
|
||||
#before filter
|
||||
@operation = :new
|
||||
logger.custom('m',@message.inspect)
|
||||
end
|
||||
|
||||
def show
|
||||
|
@ -82,7 +84,7 @@ class MessagesController < ApplicationController
|
|||
@plain_header = mail.header.to_s
|
||||
|
||||
|
||||
# FIXME missing fields
|
||||
# FIXME missing fields and support arrays
|
||||
#@from = mail.From.addrs.presence
|
||||
#@to = mail.To.addrs.presence
|
||||
@from = @message.from_addr
|
||||
|
|
|
@ -53,7 +53,7 @@ class MessagesOpsController < ApplicationController
|
|||
move
|
||||
end
|
||||
rescue Exception => e
|
||||
flash[:error] = "#{t(:imap_error)} (#{e.to_s})"
|
||||
flash[:error] = "#{t(:imap_error,:scope=>:internal)} (#{e.to_s})"
|
||||
end
|
||||
redirect_to :controller => 'messages', :action => 'index'
|
||||
end
|
||||
|
@ -124,11 +124,17 @@ class MessagesOpsController < ApplicationController
|
|||
end
|
||||
|
||||
def upload
|
||||
#FIXME check if uploads directory exists
|
||||
@operation = :upload
|
||||
create_message_with_params
|
||||
if not params[:upload]
|
||||
flash[:error] = t(:no_attach,:scope=>:compose)
|
||||
else
|
||||
name = params[:upload][:datafile].original_filename
|
||||
upload_dir = $defaults["msg_upload_dir"]
|
||||
path = File.join(upload_dir, @current_user.username + "_" + name)
|
||||
File.open(path, "wb") { |f| f.write(params[:upload][:datafile].read) }
|
||||
create_message_with_params
|
||||
end
|
||||
render 'messages/compose'
|
||||
end
|
||||
|
||||
|
@ -166,12 +172,15 @@ class MessagesOpsController < ApplicationController
|
|||
|
||||
def sendout_or_save
|
||||
|
||||
#FIXME check if domain is set
|
||||
|
||||
if params[:delete_marked] and params[:files]
|
||||
params[:files].each do |filename|
|
||||
path = File.join(Rails.root,$defaults["msg_upload_dir"],@current_user.username + "_" +filename)
|
||||
File.delete(path) if File.exist?(path)
|
||||
end
|
||||
create_message_with_params
|
||||
@operation = :new
|
||||
render 'messages/compose'
|
||||
return
|
||||
end
|
||||
|
@ -193,6 +202,7 @@ class MessagesOpsController < ApplicationController
|
|||
|
||||
if smtp_server.nil?
|
||||
flash[:error] = t(:not_configured_smtp,:scope => :compose)
|
||||
@operation = :new
|
||||
render 'messages/compose'
|
||||
return
|
||||
end
|
||||
|
@ -245,13 +255,11 @@ class MessagesOpsController < ApplicationController
|
|||
protected
|
||||
|
||||
def edit
|
||||
|
||||
old_message = @current_user.messages.find(params[:id].first)
|
||||
@message = Message.new
|
||||
@message.to_addr = address_formatter(old_message.to_addr,:raw)
|
||||
@message.to_addr = old_message.to_addr
|
||||
@message.subject = old_message.subject
|
||||
imap_message = @mailbox.fetch_body(old_message.uid)
|
||||
@edit = true
|
||||
mail = Mail.new(imap_message)
|
||||
if mail.multipart?
|
||||
@message.body = mail.text_part.decoded_and_charseted
|
||||
|
@ -259,14 +267,15 @@ class MessagesOpsController < ApplicationController
|
|||
@message.body = mail.decoded_and_charseted
|
||||
end
|
||||
@attachments = []
|
||||
@operation = :edit
|
||||
render 'messages/compose'
|
||||
end
|
||||
|
||||
def reply
|
||||
old_message = @current_user.messages.find(params[:uids].first)
|
||||
@message = Message.new
|
||||
@message.to_addr = address_formatter(old_message.from_addr,:raw)
|
||||
@message.subject = t(:reply_string,:scope=>:show) + old_message.subject
|
||||
@message.to_addr = old_message.from_addr
|
||||
@message.subject = old_message.subject
|
||||
|
||||
imap_message = @mailbox.fetch_body(old_message.uid)
|
||||
mail = Mail.new(imap_message)
|
||||
|
@ -276,6 +285,7 @@ class MessagesOpsController < ApplicationController
|
|||
@message.body = mail.decoded_and_charseted.gsub(/<\/?[^>]*>/, "")
|
||||
end
|
||||
@attachments = []
|
||||
@operation = :reply
|
||||
render 'messages/compose'
|
||||
end
|
||||
|
||||
|
|
|
@ -26,11 +26,11 @@ def form_field(object,field,flabel,example,val)
|
|||
html << "\""
|
||||
html << " name=\"#{object.class.name.downcase}[#{field}]\""
|
||||
html << " type=\"text\" class=\"text_field\" value=\""
|
||||
value = object.instance_eval(field) || val || ""
|
||||
value = val || object.instance_eval(field) || ""
|
||||
html << value
|
||||
html << "\"/>"
|
||||
html << "<span class=\"description\">"
|
||||
html << t(:example)
|
||||
html << t(:example,:scope=>:common)
|
||||
html << ": "
|
||||
html << example
|
||||
html << "</span>"
|
||||
|
@ -70,10 +70,10 @@ def area_field(object,field,flabel,example,val,cols,rows)
|
|||
|
||||
name = object.class.name.downcase + '[' + field + ']'
|
||||
id = object.class.name.downcase+"_"+field
|
||||
value = object.instance_eval(field) || val || ""
|
||||
value = val || object.instance_eval(field) || ""
|
||||
html << "<textarea id=\"#{id}\" name=\"#{name}\" class=\"text_area\" cols=\"#{cols}\" rows=\"#{rows}\">#{value}</textarea>"
|
||||
|
||||
desc = t(:example) + ": " + example
|
||||
desc = t(:example,:scope=>:common) + ": " + example
|
||||
html << "<span class=\"description\">#{desc}</span>"
|
||||
|
||||
html << "</div>"
|
||||
|
|
|
@ -14,12 +14,12 @@ module MessagesHelper
|
|||
date.nil? ? t(:no_date,:scope=>:message) : date.strftime("%Y-%m-%d %H:%M")
|
||||
end
|
||||
|
||||
def address_formatter(addr,mode)
|
||||
def address_formatter(addr,op)
|
||||
s = ""
|
||||
return s if addr.nil?
|
||||
length = $defaults["msg_address_length"].to_i
|
||||
|
||||
case mode
|
||||
case op
|
||||
when :index
|
||||
fs = addr.gsub(/\"/,"").split(/</)
|
||||
fs[0].size.zero? ? s = fs[1] : s = fs[0]
|
||||
|
@ -27,30 +27,32 @@ module MessagesHelper
|
|||
return h(s)
|
||||
when :show
|
||||
#addr = addr[0].charseted.gsub(/\"/,"")
|
||||
return h(addr)
|
||||
return h(addr.gsub(/\"/,""))
|
||||
when :raw
|
||||
#fs = addr.gsub(/\"/,"").split(/</)
|
||||
#fs[0].size.zero? ? s = fs[1] : s << fs[0] + " <" + fs[1] + ">"
|
||||
s = h(addr)
|
||||
return s
|
||||
when :reply
|
||||
return h(addr)
|
||||
end
|
||||
end
|
||||
|
||||
# def show_addr_formatter(addrs)
|
||||
# return h(force_charset(addrs[0].decoded))
|
||||
# end
|
||||
def body_formatter(body,op)
|
||||
case op
|
||||
when :reply
|
||||
s = "\n\n\n"
|
||||
body.gsub(/^\s+/,"").split(/\n/).each do |line|
|
||||
s += ">" + line + "\n"
|
||||
end
|
||||
s
|
||||
when :edit
|
||||
return body
|
||||
end
|
||||
end
|
||||
|
||||
# def show_subject_formatter(subject)
|
||||
# if subject.to_s.nil?
|
||||
# t(:no_subject,:scope=>:message)
|
||||
# else
|
||||
# return h(force_charset(subject.decoded))
|
||||
# end
|
||||
# end
|
||||
|
||||
|
||||
def subject_formatter(message,mode)
|
||||
case mode
|
||||
def subject_formatter(message,op)
|
||||
case op
|
||||
when :index
|
||||
if message.subject.nil? or message.subject.size.zero?
|
||||
s = t(:no_subject,:scope=>:message)
|
||||
|
@ -65,6 +67,12 @@ module MessagesHelper
|
|||
else
|
||||
message.subject
|
||||
end
|
||||
when :reply
|
||||
if message.nil? or message.size.zero?
|
||||
t(:reply_string,:scope=>:show)
|
||||
else
|
||||
t(:reply_string,:scope=>:show) + " " + message
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -36,10 +36,11 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def full_address
|
||||
d = domain.presence || ""
|
||||
if email =~ /\@/
|
||||
email
|
||||
else
|
||||
email + "@" + domain
|
||||
email + "@" + d
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -43,4 +43,4 @@ session_password: asDD3s2@sAdc983#
|
|||
mailbox_max_parent_folder_depth: 3
|
||||
|
||||
# array of logins which only can login to application, comment it to allow everyone to login
|
||||
only_can_logins: [wtodryk]
|
||||
only_can_logins: [soldier]
|
||||
|
|
|
@ -132,13 +132,13 @@ pl:
|
|||
write_your_message_here: Tu wpisz swoją wiadomość
|
||||
was_sent: Wiadomość została wysłana
|
||||
was_saved: Wiadomość została zapisana w katalogu roboczym
|
||||
|
||||
not_configured_smtp: Brak konfiguracji SMTP
|
||||
select_file: Wybierz plik
|
||||
delete_marked: Usuń zaznaczone
|
||||
send_file: Wyślij plik
|
||||
send: Wyślij
|
||||
save_as_draft: Zapisz w katalogu roboczym
|
||||
no_attach: Nie wybrano żadnego pliku
|
||||
|
||||
show:
|
||||
reply: Odpowiedz
|
||||
|
|
BIN
themes/olive/images/key.png
Executable file
BIN
themes/olive/images/key.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
|
@ -1,9 +1,6 @@
|
|||
<div class="msg_header">
|
||||
<%= raw show_param_view(@message,"from_addr",address_formatter(@from,:show)) %>
|
||||
<%= raw show_param_view(@message,"to_addr",address_formatter(@to,:show)) %>
|
||||
<% if @to.size > 1 %>
|
||||
<%= raw show_param_view(@message,"to_addr","To dodatkowe jest") %>
|
||||
<% end %>
|
||||
<% if not @cc.nil? %>
|
||||
<%= raw show_param_view(@message,"cc_addr","CC jest") %>
|
||||
<% end %>
|
||||
|
|
|
@ -1,11 +1,25 @@
|
|||
<%= form_tag(sendout_or_save_path)%>
|
||||
<div class="params">
|
||||
<%= raw form_field(@message,"to_addr",nil,"joe@domain.com"+', '+t(:not_contain_at,:scope=>:compose),@message.to_addr) %>
|
||||
<% if not @reply.nil? %>
|
||||
<% @message.subject = t(:reply_string,:scope=>:compose) + @message.subject %>
|
||||
<% end %>
|
||||
<%= raw form_field(@message,"subject",nil,t(:subject_of_the_message,:scope=>:compose),@message.subject) %>
|
||||
<%= raw area_field(@message,"body",nil,t(:write_your_message_here,:scope=>:compose),@message.body,80,20) %>
|
||||
<%= raw form_field( @message,
|
||||
"to_addr",
|
||||
nil,
|
||||
"joe@domain.com"+', '+ t(:not_contain_at,:scope=>:compose),
|
||||
address_formatter(@message.to_addr,@operation)
|
||||
) %>
|
||||
<%= raw form_field( @message,
|
||||
"subject",
|
||||
nil,
|
||||
t(:subject_of_the_message,:scope=>:compose),
|
||||
subject_formatter(@message.subject,@operation)
|
||||
) %>
|
||||
<%= raw area_field( @message,
|
||||
"body",
|
||||
nil,
|
||||
t(:write_your_message_here,:scope=>:compose),
|
||||
body_formatter(@message.body,@operation),
|
||||
80,
|
||||
20
|
||||
) %>
|
||||
</div>
|
||||
<%= raw group_action(@buttons) %>
|
||||
<%= render :partial=> 'messages/file_attachs' %>
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
<div class="group navform wat-cf">
|
||||
<div class="right">
|
||||
<button class="button" type="submit">
|
||||
<img src="<%= current_theme_image_path('key.png')%>" alt="login" /> <%= t :log_in %>
|
||||
<img src="<%= current_theme_image_path('key.png')%>" alt="login" /> <%= t(:log_in,:scope=>:common) %>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue