]>
gitweb.michael.orlitzky.com - mailshears.git/blob - lib/common/agendav_plugin.rb
1 require 'common/plugin'
4 # Code that all Agendav plugins ({AgendavPrune}, {AgendavRm},
8 # We implement the Plugin "interface."
12 # Initialize this Agendav {Plugin} with values in *cfg*.
14 # @param cfg [Configuration] the configuration for this plugin.
18 :host => cfg
.agendav_dbhost
,
19 :port => cfg
.agendav_dbport
,
20 :options => cfg
.agendav_dbopts
,
21 :tty => cfg
.agendav_dbtty
,
22 :dbname => cfg
.agendav_dbname
,
23 :user => cfg
.agendav_dbuser
,
24 :password => cfg
.agendav_dbpass
}
28 # Return a list of Agendav users.
30 # @return [Array<User>] a list of users contained in the
36 connection
= PG
::Connection.new(@db_hash)
38 sql_query
= '(SELECT username FROM prefs)'
40 sql_query +
= '(SELECT user_from FROM shared);'
43 connection
.query(sql_query
) do |result
|
44 users
= result
.field_values('username')
47 # Make sure the connection gets closed even if the query explodes.
51 return users
.map
{ |u
| User
.new(u
) }