]> gitweb.michael.orlitzky.com - mailshears.git/blob - lib/mv/plugins/davical.rb
Add a bunch more crap and rewrite a bunch more crap. Now the 'rm' mode at least runs.
[mailshears.git] / lib / mv / plugins / davical.rb
1 require 'pg'
2
3 require 'common/davical_plugin'
4 require 'rm/rm_plugin'
5
6 class DavicalMv
7 #
8 # DAViCal only supports Postgres, so even if we ever are
9 # database-agnostic, this plugin can't be.
10 #
11 include DavicalPlugin
12 include MvPlugin
13
14
15 def mv_domain(from, to)
16 # DAViCal doesn't have a concept of domains.
17 end
18
19
20 def mv_account(from, to)
21 # Delete the given username. DAViCal uses foreign keys properly
22 # and only supports postgres, so we let the ON UPDATE CASCADE
23 # trigger handle most of the work.
24 sql_queries = ['UPDATE usr SET username = $1 WHERE username = $2']
25
26 begin
27 connection = PGconn.connect(@db_host,
28 @db_port,
29 @db_opts,
30 @db_tty,
31 @db_name,
32 @db_user,
33 @db_pass)
34
35 sql_queries.each do |sql_query|
36 connection.query(sql_query, [to, from])
37 end
38
39 connection.close()
40
41 rescue PGError => e
42 # Pretend like we're database-agnostic in case we ever are.
43 raise DatabaseError.new(e)
44 end
45
46 end
47
48 end