]> gitweb.michael.orlitzky.com - mailshears.git/blobdiff - lib/common/roundcube_db_plugin.rb
Move domain removal into the plugins.
[mailshears.git] / lib / common / roundcube_db_plugin.rb
index 364b8199e23f992c2a4744ac3ec76239a98b7714..df5413fdb0cc7a797dc2fd1f7070f3809b7f2abc 100644 (file)
@@ -19,7 +19,7 @@ module RoundcubeDbPlugin
 
   def describe_domain(domain)
     # Roundcube doesn't have a concept of domains.
-    return 'N/A'
+    return domain
   end
 
   def describe_account(account)
@@ -65,4 +65,33 @@ module RoundcubeDbPlugin
     return user_id
   end
 
+
+  # Used in both prune/rm.
+  def list_users()
+    usernames = []
+
+    # Just assume PostgreSQL for now.
+    begin
+      connection = PGconn.connect(@db_host,
+                                  @db_port,
+                                  @db_opts,
+                                  @db_tty,
+                                  @db_name,
+                                  @db_user,
+                                  @db_pass)
+
+      sql_query = "SELECT username FROM users;"
+      connection.query(sql_query) do |result|
+        usernames = result.field_values('username')
+      end
+
+      connection.close()
+    rescue PGError => e
+      # Pretend like we're database-agnostic in case we ever are.
+      raise DatabaseError.new(e)
+    end
+
+    return usernames
+  end
+
 end