]> gitweb.michael.orlitzky.com - mailshears.git/blob - lib/rm/plugins/davical.rb
Use semantic bound on pg library.
[mailshears.git] / lib / rm / plugins / davical.rb
1 require 'pg'
2
3 require 'common/davical_plugin'
4 require 'rm/rm_plugin'
5
6 class DavicalRm
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 RmPlugin
13
14
15 def delete_user(user)
16 # Delete the given username. DAViCal uses foreign keys properly
17 # and only supports postgres, so we let the ON DELETE CASCADE
18 # trigger handle most of the work.
19 raise NonexistentUserError.new(user.to_s()) if not user_exists(user)
20
21 sql_queries = ['DELETE FROM usr WHERE username = $1']
22
23 connection = PGconn.connect(@db_host, @db_port, @db_opts, @db_tty,
24 @db_name, @db_user, @db_pass)
25
26 sql_queries.each do |sql_query|
27 connection.query(sql_query, [user.to_s()])
28 end
29
30 connection.close()
31 end
32
33
34 end