]> gitweb.michael.orlitzky.com - mailshears.git/blob - lib/mv/plugins/roundcube_db.rb
fa29aa6a6e67bdda9817bb6e5ee292a68950bc5f
[mailshears.git] / lib / mv / plugins / roundcube_db.rb
1 require 'pg'
2
3 require 'common/roundcube_db_plugin'
4 require 'mv/mv_plugin'
5
6 class RoundcubeDbMv
7
8 include RoundcubeDbPlugin
9 include MvPlugin
10
11
12 def mv_domain(from, to)
13 # Roundcube doesn't have a concept of domains.
14 end
15
16 def mv_account(from, to)
17 sql_queries = ['UPDATE users SET username = $1 WHERE username = $2;']
18
19 begin
20 connection = PGconn.connect(@db_host,
21 @db_port,
22 @db_opts,
23 @db_tty,
24 @db_name,
25 @db_user,
26 @db_pass)
27
28 sql_queries.each do |sql_query|
29 connection.query(sql_query, [to, from])
30 end
31
32 connection.close()
33
34 rescue PGError => e
35 # Pretend like we're database-agnostic in case we ever are.
36 raise DatabaseError.new(e)
37 end
38
39 end
40
41 end