1366bd6db69a15452a0b777dd3b131e65b90d54a
[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_account(account)
13 # Delete the given username and any records in other tables
14 # belonging to it.
15
16 sql_queries = ['DELETE FROM prefs WHERE username = $1;']
17 sql_queries << 'DELETE FROM shared WHERE user_from = $1;'
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, [account])
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