]>
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_query
= 'DELETE FROM users WHERE user_id = $1::int;'
32 connection
= PG
::Connection.new(@db_hash)
35 connection
.sync_exec_params(sql_query
, [user_id
])
37 # Make sure the connection gets closed even if the query explodes.