]> gitweb.michael.orlitzky.com - mailshears.git/blob - lib/rm/plugins/agendav.rb
Simplify prune plugins and fix array difference error.
[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_user(user)
13 # Delete the given username and any records in other tables
14 # belonging to it.
15 raise NonexistentUserError.new(user.to_s()) if not user_exists(user)
16
17 sql_queries = ['DELETE FROM prefs WHERE username = $1;']
18 sql_queries << 'DELETE FROM shared WHERE user_from = $1;'
19
20 begin
21 connection = PGconn.connect(@db_host,
22 @db_port,
23 @db_opts,
24 @db_tty,
25 @db_name,
26 @db_user,
27 @db_pass)
28
29 sql_queries.each do |sql_query|
30 connection.query(sql_query, [user.to_s()])
31 end
32
33 connection.close()
34
35 rescue PGError => e
36 # Pretend like we're database-agnostic in case we ever are.
37 raise DatabaseError.new(e)
38 end
39
40 end
41
42 end