]>
gitweb.michael.orlitzky.com - mailshears.git/blob - agendav_plugin.rb
cb445bed817d853c3b91c3e3c75c2735330614cc
1 require 'common/plugin'
4 # Code that all Agendav plugins (Prune, Rm, Mv...) will
5 # share. That is, we implement the Plugin interface.
10 cfg
= Configuration
.new()
11 @db_host = cfg
.agendav_dbhost
12 @db_port = cfg
.agendav_dbport
13 @db_opts = cfg
.agendav_dbopts
14 @db_tty = cfg
.agendav_dbtty
15 @db_name = cfg
.agendav_dbname
16 @db_user = cfg
.agendav_dbuser
17 @db_pass = cfg
.agendav_dbpass
21 def describe_domain(domain
)
22 # AgenDAV doesn't have a concept of domains.
27 def describe_account(account
)
28 if self.user_exists(account
)
29 return "Username: #{account}"
31 return 'User not found'
38 def user_exists(account
)
39 ad_users
= list_users()
40 return ad_users
.include?(account
)
46 # Just assume PostgreSQL for now.
48 connection
= PGconn
.connect(@db_host,
56 sql_query
= '(SELECT username FROM prefs)'
58 sql_query +
= '(SELECT user_from FROM shared);'
60 connection
.query(sql_query
) do |result
|
61 usernames
= result
.field_values('username')
66 # Pretend like we're database-agnostic in case we ever are.
67 raise DatabaseError
.new(e
)