]>
gitweb.michael.orlitzky.com - mailshears.git/blob - lib/mv/plugins/roundcube_db.rb
68592821a44442a30cf4d0f6bbed6a22089d3557
3 require 'common/plugin'
12 cfg
= Configuration
.new()
13 @db_host = cfg
.roundcube_dbhost
14 @db_port = cfg
.roundcube_dbport
15 @db_opts = cfg
.roundcube_dbopts
16 @db_tty = cfg
.roundcube_dbtty
17 @db_name = cfg
.roundcube_dbname
18 @db_user = cfg
.roundcube_dbuser
19 @db_pass = cfg
.roundcube_dbpass
23 def describe_domain(domain
)
24 # Roundcube doesn't have a concept of domains.
28 def describe_account(account
)
29 user_id
= self.get_user_id(account
)
32 return 'User not found'
34 return "User ID: #{user_id}"
38 def mv_domain(from
, to
)
39 # Roundcube doesn't have a concept of domains.
42 def mv_account(from
, to
)
43 sql_queries
= ['UPDATE users SET username = $1 WHERE username = $2;']
46 connection
= PGconn
.connect(@db_host,
54 sql_queries
.each
do |sql_query
|
55 connection
.query(sql_query
, [to
, from
])
61 # Pretend like we're database-agnostic in case we ever are.
62 raise DatabaseError
.new(e
)
70 def get_user_id(account
)
74 connection
= PGconn
.connect(@db_host,
82 sql_query
= "SELECT user_id FROM users WHERE username = $1;"
84 connection
.query(sql_query
, [account
]) do |result
|
85 if result
.num_tuples
> 0
86 user_id
= result
[0]['user_id']
93 # Pretend like we're database-agnostic in case we ever are.
94 raise DatabaseError
.new(e
)