X-Git-Url: http://gitweb.michael.orlitzky.com/?p=mailshears.git;a=blobdiff_plain;f=lib%2Fmailshears%2Fplugins%2Froundcube_db.rb;h=7d1a037623ecf75092162d7cdf77c30897b7c092;hp=c86d31460e93d96395d4cc29e0849f9a15803ae0;hb=9392a185e1f1ffd192ffc0b36bfa401143738ba8;hpb=451f1c3175c1a3c8670f51ebc907102d8c99820d diff --git a/lib/mailshears/plugins/roundcube_db.rb b/lib/mailshears/plugins/roundcube_db.rb index c86d314..7d1a037 100644 --- a/lib/mailshears/plugins/roundcube_db.rb +++ b/lib/mailshears/plugins/roundcube_db.rb @@ -5,13 +5,14 @@ class RoundcubeDb include Plugin def initialize() - @db_host = Configuration::roundcube_dbhost - @db_port = Configuration::roundcube_dbport - @db_opts = Configuration::roundcube_dbopts - @db_tty = Configuration::roundcube_dbtty - @db_name = Configuration::roundcube_dbname - @db_user = Configuration::roundcube_dbuser - @db_pass = Configuration::roundcube_dbpass + cfg = Configuration.new() + @db_host = cfg.roundcube_dbhost + @db_port = cfg.roundcube_dbport + @db_opts = cfg.roundcube_dbopts + @db_tty = cfg.roundcube_dbtty + @db_name = cfg.roundcube_dbname + @db_user = cfg.roundcube_dbuser + @db_pass = cfg.roundcube_dbpass end @@ -39,28 +40,16 @@ class RoundcubeDb # belonging to it. user_id = self.get_user_id(account) - # This is mostly unnecessary when using Postgres. The Roundcube - # developers were nice enough to include DBMS-specific install and - # upgrade scripts, so Postgres can take advantage of ON DELETE - # triggers. Here's an example: + # The Roundcube developers were nice enough to include + # DBMS-specific install and upgrade scripts, so Postgres can take + # advantage of ON DELETE triggers. Here's an example: # # ... # user_id integer NOT NULL # REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE # - sql_queries = ['DELETE FROM cache WHERE user_id = $1::int;'] - sql_queries << 'DELETE FROM cache_index WHERE user_id = $1::int;' - sql_queries << 'DELETE FROM cache_messages WHERE user_id = $1::int;' - sql_queries << 'DELETE FROM cache_thread WHERE user_id = $1::int;' - sql_queries << 'DELETE FROM contactgroupmembers WHERE contactgroup_id IN (SELECT contactgroup_id FROM contactgroups WHERE user_id = $1::int);' - sql_queries << 'DELETE FROM contactgroups WHERE user_id = $1::int;' - sql_queries << 'DELETE FROM contacts WHERE user_id = $1::int;' - sql_queries << 'DELETE FROM identities WHERE user_id = $1::int;' - sql_queries << 'DELETE FROM dictionary WHERE user_id = $1::int;' - sql_queries << 'DELETE FROM searches WHERE user_id = $1::int;' - - # This one is of course necessary with any DBMS. - sql_queries << 'DELETE FROM users WHERE user_id = $1::int;' + # This query is of course necessary with any DBMS: + sql_queries = ['DELETE FROM users WHERE user_id = $1::int;'] begin connection = PGconn.connect(@db_host, @@ -92,7 +81,7 @@ class RoundcubeDb def get_leftover_accounts(db_accounts) - # Given a list of all users who have logged in to Roundcube. + # Get a list of all users who have logged in to Roundcube. rc_accounts = self.get_roundcube_usernames() return rc_accounts - db_accounts end