]>
gitweb.michael.orlitzky.com - mailshears.git/blob - lib/rm/plugins/roundcube.rb
3 require 'common/roundcube_plugin'
6 # Handle removal of Roundcube users from its database. Roundcube has
7 # no concept of domains.
11 include RoundcubePlugin
14 # Remove *user* from the Roundcube database. This should remove him
15 # from _every_ table in which he is referenced. Fortunately the
16 # Roundcube developers were nice enough to include DBMS-specific
17 # install and upgrade scripts, so Postgres can take advantage of ON
20 # @param user [User] the user to remove.
23 raise NonexistentUserError
.new(user
.to_s()) if not user_exists(user
)
25 # Get the primary key for this user in the "users" table.
26 user_id
= self.get_user_id(user
)
28 # Thanks to the ON DELETE triggers, this will remove all child
29 # records associated with user_id too.
30 sql_queries
= ['DELETE FROM users WHERE user_id = $1::int;']
32 connection
= PGconn
.connect(@db_host, @db_port, @db_opts, @db_tty,
33 @db_name, @db_user, @db_pass)
35 sql_queries
.each
do |sql_query
|
36 connection
.query(sql_query
, [user_id
])