4cd179c655323070d71b01348a975a4a214047c0
[mailshears.git] / lib / rm / plugins / agendav.rb
1 require 'pg'
2
3 require 'common/agendav_plugin'
4 require 'rm/rm_plugin'
5
6 class AgendavRm
7
8 include AgendavPlugin
9 include RmPlugin
10
11
12 def delete_domain(domain)
13 # AgenDAV doesn't have a concept of domains.
14 end
15
16 def delete_account(account)
17 # Delete the given username and any records in other tables
18 # belonging to it.
19
20 sql_queries = ['DELETE FROM prefs WHERE username = $1;']
21 sql_queries << 'DELETE FROM shared WHERE user_from = $1;'
22
23 begin
24 connection = PGconn.connect(@db_host,
25 @db_port,
26 @db_opts,
27 @db_tty,
28 @db_name,
29 @db_user,
30 @db_pass)
31
32 sql_queries.each do |sql_query|
33 connection.query(sql_query, [account])
34 end
35
36 connection.close()
37
38 rescue PGError => e
39 # Pretend like we're database-agnostic in case we ever are.
40 raise DatabaseError.new(e)
41 end
42
43 end
44
45 end