2011-07-23 21:55:26 +02:00
|
|
|
class Server < ActiveRecord::Base
|
2011-07-27 20:34:30 +02:00
|
|
|
|
2011-07-23 21:55:26 +02:00
|
|
|
validates_presence_of :name
|
|
|
|
belongs_to :user
|
2011-09-03 13:07:40 +02:00
|
|
|
#before_save :fill_params
|
2011-07-27 20:34:30 +02:00
|
|
|
|
2011-09-03 13:07:40 +02:00
|
|
|
def self.primary_for_imap
|
|
|
|
where(:for_imap=>true).first
|
2011-07-27 20:34:30 +02:00
|
|
|
end
|
|
|
|
|
2011-09-03 13:07:40 +02:00
|
|
|
def self.primary_for_smtp
|
|
|
|
where(:for_smtp=>true).first
|
|
|
|
end
|
2011-07-27 20:34:30 +02:00
|
|
|
|
2011-09-03 13:07:40 +02:00
|
|
|
def self.create_defaults(user)
|
|
|
|
create( :user_id=>user.id,
|
|
|
|
:name=>"localhost",
|
|
|
|
:port=>$defaults['imap_port'],
|
|
|
|
:use_ssl=>false,
|
|
|
|
:use_tls=>false,
|
|
|
|
:for_smtp=>false,
|
|
|
|
:for_imap=>true
|
|
|
|
)
|
|
|
|
create( :user_id=>user.id,
|
|
|
|
:name=>"localhost",
|
|
|
|
:port=>$defaults['smtp_port'],
|
|
|
|
:use_ssl=>false,
|
|
|
|
:use_tls=>false,
|
|
|
|
:for_smtp=>true,
|
|
|
|
:for_imap=>false
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
# private
|
|
|
|
|
|
|
|
# def fill_params
|
|
|
|
# port.nil? ? port = $defaults['imap_port'] : port
|
|
|
|
# $defaults['imap_use_ssl'] == true ? self.use_ssl = 1 : self.use_ssl = 0
|
|
|
|
# end
|
2011-07-27 20:34:30 +02:00
|
|
|
|
2011-07-23 21:55:26 +02:00
|
|
|
end
|