view work
This commit is contained in:
parent
081bf95ce7
commit
751fae97f3
81
Gemfile.lock
81
Gemfile.lock
|
@ -1,81 +0,0 @@
|
||||||
GEM
|
|
||||||
remote: http://rubygems.org/
|
|
||||||
specs:
|
|
||||||
actionmailer (3.0.9)
|
|
||||||
actionpack (= 3.0.9)
|
|
||||||
mail (~> 2.2.19)
|
|
||||||
actionpack (3.0.9)
|
|
||||||
activemodel (= 3.0.9)
|
|
||||||
activesupport (= 3.0.9)
|
|
||||||
builder (~> 2.1.2)
|
|
||||||
erubis (>= 2.6.6)
|
|
||||||
i18n (~> 0.5.0)
|
|
||||||
rack (~> 1.2.1)
|
|
||||||
rack-mount (~> 0.6.14)
|
|
||||||
rack-test (~> 0.5.7)
|
|
||||||
tzinfo (~> 0.3.23)
|
|
||||||
activemodel (3.0.9)
|
|
||||||
activesupport (= 3.0.9)
|
|
||||||
builder (~> 2.1.2)
|
|
||||||
i18n (~> 0.5.0)
|
|
||||||
activerecord (3.0.9)
|
|
||||||
activemodel (= 3.0.9)
|
|
||||||
activesupport (= 3.0.9)
|
|
||||||
arel (~> 2.0.10)
|
|
||||||
tzinfo (~> 0.3.23)
|
|
||||||
activeresource (3.0.9)
|
|
||||||
activemodel (= 3.0.9)
|
|
||||||
activesupport (= 3.0.9)
|
|
||||||
activesupport (3.0.9)
|
|
||||||
arel (2.0.10)
|
|
||||||
builder (2.1.2)
|
|
||||||
erubis (2.7.0)
|
|
||||||
ezcrypto (0.7.2)
|
|
||||||
i18n (0.5.0)
|
|
||||||
mail (2.2.19)
|
|
||||||
activesupport (>= 2.3.6)
|
|
||||||
i18n (>= 0.4.0)
|
|
||||||
mime-types (~> 1.16)
|
|
||||||
treetop (~> 1.4.8)
|
|
||||||
mime-types (1.16)
|
|
||||||
mysql2 (0.2.7)
|
|
||||||
polyglot (0.3.1)
|
|
||||||
rack (1.2.3)
|
|
||||||
rack-mount (0.6.14)
|
|
||||||
rack (>= 1.0.0)
|
|
||||||
rack-test (0.5.7)
|
|
||||||
rack (>= 1.0)
|
|
||||||
rails (3.0.9)
|
|
||||||
actionmailer (= 3.0.9)
|
|
||||||
actionpack (= 3.0.9)
|
|
||||||
activerecord (= 3.0.9)
|
|
||||||
activeresource (= 3.0.9)
|
|
||||||
activesupport (= 3.0.9)
|
|
||||||
bundler (~> 1.0)
|
|
||||||
railties (= 3.0.9)
|
|
||||||
railties (3.0.9)
|
|
||||||
actionpack (= 3.0.9)
|
|
||||||
activesupport (= 3.0.9)
|
|
||||||
rake (>= 0.8.7)
|
|
||||||
rdoc (~> 3.4)
|
|
||||||
thor (~> 0.14.4)
|
|
||||||
rake (0.9.2)
|
|
||||||
rdoc (3.6.1)
|
|
||||||
themes_for_rails (0.4.2)
|
|
||||||
rails (~> 3.0.0)
|
|
||||||
themes_for_rails
|
|
||||||
thor (0.14.6)
|
|
||||||
treetop (1.4.9)
|
|
||||||
polyglot (>= 0.3.1)
|
|
||||||
tzinfo (0.3.29)
|
|
||||||
will_paginate (3.0.pre4)
|
|
||||||
|
|
||||||
PLATFORMS
|
|
||||||
ruby
|
|
||||||
|
|
||||||
DEPENDENCIES
|
|
||||||
ezcrypto (~> 0.7.2)
|
|
||||||
mysql2 (~> 0.2.7)
|
|
||||||
rails (~> 3.0.7)
|
|
||||||
themes_for_rails
|
|
||||||
will_paginate (~> 3.0.beta)
|
|
|
@ -2,15 +2,16 @@ require 'yaml'
|
||||||
|
|
||||||
class ApplicationController < ActionController::Base
|
class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
#unless config.consider_all_requests_local
|
|
||||||
# #rescue_from ActionController::RoutingError, :with => :route_not_found
|
|
||||||
# rescue_from ActiveRecord::RecordNotFound, :with => :route_not_found
|
|
||||||
#end
|
|
||||||
|
|
||||||
protect_from_forgery
|
protect_from_forgery
|
||||||
before_filter :load_defaults,:current_user,:set_locale
|
before_filter :load_defaults,:current_user,:set_locale
|
||||||
before_filter :plugins_configuration
|
before_filter :plugins_configuration
|
||||||
|
|
||||||
|
rescue_from ActiveRecord::RecordNotFound do
|
||||||
|
logger.custom('record_not_found','exc')
|
||||||
|
reset_session
|
||||||
|
redirect_to :controller=>'user', :action => 'login'
|
||||||
|
end
|
||||||
|
|
||||||
################################# protected section ###########################################
|
################################# protected section ###########################################
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
@ -42,7 +43,7 @@ class ApplicationController < ActionController::Base
|
||||||
def check_current_user
|
def check_current_user
|
||||||
if @current_user.nil?
|
if @current_user.nil?
|
||||||
session["return_to"] = request.fullpath
|
session["return_to"] = request.fullpath
|
||||||
redirect_to :controller=>"user", :action => "login"
|
redirect_to :controller => 'user', :action => 'login'
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -65,9 +66,5 @@ class ApplicationController < ActionController::Base
|
||||||
WillPaginate::ViewHelpers.pagination_options[:next_label] = t(:next_page)
|
WillPaginate::ViewHelpers.pagination_options[:next_label] = t(:next_page)
|
||||||
end
|
end
|
||||||
|
|
||||||
#def route_not_found
|
|
||||||
# render :text => 'What the fuck are you looking for ?', :status => :not_found
|
|
||||||
#end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,8 @@ class FoldersController < ApplicationController
|
||||||
|
|
||||||
before_filter :check_current_user ,:selected_folder
|
before_filter :check_current_user ,:selected_folder
|
||||||
|
|
||||||
before_filter :open_imap_session, :except => [:index,:refresh_status,:show_hide]
|
before_filter :open_imap_session, :except => [:index,:show_hide]
|
||||||
after_filter :close_imap_session, :except => [:index,:refresh_status,:show_hide]
|
after_filter :close_imap_session, :except => [:index,:show_hide]
|
||||||
|
|
||||||
before_filter :get_folders
|
before_filter :get_folders
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ class FoldersController < ApplicationController
|
||||||
render "index"
|
render "index"
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
|
#TODO recreate local copy of folders
|
||||||
if params["parent_folder"].empty?
|
if params["parent_folder"].empty?
|
||||||
@mailbox.create_folder(params[:folder])
|
@mailbox.create_folder(params[:folder])
|
||||||
else
|
else
|
||||||
|
@ -39,10 +40,11 @@ class FoldersController < ApplicationController
|
||||||
render 'index'
|
render 'index'
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
redirect_to :action => 'refresh', :flash => t(:was_created,:scope=>:folder), :type => :notice
|
flash[:notice] = t(:was_created,:scope=>:folder)
|
||||||
|
redirect_to :action => 'index'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# FIXME if you delete folder you should change current folder because if you go to messages/index you got nil
|
|
||||||
def delete
|
def delete
|
||||||
if params["folder"].empty?
|
if params["folder"].empty?
|
||||||
flash[:warning] = t(:to_delete_empty,:scope=>:folder)
|
flash[:warning] = t(:to_delete_empty,:scope=>:folder)
|
||||||
|
@ -59,18 +61,25 @@ class FoldersController < ApplicationController
|
||||||
raise Exception, t(:system_folder)
|
raise Exception, t(:system_folder)
|
||||||
end
|
end
|
||||||
@mailbox.delete_folder(folder.full_name)
|
@mailbox.delete_folder(folder.full_name)
|
||||||
|
logger.custom('c',@current_folder.inspect)
|
||||||
|
logger.custom('f',folder.inspect)
|
||||||
|
if @current_folder.eql? folder
|
||||||
|
session[:selected_folder] = $defaults['mailbox_inbox']
|
||||||
|
end
|
||||||
|
folder.destroy
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
flash[:error] = t(:can_not_delete,:scope=>:folder) + ' (' + e.to_s + ')'
|
flash[:error] = t(:can_not_delete,:scope=>:folder) + ' (' + e.to_s + ')'
|
||||||
render 'index'
|
render 'index'
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
redirect_to :action => 'refresh', :flash => t(:was_deleted,:scope=>:folder), :type => :notice
|
flash[:notice] = t(:was_deleted,:scope=>:folder)
|
||||||
|
redirect_to :action => 'index'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def show_hide
|
def show_hide
|
||||||
|
if !params["folders_to_show"].nil?
|
||||||
@folders.each do |f|
|
@folders.each do |f|
|
||||||
logger.info f.inspect,"\n"
|
|
||||||
if params["folders_to_show"].include?(f.id.to_s)
|
if params["folders_to_show"].include?(f.id.to_s)
|
||||||
f.shown = true
|
f.shown = true
|
||||||
f.save
|
f.save
|
||||||
|
@ -79,6 +88,7 @@ class FoldersController < ApplicationController
|
||||||
f.save
|
f.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
redirect_to :action => 'index'
|
redirect_to :action => 'index'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -88,6 +98,39 @@ class FoldersController < ApplicationController
|
||||||
redirect_to :action => 'index'
|
redirect_to :action => 'index'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def select
|
||||||
|
session[:selected_folder] = params[:id]
|
||||||
|
redirect_to :controller => 'messages', :action => 'index'
|
||||||
|
end
|
||||||
|
|
||||||
|
def refresh_status
|
||||||
|
@folders_shown.each do |f|
|
||||||
|
@mailbox.set_folder(f.full_name)
|
||||||
|
folder_status = @mailbox.status
|
||||||
|
f.update_attributes(:total => folder_status['MESSAGES'], :unseen => folder_status['UNSEEN'])
|
||||||
|
end
|
||||||
|
redirect_to :controller=> 'messages', :action => 'index'
|
||||||
|
end
|
||||||
|
|
||||||
|
def emptybin
|
||||||
|
begin
|
||||||
|
trash_folder = @current_user.folders.find_by_full_name($defaults["mailbox_trash"])
|
||||||
|
@mailbox.set_folder(trash_folder.full_name)
|
||||||
|
trash_folder.messages.each do |m|
|
||||||
|
@mailbox.delete_message(m.uid)
|
||||||
|
end
|
||||||
|
@mailbox.expunge
|
||||||
|
trash_folder.messages.destroy_all
|
||||||
|
trash_folder.update_attributes(:unseen => 0, :total => 0)
|
||||||
|
rescue Exception => e
|
||||||
|
flash[:error] = "#{t(:imap_error)} (#{e.to_s})"
|
||||||
|
end
|
||||||
|
redirect_to :controller => 'messages', :action => 'index'
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
############################################# protected section #######################################
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def get_folders
|
def get_folders
|
||||||
|
|
|
@ -28,4 +28,11 @@ class InternalController < ApplicationController
|
||||||
redirect_to :controller=>'user', :action => 'login'
|
redirect_to :controller=>'user', :action => 'login'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def onlycanlogins
|
||||||
|
reset_session
|
||||||
|
flash[:error] = t(:only_can_logins,:scope=>:user)
|
||||||
|
@current_user = nil
|
||||||
|
redirect_to :controller=>'user', :action => 'login'
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,18 +9,20 @@ class MessagesController < ApplicationController
|
||||||
include ImapMessageModule
|
include ImapMessageModule
|
||||||
include MessagesHelper
|
include MessagesHelper
|
||||||
|
|
||||||
before_filter :check_current_user ,:selected_folder
|
before_filter :check_current_user ,:selected_folder,:get_current_folders
|
||||||
|
|
||||||
before_filter :get_current_folders
|
|
||||||
|
|
||||||
before_filter :open_imap_session, :select_imap_folder
|
before_filter :open_imap_session, :select_imap_folder
|
||||||
after_filter :close_imap_session
|
after_filter :close_imap_session
|
||||||
|
|
||||||
theme :theme_resolver
|
theme :theme_resolver
|
||||||
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
||||||
|
if @current_folder.nil?
|
||||||
|
redirect_to :controller => 'folders', :action => 'index'
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
@messages = []
|
@messages = []
|
||||||
|
|
||||||
folder_status = @mailbox.status
|
folder_status = @mailbox.status
|
||||||
|
@ -45,53 +47,38 @@ class MessagesController < ApplicationController
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def folder
|
|
||||||
session[:selected_folder] = params[:id]
|
|
||||||
redirect_to :action => 'index'
|
|
||||||
end
|
|
||||||
|
|
||||||
def compose
|
def compose
|
||||||
flash[:notice] = 'Not impelented yet'
|
@message = Message.new
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO error when no folders are shown
|
def reply
|
||||||
|
@message = Message.new
|
||||||
def refresh
|
render 'compose'
|
||||||
@folders_shown.each do |f|
|
|
||||||
@mailbox.set_folder(f.full_name)
|
|
||||||
folder_status = @mailbox.status
|
|
||||||
f.update_attributes(:total => folder_status['MESSAGES'], :unseen => folder_status['UNSEEN'])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sendout
|
||||||
|
flash[:notice] = t(:was_sent,:scope => :sendout)
|
||||||
redirect_to :action => 'index'
|
redirect_to :action => 'index'
|
||||||
end
|
end
|
||||||
|
|
||||||
def emptybin
|
def msgops
|
||||||
begin
|
begin
|
||||||
trash_folder = @current_user.folders.find_by_full_name($defaults["mailbox_trash"])
|
if !params["uids"]
|
||||||
@mailbox.set_folder(trash_folder.full_name)
|
flash[:warning] = t(:no_selected,:scope=>:message)
|
||||||
trash_folder.messages.each do |m|
|
elsif params["reply"]
|
||||||
logger.custom('id',m.inspect)
|
redirect_to :action => 'reply', :id => params[:id]
|
||||||
@mailbox.delete_message(m.uid)
|
return
|
||||||
end
|
end
|
||||||
@mailbox.expunge
|
|
||||||
trash_folder.messages.destroy_all
|
|
||||||
trash_folder.update_attributes(:unseen => 0, :total => 0)
|
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
flash[:error] = "#{t(:imap_error)} (#{e.to_s})"
|
flash[:error] = "#{t(:imap_error)} (#{e.to_s})"
|
||||||
end
|
end
|
||||||
redirect_to :action => 'index'
|
redirect_to :action => 'show', :id => params[:id]
|
||||||
end
|
end
|
||||||
|
|
||||||
def ops
|
def ops
|
||||||
begin
|
begin
|
||||||
if !params["uids"]
|
if !params["uids"]
|
||||||
flash[:warning] = t(:no_selected,:scope=>:message)
|
flash[:warning] = t(:no_selected,:scope=>:message)
|
||||||
elsif params["delete"]
|
|
||||||
params["uids"].each do |uid|
|
|
||||||
@mailbox.delete_message(uid)
|
|
||||||
@current_user.messages.find_by_uid(uid).destroy
|
|
||||||
end
|
|
||||||
@current_folder.update_stats
|
|
||||||
elsif params["set_unread"]
|
elsif params["set_unread"]
|
||||||
params["uids"].each do |uid|
|
params["uids"].each do |uid|
|
||||||
@mailbox.set_unread(uid)
|
@mailbox.set_unread(uid)
|
||||||
|
@ -116,7 +103,7 @@ class MessagesController < ApplicationController
|
||||||
if params["dest_folder"].empty?
|
if params["dest_folder"].empty?
|
||||||
flash[:warning] = t(:no_selected,:scope=>:folder)
|
flash[:warning] = t(:no_selected,:scope=>:folder)
|
||||||
else
|
else
|
||||||
dest_folder = find(params["dest_folder"])
|
dest_folder = @current_user.folders.find(params["dest_folder"])
|
||||||
params["uids"].each do |uid|
|
params["uids"].each do |uid|
|
||||||
@mailbox.copy_message(uid,dest_folder.full_name)
|
@mailbox.copy_message(uid,dest_folder.full_name)
|
||||||
message = @current_folder.messages.find_by_uid(uid)
|
message = @current_folder.messages.find_by_uid(uid)
|
||||||
|
@ -151,8 +138,13 @@ class MessagesController < ApplicationController
|
||||||
def show
|
def show
|
||||||
@message = @current_user.messages.find(params[:id])
|
@message = @current_user.messages.find(params[:id])
|
||||||
@message.update_attributes(:unseen => false)
|
@message.update_attributes(:unseen => false)
|
||||||
flash[:notice] = 'Not implemented yet'
|
|
||||||
@body = @mailbox.fetch_body(@message.uid)
|
end
|
||||||
|
|
||||||
|
def body
|
||||||
|
body = @mailbox.fetch_body(params[:id].to_i)
|
||||||
|
@body = "<html><head><title>ala</title><body>#{body}</body></html>"
|
||||||
|
render :text => @body
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,9 +12,11 @@ class UserController < ApplicationController
|
||||||
redirect_to :action => "login"
|
redirect_to :action => "login"
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO make login possible to use only one username
|
|
||||||
|
|
||||||
def authenticate
|
def authenticate
|
||||||
|
if !$defaults["only_can_logins"].include?(params[:user][:email])
|
||||||
|
redirect_to :controller => 'internal', :action => 'onlycanlogins'
|
||||||
|
return false
|
||||||
|
end
|
||||||
user = User.find_by_email(params[:user][:email])
|
user = User.find_by_email(params[:user][:email])
|
||||||
if user.nil?
|
if user.nil?
|
||||||
redirect_to :action => 'unknown' ,:email=> params[:user][:email]
|
redirect_to :action => 'unknown' ,:email=> params[:user][:email]
|
||||||
|
@ -26,7 +28,7 @@ class UserController < ApplicationController
|
||||||
redirect_to(session["return_to"])
|
redirect_to(session["return_to"])
|
||||||
session["return_to"] = nil
|
session["return_to"] = nil
|
||||||
else
|
else
|
||||||
redirect_to :controller=> 'messages', :action=> 'refresh'
|
redirect_to :controller=> 'messages', :action=> 'index'
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,18 +4,16 @@ def form_field(object,field,flabel,example,val)
|
||||||
model_name = eval(object.class.model_name)
|
model_name = eval(object.class.model_name)
|
||||||
html = ""
|
html = ""
|
||||||
html << "<div class=\"group\">"
|
html << "<div class=\"group\">"
|
||||||
if object.errors[field.to_sym]
|
if not object.errors[field.to_sym].empty?
|
||||||
html << "<div class=\"fieldWithErrors\">"
|
html << "<div class=\"fieldWithErrors\">"
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
html << "<label class=\"label\">"
|
html << "<label class=\"label\">"
|
||||||
if flabel.nil?
|
flabel.nil? ? html << model_name.human_attribute_name(field) : html << t(flabel.to_sym)
|
||||||
html << model_name.human_attribute_name(field)
|
|
||||||
else
|
|
||||||
html << t(flabel.to_sym)
|
|
||||||
end
|
|
||||||
html << "</label>"
|
html << "</label>"
|
||||||
if object.errors[field.to_sym]
|
|
||||||
|
if not object.errors[field.to_sym].empty?
|
||||||
html << "<span class=\"error\"> "
|
html << "<span class=\"error\"> "
|
||||||
html << object.errors[field.to_sym].to_s
|
html << object.errors[field.to_sym].to_s
|
||||||
html << "</span>"
|
html << "</span>"
|
||||||
|
@ -25,7 +23,7 @@ def form_field(object,field,flabel,example,val)
|
||||||
html << object.class.name.downcase+"_"+field
|
html << object.class.name.downcase+"_"+field
|
||||||
html << "\""
|
html << "\""
|
||||||
html << " name=\"#{object.class.name.downcase}[#{field}]\""
|
html << " name=\"#{object.class.name.downcase}[#{field}]\""
|
||||||
html << " size=50 type=\"text\" class=\"text_field\" value=\""
|
html << " type=\"text\" class=\"text_field\" value=\""
|
||||||
value = object.instance_eval(field) || val || ""
|
value = object.instance_eval(field) || val || ""
|
||||||
html << value
|
html << value
|
||||||
html << "\"/>"
|
html << "\"/>"
|
||||||
|
@ -38,6 +36,47 @@ def form_field(object,field,flabel,example,val)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def mail_param_view(object,field,value)
|
||||||
|
model_name = eval(object.class.model_name)
|
||||||
|
html = ""
|
||||||
|
html << "<div class=\"group\">"
|
||||||
|
html << "<label class=\"label\">#{model_name.human_attribute_name(field)}: </label>"
|
||||||
|
html << value
|
||||||
|
html << "</div>"
|
||||||
|
html
|
||||||
|
end
|
||||||
|
|
||||||
|
def area_field(object,field,flabel,example,val,cols,rows)
|
||||||
|
model_name = eval(object.class.model_name)
|
||||||
|
html = ""
|
||||||
|
html << "<div class=\"group\">"
|
||||||
|
|
||||||
|
if not object.errors[field.to_sym].empty?
|
||||||
|
html << "<div class=\"fieldWithErrors\">"
|
||||||
|
end
|
||||||
|
|
||||||
|
html << "<label class=\"label\">"
|
||||||
|
flabel.nil? ? html << model_name.human_attribute_name(field) : html << t(flabel.to_sym)
|
||||||
|
html << "</label>"
|
||||||
|
|
||||||
|
if not object.errors[field.to_sym].empty?
|
||||||
|
html << "<span class=\"error\">"
|
||||||
|
html << object.errors[field.to_sym].to_s
|
||||||
|
html << "</span>"
|
||||||
|
html << "</div>"
|
||||||
|
end
|
||||||
|
|
||||||
|
name = object.class.name.downcase + '[' + field + ']'
|
||||||
|
id = object.class.name.downcase+"_"+field
|
||||||
|
value = object.instance_eval(field) || val || ""
|
||||||
|
html << "<textarea id=\"#{id}\" name=\"#{name}\" class=\"text_area\" cols=\"#{cols}\" rows=\"#{rows}\" value=\"#{value}\"></textarea>"
|
||||||
|
|
||||||
|
desc = t(:example) + ": " + example
|
||||||
|
html << "<span class=\"description\">#{desc}</span>"
|
||||||
|
|
||||||
|
html << "</div>"
|
||||||
|
end
|
||||||
|
|
||||||
def form_button(text,image)
|
def form_button(text,image)
|
||||||
html = ""
|
html = ""
|
||||||
html << "<div class=\"group navform wat-cf\">"
|
html << "<div class=\"group navform wat-cf\">"
|
||||||
|
|
|
@ -3,12 +3,12 @@ module FolderHelper
|
||||||
def folder_link(folder)
|
def folder_link(folder)
|
||||||
|
|
||||||
folder.parent.empty? ? name = folder.name : name = folder.parent.gsub(/\./,'#') + "#" + folder.name
|
folder.parent.empty? ? name = folder.name : name = folder.parent.gsub(/\./,'#') + "#" + folder.name
|
||||||
s = link_to folder.name.capitalize, messages_folder_path(:id => name)
|
s = link_to folder.name.capitalize, folders_select_path(:id => name)
|
||||||
|
|
||||||
if folder.full_name.downcase == $defaults["mailbox_trash"].downcase
|
if folder.full_name.downcase == $defaults["mailbox_trash"].downcase
|
||||||
if not folder.total.zero?
|
if not folder.total.zero?
|
||||||
s <<' ('
|
s <<' ('
|
||||||
s << link_to(t(:emptybin,:scope=>:folder),messages_emptybin_path)
|
s << link_to(t(:emptybin,:scope=>:folder),folders_emptybin_path)
|
||||||
s << ')'
|
s << ')'
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|
|
@ -18,6 +18,13 @@ module MessagesHelper
|
||||||
ImapMessageModule::IMAPAddress.parse(addr).friendly
|
ImapMessageModule::IMAPAddress.parse(addr).friendly
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def show_address_formatter(addr)
|
||||||
|
html = ""
|
||||||
|
fs = addr.split(/#/)
|
||||||
|
fs[0].size.zero? ? html << h("<")+fs[1]+h("@")+fs[2]+h(">") : html << fs[0]+h(" <")+fs[1]+h("@")+fs[2]+h(">")
|
||||||
|
html
|
||||||
|
end
|
||||||
|
|
||||||
def subject_formatter(message)
|
def subject_formatter(message)
|
||||||
if message.subject.size.zero?
|
if message.subject.size.zero?
|
||||||
s = t(:no_subject,:scope=>:message)
|
s = t(:no_subject,:scope=>:message)
|
||||||
|
|
|
@ -40,6 +40,9 @@ class Folder < ActiveRecord::Base
|
||||||
def check_fill_params
|
def check_fill_params
|
||||||
self.total.nil? ? self.total = 0 : self.total
|
self.total.nil? ? self.total = 0 : self.total
|
||||||
self.unseen.nil? ? self.unseen = 0 : self.unseen
|
self.unseen.nil? ? self.unseen = 0 : self.unseen
|
||||||
|
self.parent.nil? ? self.parent = "" : self.parent
|
||||||
|
self.haschildren.nil? ? self.haschildren = false : self.haschildren
|
||||||
|
self.delim.nil? ? self.delim = "." : self.delim
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.createBulk(user,imapFolders)
|
def self.createBulk(user,imapFolders)
|
||||||
|
|
|
@ -2,6 +2,8 @@ class Message < ActiveRecord::Base
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
belongs_to :folder
|
belongs_to :folder
|
||||||
|
|
||||||
|
attr_accessor :body
|
||||||
|
|
||||||
def self.getPageForUser(user,folder,page,sort_field,sort_dir)
|
def self.getPageForUser(user,folder,page,sort_field,sort_dir)
|
||||||
|
|
||||||
order = 'date desc'
|
order = 'date desc'
|
||||||
|
@ -22,7 +24,7 @@ class Message < ActiveRecord::Base
|
||||||
:msg_id => mess.message_id,
|
:msg_id => mess.message_id,
|
||||||
:uid => mess.uid,
|
:uid => mess.uid,
|
||||||
:from_addr => mess.from_to_db,
|
:from_addr => mess.from_to_db,
|
||||||
:to_addr => mess.to,
|
:to_addr => mess.to_to_db,
|
||||||
:subject => mess.subject,
|
:subject => mess.subject,
|
||||||
:content_type => mess.content_type,
|
:content_type => mess.content_type,
|
||||||
:date => mess.date,
|
:date => mess.date,
|
||||||
|
|
|
@ -35,3 +35,4 @@ mailbox_trash: INBOX.Trash
|
||||||
mailbox_sent: INBOX.sent
|
mailbox_sent: INBOX.sent
|
||||||
mailbox_drafts: INBOX.drafts
|
mailbox_drafts: INBOX.drafts
|
||||||
|
|
||||||
|
only_can_logins: [login]
|
||||||
|
|
|
@ -28,6 +28,7 @@ pl:
|
||||||
subject: Temat
|
subject: Temat
|
||||||
size: Rozmiar
|
size: Rozmiar
|
||||||
date: Data
|
date: Data
|
||||||
|
body: Treść
|
||||||
user:
|
user:
|
||||||
email: E-mail
|
email: E-mail
|
||||||
password: Hasło
|
password: Hasło
|
||||||
|
@ -40,7 +41,7 @@ pl:
|
||||||
compose_to_selected: Napisz do wybranych
|
compose_to_selected: Napisz do wybranych
|
||||||
delete_selected: Usuń wybrane
|
delete_selected: Usuń wybrane
|
||||||
modifying: Modyfikacja kontaktu
|
modifying: Modyfikacja kontaktu
|
||||||
creating_new: Tworzenie nowego kontaktu
|
creating_new: Nowy kontakt
|
||||||
create_new: Utwórz nowy kontakt
|
create_new: Utwórz nowy kontakt
|
||||||
contacts: Kontakty
|
contacts: Kontakty
|
||||||
contact: Kontakt
|
contact: Kontakt
|
||||||
|
@ -55,7 +56,7 @@ pl:
|
||||||
|
|
||||||
folder:
|
folder:
|
||||||
folders: Foldery
|
folders: Foldery
|
||||||
no_shown: Żadnych pokazanych folderów
|
no_shown: Nie prezentowany jest żaden folder. Skonfiguruj widok folderów w zakładce
|
||||||
parent: Folder nadrzędny
|
parent: Folder nadrzędny
|
||||||
to_create: Folder do utworzenia
|
to_create: Folder do utworzenia
|
||||||
to_delete: Folder do usunięcia
|
to_delete: Folder do usunięcia
|
||||||
|
@ -84,6 +85,16 @@ pl:
|
||||||
|
|
||||||
compose:
|
compose:
|
||||||
compose: Nowa wiadomość
|
compose: Nowa wiadomość
|
||||||
|
new_message: Nowa wiadomość
|
||||||
|
not_contain_at: ",jeżeli nie zawiera znaku @, adres będzie szukany w kontaktach"
|
||||||
|
subject_of_the_message: Temat wiadomości
|
||||||
|
write_your_message_here: Tu wpisz swoją wiadomość
|
||||||
|
|
||||||
|
sendout:
|
||||||
|
was_sent: Wiadomość została wysłana
|
||||||
|
|
||||||
|
show:
|
||||||
|
replay_to: Odpowiedz
|
||||||
|
|
||||||
user:
|
user:
|
||||||
login_failure: Nieudane logowanie. Podano błędny e-mail lub hasło.
|
login_failure: Nieudane logowanie. Podano błędny e-mail lub hasło.
|
||||||
|
@ -96,6 +107,7 @@ pl:
|
||||||
unknown_setup: Idź do strony konfiguracyjnej i skonfiguruj swój dostęp
|
unknown_setup: Idź do strony konfiguracyjnej i skonfiguruj swój dostęp
|
||||||
setup: Konfiguracja
|
setup: Konfiguracja
|
||||||
login: Logowanie
|
login: Logowanie
|
||||||
|
only_can_logins: Podany identyfikator użytkownika nie uprawnia do korzystania z aplikacji
|
||||||
|
|
||||||
must_be_unique: musi być unikalny
|
must_be_unique: musi być unikalny
|
||||||
some_add_info: jakieś dodatkowe informacje
|
some_add_info: jakieś dodatkowe informacje
|
||||||
|
|
|
@ -8,26 +8,34 @@ Mailr::Application.routes.draw do
|
||||||
|
|
||||||
|
|
||||||
#resources :folders
|
#resources :folders
|
||||||
get "folders/index"
|
match "folders/index" => 'folders#index', :as => :folders
|
||||||
post "folders/create"
|
post "folders/create"
|
||||||
post "folders/delete"
|
post "folders/delete"
|
||||||
post "folders/show_hide"
|
post "folders/show_hide"
|
||||||
get "folders/refresh"
|
get "folders/refresh"
|
||||||
|
get "folders/refresh_status"
|
||||||
post "folders/refresh"
|
post "folders/refresh"
|
||||||
|
match "folders/select/:id" => 'folders#select', :as => :folders_select
|
||||||
|
get "folders/emptybin"
|
||||||
|
|
||||||
get "internal/error"
|
get "internal/error"
|
||||||
get "internal/imaperror"
|
get "internal/imaperror"
|
||||||
get "internal/loginfailure"
|
get "internal/loginfailure"
|
||||||
|
get "internal/onlycanlogins"
|
||||||
|
|
||||||
root :to => "messages#index"
|
root :to => "messages#index"
|
||||||
|
#get "messages/refresh_status"
|
||||||
|
#get "messages/emptybin"
|
||||||
|
#match "messages/select/:id" => 'messages#select', :as => :messages_select
|
||||||
get "messages/index"
|
get "messages/index"
|
||||||
get "messages/refresh"
|
#match 'messages/folder/:id' => 'messages#folder', :as => :messages_folder
|
||||||
match 'messages/folder/:id' => 'messages#folder', :as => :messages_folder
|
|
||||||
post "messages/ops"
|
post "messages/ops"
|
||||||
get "messages/compose"
|
post "messages/msgops"
|
||||||
get "messages/refresh"
|
match "messages/compose" => 'messages#compose'
|
||||||
|
match "messages/reply/:id" => 'messages#reply'
|
||||||
|
post "messages/sendout"
|
||||||
match "messages/show/:id" => 'messages#show'
|
match "messages/show/:id" => 'messages#show'
|
||||||
get "messages/emptybin"
|
match "messages/body/:id" => 'messages#body' , :as => :messages_body
|
||||||
|
|
||||||
get "user/logout"
|
get "user/logout"
|
||||||
post "user/authenticate"
|
post "user/authenticate"
|
||||||
|
|
|
@ -12,11 +12,12 @@ class IMAPMailbox
|
||||||
attr_accessor :sfolder
|
attr_accessor :sfolder
|
||||||
attr_accessor :logger
|
attr_accessor :logger
|
||||||
|
|
||||||
def initialize(logger)
|
def initialize(logger,debug)
|
||||||
@sfolder = ''
|
@sfolder = ''
|
||||||
@folders = {}
|
@folders = {}
|
||||||
@connected = false
|
@connected = false
|
||||||
@logger = logger
|
@logger = logger
|
||||||
|
Net::IMAP.debug = debug
|
||||||
end
|
end
|
||||||
|
|
||||||
def connect(server,username,password)
|
def connect(server,username,password)
|
||||||
|
|
|
@ -57,7 +57,6 @@ class IMAPMessage
|
||||||
envelope = message.attr['ENVELOPE']
|
envelope = message.attr['ENVELOPE']
|
||||||
m.envelope = envelope
|
m.envelope = envelope
|
||||||
m.message_id = envelope.message_id
|
m.message_id = envelope.message_id
|
||||||
m.to = envelope.to
|
|
||||||
m.date = envelope.date
|
m.date = envelope.date
|
||||||
m.subject = envelope.subject
|
m.subject = envelope.subject
|
||||||
m.uid = message.attr['UID']
|
m.uid = message.attr['UID']
|
||||||
|
@ -66,6 +65,7 @@ class IMAPMessage
|
||||||
m.size = message.attr['RFC822.SIZE']
|
m.size = message.attr['RFC822.SIZE']
|
||||||
m.unseen = !(message.attr['FLAGS'].member? :Seen)
|
m.unseen = !(message.attr['FLAGS'].member? :Seen)
|
||||||
m.from = IMAPAddress.from_address(envelope.from[0])
|
m.from = IMAPAddress.from_address(envelope.from[0])
|
||||||
|
m.to = IMAPAddress.from_address(envelope.to[0])
|
||||||
m
|
m
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -77,6 +77,10 @@ class IMAPMessage
|
||||||
from.to_db
|
from.to_db
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_to_db
|
||||||
|
to.to_db
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ module ImapSessionModule
|
||||||
|
|
||||||
def open_imap_session
|
def open_imap_session
|
||||||
begin
|
begin
|
||||||
@mailbox ||= ImapMailboxModule::IMAPMailbox.new(logger)
|
@mailbox ||= ImapMailboxModule::IMAPMailbox.new(logger,$defaults["imap_debug"])
|
||||||
@mailbox.connect(@current_user.servers.primary,@current_user.email, @current_user.get_cached_password(session))
|
@mailbox.connect(@current_user.servers.primary,@current_user.email, @current_user.get_cached_password(session))
|
||||||
rescue Exception => ex
|
rescue Exception => ex
|
||||||
redirect_to :controller => 'internal', :action => 'loginfailure'
|
redirect_to :controller => 'internal', :action => 'loginfailure'
|
||||||
|
|
|
@ -356,11 +356,11 @@ tr.notseen td.subject {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
input,select {
|
input,select,textarea {
|
||||||
background-color: #EFF3E4;
|
background-color: #EFF3E4;
|
||||||
border: 1px solid #5E634E;
|
border: 1px solid #5E634E;
|
||||||
color: #black;
|
color: #black;
|
||||||
margin: 5px 0 0;
|
margin: 3px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#footer {
|
#footer {
|
||||||
|
@ -422,10 +422,33 @@ div.params {
|
||||||
}
|
}
|
||||||
|
|
||||||
div.params div.group {
|
div.params div.group {
|
||||||
margin-bottom:5px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.params div.group div.fieldWithErrors label.label {
|
div.msg_header label {
|
||||||
|
display: inline;
|
||||||
|
float: left;
|
||||||
|
text-align: right;
|
||||||
|
width: 100px;
|
||||||
|
margin-right: 10px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.msg_header div.group {
|
||||||
|
margin: 10px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.msg_header {
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
iframe {
|
||||||
|
width: 937px;
|
||||||
|
height: 600px;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.params div.group div.fieldWithErrors label.label, div.params div.group label.label{
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
@ -444,3 +467,4 @@ div.params div.group .description {
|
||||||
div.params div.group .fieldWithErrors .error {
|
div.params div.group .fieldWithErrors .error {
|
||||||
color: red;
|
color: red;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<div class="block">
|
<div class="block">
|
||||||
<h3><%=t(:folders,:scope=>:folder) %> <%= link_to t(:refresh), messages_refresh_path, :class=>'minor' %></h3>
|
<h3><%=t(:folders,:scope=>:folder) %> <%= link_to t(:refresh), folders_refresh_status_path, :class=>'minor' %></h3>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<% if @folders_shown.size.zero? %>
|
<% if @folders_shown.nil? or @folders_shown.size.zero? %>
|
||||||
<p><%= t(:no_shown,:scope=>:folder) %></p>
|
<p><%= t(:no_shown,:scope=>:folder) %> <%= link_to t(:folders,:scope=>:folder), folders_path %></p>
|
||||||
<% else %>
|
<% else %>
|
||||||
<ul class="navigation folders">
|
<ul class="navigation folders">
|
||||||
<% @folders_shown.each do |folder| -%>
|
<% @folders_shown.each do |folder| -%>
|
||||||
|
|
3
themes/olive/views/messages/_body.html.erb
Executable file
3
themes/olive/views/messages/_body.html.erb
Executable file
|
@ -0,0 +1,3 @@
|
||||||
|
<iframe frameborder="0" src="<%= messages_body_path(@message.uid) %>">
|
||||||
|
</iframe>
|
||||||
|
|
9
themes/olive/views/messages/_header.html.erb
Executable file
9
themes/olive/views/messages/_header.html.erb
Executable file
|
@ -0,0 +1,9 @@
|
||||||
|
<div class="msg_header">
|
||||||
|
<%= raw mail_param_view(@message,"from_addr",show_address_formatter(@message.from_addr)) %>
|
||||||
|
<%= raw mail_param_view(@message,"to_addr",show_address_formatter(@message.to_addr)) %>
|
||||||
|
<%= raw mail_param_view(@message,"subject",@message.subject) %>
|
||||||
|
<%= raw mail_param_view(@message,"date",date_formatter(@message.date)) %>
|
||||||
|
<%= hidden_field_tag 'uids[]', @message.uid %>
|
||||||
|
<%= hidden_field_tag 'id', @message.id %>
|
||||||
|
<%= hidden_field_tag 'source', 'show' %>
|
||||||
|
</div>
|
8
themes/olive/views/messages/_msg_ops.html.erb
Executable file
8
themes/olive/views/messages/_msg_ops.html.erb
Executable file
|
@ -0,0 +1,8 @@
|
||||||
|
<div id="ops" class="ops">
|
||||||
|
<%= submit_tag(t(:copy), :name=> 'copy')%>
|
||||||
|
<%= submit_tag(t(:move), :name=>'move')%>
|
||||||
|
<%= t(:to_folder,:scope=>:folder) %>
|
||||||
|
<%= raw simple_select_for_folders("","dest_folder",@folders_shown,true) %><br/>
|
||||||
|
<%= submit_tag(t(:delete), :name=>'trash')%>
|
||||||
|
<%= submit_tag(t(:replay_to,:scope => :show), :name=>'reply')%>
|
||||||
|
</div>
|
6
themes/olive/views/messages/_new.html.erb
Executable file
6
themes/olive/views/messages/_new.html.erb
Executable file
|
@ -0,0 +1,6 @@
|
||||||
|
<div class="params">
|
||||||
|
<%= raw form_field(@message,"to_addr",nil,"joe@domain.com"+', '+t(:not_contain_at,:scope=>:compose),@message.to_addr) %>
|
||||||
|
<%= 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) %>
|
||||||
|
</div>
|
||||||
|
<%= raw form_button('send','tick.png') %>
|
|
@ -10,9 +10,12 @@
|
||||||
<div class="secondary-navigation">
|
<div class="secondary-navigation">
|
||||||
<%= raw main_navigation(:compose) %>
|
<%= raw main_navigation(:compose) %>
|
||||||
</div>
|
</div>
|
||||||
<div class="content"><%= params.inspect %>
|
<div class="content">
|
||||||
<%= form_tag(messages_ops_path)%>
|
<h2><%= t(:new_message,:scope=>:compose) %></h2>
|
||||||
|
<%= form_tag(messages_sendout_path)%>
|
||||||
|
<div class="inner">
|
||||||
|
<%= render :partial => 'new' %>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -11,8 +11,11 @@
|
||||||
<%= raw main_navigation(:show) %>
|
<%= raw main_navigation(:show) %>
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<p><%= @message.inspect %></p>
|
<%= form_tag(messages_msgops_path)%>
|
||||||
<p><%= @body.inspect %></p>
|
<%= render :partial => 'header' %>
|
||||||
|
<%= render :partial => 'msg_ops' %>
|
||||||
|
<%= render :partial => 'body' %>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue