]>
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.
17 @db_host = cfg
.agendav_dbhost
18 @db_port = cfg
.agendav_dbport
19 @db_opts = cfg
.agendav_dbopts
20 @db_tty = cfg
.agendav_dbtty
21 @db_name = cfg
.agendav_dbname
22 @db_user = cfg
.agendav_dbuser
23 @db_pass = cfg
.agendav_dbpass
27 # Return a list of Agendav users.
29 # @return [Array<User>] a list of users contained in the
35 connection
= PGconn
.connect(@db_host, @db_port, @db_opts, @db_tty,
36 @db_name, @db_user, @db_pass)
38 sql_query
= '(SELECT username FROM prefs)'
40 sql_query +
= '(SELECT user_from FROM shared);'
42 connection
.query(sql_query
) do |result
|
43 users
= result
.field_values('username')
48 return users
.map
{ |u
| User
.new(u
) }