]>
gitweb.michael.orlitzky.com - mailshears.git/blob - lib/rm/plugins/roundcube_db.rb
3e18e8e4b8a5c2bbb8db7555ba8745773ed8f5b5
3 require 'common/roundcube_db_plugin'
8 include RoundcubeDbPlugin
11 def delete_domain(domain
)
12 # Roundcube doesn't have a concept of domains.
15 def delete_account(account
)
16 # Delete the given username and any records in other tables
18 user_id
= self.get_user_id(account
)
20 # The Roundcube developers were nice enough to include
21 # DBMS-specific install and upgrade scripts, so Postgres can take
22 # advantage of ON DELETE triggers. Here's an example:
25 # user_id integer NOT NULL
26 # REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE
28 # This query is of course necessary with any DBMS:
29 sql_queries
= ['DELETE FROM users WHERE user_id = $1::int;']
32 connection
= PGconn
.connect(@db_host,
40 sql_queries
.each
do |sql_query
|
41 connection
.query(sql_query
, [user_id
])
47 # Pretend like we're database-agnostic in case we ever are.
48 raise DatabaseError
.new(e
)
54 def get_leftover_domains(db_domains
)
55 # Roundcube doesn't have a concept of domains.
60 def get_leftover_accounts(db_accounts
)
61 # Get a list of all users who have logged in to Roundcube.
62 rc_accounts
= self.get_roundcube_usernames()
63 return rc_accounts
- db_accounts
69 def get_roundcube_usernames()
72 # Just assume PostgreSQL for now.
74 connection
= PGconn
.connect(@db_host,
82 sql_query
= "SELECT username FROM users;"
83 connection
.query(sql_query
) do |result
|
84 usernames
= result
.field_values('username')
89 # Pretend like we're database-agnostic in case we ever are.
90 raise DatabaseError
.new(e
)