]>
gitweb.michael.orlitzky.com - mailshears.git/blob - lib/common/roundcube_plugin.rb
1 require 'common/plugin'
4 # Code that all Roundcube plugins (Prune, Rm, Mv...) will share.
5 # That is, we implement the Plugin interface.
9 @db_host = cfg
.roundcube_dbhost
10 @db_port = cfg
.roundcube_dbport
11 @db_opts = cfg
.roundcube_dbopts
12 @db_tty = cfg
.roundcube_dbtty
13 @db_name = cfg
.roundcube_dbname
14 @db_user = cfg
.roundcube_dbuser
15 @db_pass = cfg
.roundcube_dbpass
19 def describe_domain(domain
)
20 # Roundcube doesn't have a concept of domains.
24 def describe_user(user
)
25 user_id
= self.get_user_id(user
)
28 return 'User not found'
30 return "User ID: #{user_id}"
41 connection
= PGconn
.connect(@db_host,
49 sql_query
= "SELECT user_id FROM users WHERE username = $1;"
51 connection
.query(sql_query
, [user
]) do |result
|
52 if result
.num_tuples
> 0
53 user_id
= result
[0]['user_id']
60 # Pretend like we're database-agnostic in case we ever are.
61 raise DatabaseError
.new(e
)
68 # Used in both prune/rm.
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
)