message index
This commit is contained in:
parent
53fd7ad6ee
commit
f5c796f76b
|
@ -37,9 +37,9 @@ class WebmailController < ApplicationController
|
||||||
|
|
||||||
def manage_folders
|
def manage_folders
|
||||||
if operation_param == _('Add folder')
|
if operation_param == _('Add folder')
|
||||||
@mailbox.create_folder(CDF::CONFIG[:mail_inbox]+"."+@params["folder_name"])
|
@mailbox.create_folder(CDF::CONFIG[:mail_inbox]+"."+params["folder_name"])
|
||||||
elsif operation_param == _('(Delete)')
|
elsif operation_param == _('(Delete)')
|
||||||
@mailbox.delete_folder(@params["folder_name"])
|
@mailbox.delete_folder(params["folder_name"])
|
||||||
elsif operation_param == _('(Subscribe)')
|
elsif operation_param == _('(Subscribe)')
|
||||||
elsif operation_param == _('(Select)')
|
elsif operation_param == _('(Select)')
|
||||||
end
|
end
|
||||||
|
@ -47,15 +47,15 @@ class WebmailController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def messages
|
def messages
|
||||||
@session["return_to"] = nil
|
session["return_to"] = nil
|
||||||
@search_field = @params['search_field']
|
@search_field = params['search_field']
|
||||||
@search_value = @params['search_value']
|
@search_value = params['search_value']
|
||||||
|
|
||||||
# handle sorting - tsort session field contains last reverse or no for field
|
# handle sorting - tsort session field contains last reverse or no for field
|
||||||
# and lsort - last sort field
|
# and lsort - last sort field
|
||||||
if @session['tsort'].nil? or @session['lsort'].nil?
|
if session['tsort'].nil? or session['lsort'].nil?
|
||||||
@session['lsort'] = "DATE"
|
session['lsort'] = "DATE"
|
||||||
@session['tsort'] = {"DATE" => true, "FROM" => true, "SUBJECT" => true, "TO" => false}
|
session['tsort'] = {"DATE" => true, "FROM" => true, "SUBJECT" => true, "TO" => false}
|
||||||
end
|
end
|
||||||
|
|
||||||
case operation_param
|
case operation_param
|
||||||
|
@ -78,27 +78,27 @@ class WebmailController < ApplicationController
|
||||||
when _('mark unread') # mark as unread
|
when _('mark unread') # mark as unread
|
||||||
messages_param.each { |msg_id, bool| msg = folder.mark_unread(msg_id.to_i) if bool == BOOL_ON } if messages_param
|
messages_param.each { |msg_id, bool| msg = folder.mark_unread(msg_id.to_i) if bool == BOOL_ON } if messages_param
|
||||||
when "SORT"
|
when "SORT"
|
||||||
@session['lsort'] = sort_query = @params["scc"]
|
session['lsort'] = sort_query = params["scc"]
|
||||||
@session['tsort'][sort_query] = (@session['tsort'][sort_query]? false : true)
|
session['tsort'][sort_query] = (session['tsort'][sort_query]? false : true)
|
||||||
@search_field, @search_value = @session['search_field'], @session['search_value']
|
@search_field, @search_value = session['search_field'], session['search_value']
|
||||||
when _('Search') # search
|
when _('Search') # search
|
||||||
@session['search_field'] = @search_field
|
session['search_field'] = @search_field
|
||||||
@session['search_value'] = @search_value
|
session['search_value'] = @search_value
|
||||||
when _('Show all') # search
|
when _('Show all') # search
|
||||||
@session['search_field'] = @search_field = nil
|
session['search_field'] = @search_field = nil
|
||||||
@session['search_value'] = @search_value = nil
|
session['search_value'] = @search_value = nil
|
||||||
else
|
else
|
||||||
# get search criteria from session
|
# get search criteria from session
|
||||||
@search_field = @session['search_field']
|
@search_field = session['search_field']
|
||||||
@search_value = @session['search_value']
|
@search_value = session['search_value']
|
||||||
end
|
end
|
||||||
|
|
||||||
sort_query = @session['lsort']
|
sort_query = session['lsort']
|
||||||
reverse_sort = @session['tsort'][sort_query]
|
reverse_sort = session['tsort'][sort_query]
|
||||||
query = ["ALL"]
|
query = ["ALL"]
|
||||||
@page = @params["page"]
|
@page = params["page"]
|
||||||
@page ||= @session['page']
|
@page ||= session['page']
|
||||||
@session['page'] = @page
|
session['page'] = @page
|
||||||
if @search_field and @search_value and not(@search_field.strip() == "") and not(@search_value.strip() == "")
|
if @search_field and @search_value and not(@search_field.strip() == "") and not(@search_value.strip() == "")
|
||||||
@pages = Paginator.new self, 0, get_mail_prefs.wm_rows, @page
|
@pages = Paginator.new self, 0, get_mail_prefs.wm_rows, @page
|
||||||
@messages = folder.messages_search([@search_field, @search_value], sort_query + (reverse_sort ? ' desc' : ' asc'))
|
@messages = folder.messages_search([@search_field, @search_value], sort_query + (reverse_sort ? ' desc' : ' asc'))
|
||||||
|
@ -154,7 +154,7 @@ class WebmailController < ApplicationController
|
||||||
elsif operation == _('Add')
|
elsif operation == _('Add')
|
||||||
@mail = create_mail
|
@mail = create_mail
|
||||||
attachment = CDF::Attachment.new(@mail)
|
attachment = CDF::Attachment.new(@mail)
|
||||||
attachment.file = @params['attachment']
|
attachment.file = params['attachment']
|
||||||
else
|
else
|
||||||
# default - new email create
|
# default - new email create
|
||||||
@mail = create_mail
|
@mail = create_mail
|
||||||
|
@ -184,7 +184,7 @@ class WebmailController < ApplicationController
|
||||||
|
|
||||||
if mail.multipart?
|
if mail.multipart?
|
||||||
get_parts(mail).each { |part|
|
get_parts(mail).each { |part|
|
||||||
return send_part(part) if part.header and part.header['content-type']['name'] == @params['ctype']
|
return send_part(part) if part.header and part.header['content-type']['name'] == params['ctype']
|
||||||
}
|
}
|
||||||
render("webmail/webmail/noattachment")
|
render("webmail/webmail/noattachment")
|
||||||
else
|
else
|
||||||
|
@ -198,15 +198,15 @@ class WebmailController < ApplicationController
|
||||||
@mailpref = MailPref.create("customer_id"=>logged_customer)
|
@mailpref = MailPref.create("customer_id"=>logged_customer)
|
||||||
end
|
end
|
||||||
|
|
||||||
if @params['op'] == _('Save')
|
if params['op'] == _('Save')
|
||||||
if @params['customer']
|
if params['customer']
|
||||||
@customer.fname = @params['customer']['fname']
|
@customer.fname = params['customer']['fname']
|
||||||
@customer.lname = @params['customer']['lname']
|
@customer.lname = params['customer']['lname']
|
||||||
@customer.save
|
@customer.save
|
||||||
end
|
end
|
||||||
@mailpref.attributes = @params["mailpref"]
|
@mailpref.attributes = params["mailpref"]
|
||||||
@mailpref.save
|
@mailpref.save
|
||||||
@session["wmimapseskey"] = nil
|
session["wmimapseskey"] = nil
|
||||||
redirect_to(:action=>"messages")
|
redirect_to(:action=>"messages")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -216,16 +216,16 @@ class WebmailController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def filter
|
def filter
|
||||||
if @params['op']
|
if params['op']
|
||||||
@filter = Filter.new(@params['filter'])
|
@filter = Filter.new(params['filter'])
|
||||||
@filter.customer_id = logged_customer
|
@filter.customer_id = logged_customer
|
||||||
@params['expression'].each { |index, expr| @filter.expressions << Expression.new(expr) unless expr["expr_value"].nil? or expr["expr_value"].strip == "" }
|
params['expression'].each { |index, expr| @filter.expressions << Expression.new(expr) unless expr["expr_value"].nil? or expr["expr_value"].strip == "" }
|
||||||
case @params['op']
|
case params['op']
|
||||||
when _('Add')
|
when _('Add')
|
||||||
@filter.expressions << Expression.new
|
@filter.expressions << Expression.new
|
||||||
when _('Save')
|
when _('Save')
|
||||||
if @params['filter']['id'] and @params['filter']['id'] != ""
|
if params['filter']['id'] and params['filter']['id'] != ""
|
||||||
@sf = Filter.find(@params['filter']['id'])
|
@sf = Filter.find(params['filter']['id'])
|
||||||
@sf.name, @sf.destination_folder = @filter.name, @filter.destination_folder
|
@sf.name, @sf.destination_folder = @filter.name, @filter.destination_folder
|
||||||
@sf.expressions.each{|expr| Expression.delete(expr.id) }
|
@sf.expressions.each{|expr| Expression.delete(expr.id) }
|
||||||
@filter.expressions.each {|expr| @sf.expressions << Expression.create(expr.attributes) }
|
@filter.expressions.each {|expr| @sf.expressions << Expression.create(expr.attributes) }
|
||||||
|
@ -241,14 +241,14 @@ class WebmailController < ApplicationController
|
||||||
end
|
end
|
||||||
@expressions = @filter.expressions
|
@expressions = @filter.expressions
|
||||||
else
|
else
|
||||||
@filter = Filter.find(@params["id"]) if @params["id"]
|
@filter = Filter.find(params["id"]) if params["id"]
|
||||||
@expressions = @filter.expressions
|
@expressions = @filter.expressions
|
||||||
end
|
end
|
||||||
@destfolders = get_to_folders
|
@destfolders = get_to_folders
|
||||||
end
|
end
|
||||||
|
|
||||||
def filter_delete
|
def filter_delete
|
||||||
Filter.delete(@params["id"])
|
Filter.delete(params["id"])
|
||||||
# reindex other filters
|
# reindex other filters
|
||||||
@user = Customer.find(logged_customer)
|
@user = Customer.find(logged_customer)
|
||||||
findex = 0
|
findex = 0
|
||||||
|
@ -262,7 +262,7 @@ class WebmailController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def filter_up
|
def filter_up
|
||||||
filt = @user.filters.find(@params['id'])
|
filt = @user.filters.find(params['id'])
|
||||||
ufilt = @user.filters.find_all("order_num = #{filt.order_num - 1}").first
|
ufilt = @user.filters.find_all("order_num = #{filt.order_num - 1}").first
|
||||||
ufilt.order_num = ufilt.order_num + 1
|
ufilt.order_num = ufilt.order_num + 1
|
||||||
filt.order_num = filt.order_num - 1
|
filt.order_num = filt.order_num - 1
|
||||||
|
@ -273,7 +273,7 @@ class WebmailController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def filter_down
|
def filter_down
|
||||||
filt = Filter.find(@params["id"])
|
filt = Filter.find(params["id"])
|
||||||
dfilt = @user.filters[filt.order_num]
|
dfilt = @user.filters[filt.order_num]
|
||||||
dfilt.order_num = dfilt.order_num - 1
|
dfilt.order_num = dfilt.order_num - 1
|
||||||
filt.order_num = filt.order_num + 1
|
filt.order_num = filt.order_num + 1
|
||||||
|
@ -338,10 +338,10 @@ class WebmailController < ApplicationController
|
||||||
|
|
||||||
def get_upass
|
def get_upass
|
||||||
if CDF::CONFIG[:crypt_session_pass]
|
if CDF::CONFIG[:crypt_session_pass]
|
||||||
EzCrypto::Key.decrypt_with_password(CDF::CONFIG[:encryption_password], CDF::CONFIG[:encryption_salt], @session["wmp"])
|
EzCrypto::Key.decrypt_with_password(CDF::CONFIG[:encryption_password], CDF::CONFIG[:encryption_salt], session["wmp"])
|
||||||
else
|
else
|
||||||
# retrun it plain
|
# retrun it plain
|
||||||
@session["wmp"]
|
session["wmp"]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -383,23 +383,23 @@ class WebmailController < ApplicationController
|
||||||
|
|
||||||
def load_folders
|
def load_folders
|
||||||
if have_to_load_folders?()
|
if have_to_load_folders?()
|
||||||
if @params["folder_name"]
|
if params["folder_name"]
|
||||||
@folder_name = @params["folder_name"]
|
@folder_name = params["folder_name"]
|
||||||
else
|
else
|
||||||
@folder_name = @session["folder_name"] ? @session["folder_name"] : CDF::CONFIG[:mail_inbox]
|
@folder_name = session["folder_name"] ? session["folder_name"] : CDF::CONFIG[:mail_inbox]
|
||||||
end
|
end
|
||||||
@session["folder_name"] = @folder_name
|
session["folder_name"] = @folder_name
|
||||||
@folders = @mailbox.folders if @folders.nil?
|
@folders = @mailbox.folders if @folders.nil?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_mail
|
def create_mail
|
||||||
m = CDF::Mail.new(user.mail_temporary_path)
|
m = CDF::Mail.new(user.mail_temporary_path)
|
||||||
if @params["mail"]
|
if params["mail"]
|
||||||
ma = @params["mail"]
|
ma = params["mail"]
|
||||||
m.body, m.content_type, m.from, m.to, m.cc, m.bcc, m.subject = ma["body"], ma["content_type"], ma["from"], ma["to"], ma["cc"], ma["bcc"], ma["subject"]
|
m.body, m.content_type, m.from, m.to, m.cc, m.bcc, m.subject = ma["body"], ma["content_type"], ma["from"], ma["to"], ma["cc"], ma["bcc"], ma["subject"]
|
||||||
if @params["att_files"]
|
if params["att_files"]
|
||||||
att_files, att_tfiles, att_ctypes = @params["att_files"], @params["att_tfiles"], @params["att_ctypes"]
|
att_files, att_tfiles, att_ctypes = params["att_files"], params["att_tfiles"], params["att_ctypes"]
|
||||||
att_files.each {|i, value|
|
att_files.each {|i, value|
|
||||||
att = CDF::Attachment.new(m)
|
att = CDF::Attachment.new(m)
|
||||||
att.filename, att.temp_filename, att.content_type = value, att_tfiles[i], att_ctypes[i]
|
att.filename, att.temp_filename, att.content_type = value, att_tfiles[i], att_ctypes[i]
|
||||||
|
@ -425,7 +425,7 @@ class WebmailController < ApplicationController
|
||||||
|
|
||||||
def get_mail_prefs
|
def get_mail_prefs
|
||||||
if not(@mailprefs)
|
if not(@mailprefs)
|
||||||
if not(@mailprefs = MailPref.find_by_customer(logged_customer))
|
if not(@mailprefs = MailPref.find_by_customer_id(logged_customer))
|
||||||
@mailprefs = MailPref.create("customer_id"=>logged_customer)
|
@mailprefs = MailPref.create("customer_id"=>logged_customer)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -477,18 +477,18 @@ class WebmailController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def msg_id_param
|
def msg_id_param
|
||||||
@params["msg_id"]
|
params["msg_id"]
|
||||||
end
|
end
|
||||||
|
|
||||||
def messages_param
|
def messages_param
|
||||||
@params["messages"]
|
params["messages"]
|
||||||
end
|
end
|
||||||
|
|
||||||
def dst_folder
|
def dst_folder
|
||||||
@params["cpdest"]
|
params["cpdest"]
|
||||||
end
|
end
|
||||||
|
|
||||||
def operation_param
|
def operation_param
|
||||||
@params["op"]
|
params["op"]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
9
app/models/mail_pref.rb
Normal file
9
app/models/mail_pref.rb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
# require_association 'customer'
|
||||||
|
|
||||||
|
class MailPref < ActiveRecord::Base
|
||||||
|
belongs_to :customer
|
||||||
|
|
||||||
|
# def MailPref.find_by_customer(customer_id)
|
||||||
|
# find :first, :conditions => (["customer_id = #{customer_id}"])
|
||||||
|
# end
|
||||||
|
end
|
|
@ -31,7 +31,7 @@
|
||||||
<div id="messages">
|
<div id="messages">
|
||||||
<div id="msglist">
|
<div id="msglist">
|
||||||
<h2><%= @folder_name %></h2>
|
<h2><%= @folder_name %></h2>
|
||||||
<%= start_form_tag({:controller=>'/webmail/webmail', :action=>'messages'})%>
|
<%= form_tag({:controller=>'/webmail/webmail', :action=>'messages'})%>
|
||||||
<div class='notviscode'><input type="submit" name="op" value="<%=_('Search')%>" /></div>
|
<div class='notviscode'><input type="submit" name="op" value="<%=_('Search')%>" /></div>
|
||||||
<input type="hidden" name="page" value="<%=@page%>"/>
|
<input type="hidden" name="page" value="<%=@page%>"/>
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@
|
||||||
</select>
|
</select>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<%= render_partial "search" %>
|
<%= render :partial => "search" %>
|
||||||
<%= page_navigation_webmail @pages if @pages.page_count > 1 %>
|
<%= page_navigation_webmail @pages if @pages.page_count > 1 %>
|
||||||
<table width='98%'>
|
<table width='98%'>
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -76,7 +76,7 @@
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<% for message in @messages %>
|
<% for message in @messages %>
|
||||||
<%= render_partial 'webmail/webmail/message_row', message %>
|
<%= render :partial => 'message_row', :object => message %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
require_association 'customer'
|
|
||||||
|
|
||||||
class MailPref < ActiveRecord::Base
|
|
||||||
belongs_to :customer
|
|
||||||
|
|
||||||
def MailPref.find_by_customer(customer_id)
|
|
||||||
find_first(["customer_id = #{customer_id}"])
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -21,7 +21,8 @@ class Init < ActiveRecord::Migration
|
||||||
|
|
||||||
create_table :mail_prefs do |t|
|
create_table :mail_prefs do |t|
|
||||||
t.string :mail_type
|
t.string :mail_type
|
||||||
t.integer :wm_rows, :customer_id
|
t.integer :wm_rows, :default => 20
|
||||||
|
t.integer :customer_id
|
||||||
t.boolean :check_external_mail
|
t.boolean :check_external_mail
|
||||||
t.timestamps
|
t.timestamps
|
||||||
end
|
end
|
||||||
|
|
|
@ -85,7 +85,7 @@ ActiveRecord::Schema.define(:version => 20090107193228) do
|
||||||
|
|
||||||
create_table "mail_prefs", :force => true do |t|
|
create_table "mail_prefs", :force => true do |t|
|
||||||
t.string "mail_type"
|
t.string "mail_type"
|
||||||
t.integer "wm_rows"
|
t.integer "wm_rows", :default => 20
|
||||||
t.integer "customer_id"
|
t.integer "customer_id"
|
||||||
t.boolean "check_external_mail"
|
t.boolean "check_external_mail"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
|
|
Loading…
Reference in a new issue