aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2012-07-28 21:27:45 +0200
committerKim Alvefur <zash@zash.se>2012-07-28 21:27:45 +0200
commita1b0be048a60d63da9057e1791e5db4c41b3a6c0 (patch)
tree75584250c0c2626c14c893388993e9d6ca0a7924 /plugins
parentd58703f58288f9f98c2d02a40fdbc807f4da6af2 (diff)
downloadprosody-a1b0be048a60d63da9057e1791e5db4c41b3a6c0.tar.gz
prosody-a1b0be048a60d63da9057e1791e5db4c41b3a6c0.zip
mod_storage_sql: Add method for listing stores
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_storage_sql.lua18
1 files changed, 18 insertions, 0 deletions
diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua
index 8b05c822..211f4d5f 100644
--- a/plugins/mod_storage_sql.lua
+++ b/plugins/mod_storage_sql.lua
@@ -352,4 +352,22 @@ function driver:open(store, typ)
return nil, "unsupported-store";
end
+function driver:list_stores(username) -- Not to be confused with the list store type
+ local sql = (username == true
+ and "SELECT DISTINCT `store` FROM `prosody` WHERE `host`=? AND `user`!=?"
+ or "SELECT DISTINCT `store` FROM `prosody` WHERE `host`=? AND `user`=?");
+ if username == true or not username then
+ username = "";
+ end
+ local stmt, err = dosql(sql, host, username);
+ if not stmt then
+ return nil, err;
+ end
+ local stores = {};
+ for row in stmt:rows() do
+ stores[#stores+1] = row[1];
+ end
+ return stores;
+end
+
module:add_item("data-driver", driver);