aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Romain <christophe.romain@process-one.net>2007-11-16 13:58:00 +0000
committerChristophe Romain <christophe.romain@process-one.net>2007-11-16 13:58:00 +0000
commitd7d34f87e74fdc4094b4819e5a55a87e6663d487 (patch)
tree8f1aecaf1b17317be1eadf2b8cc7ac8be3720b2d
parent* Making sure SVN properties are correctly set. (diff)
Better count management and batch users retrieval internal database
SVN Revision: 972
-rw-r--r--ChangeLog5
-rw-r--r--src/ejabberd_auth.erl6
-rw-r--r--src/ejabberd_auth_internal.erl64
-rw-r--r--src/ejabberd_auth_odbc.erl4
4 files changed, 72 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index d74c079bd..30f88d3f6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-11-16 Christophe Romain <christophe.romain@process-one.net>
+
+ * src/ejabberd_auth_internal.erl: Better count management and batch users
+ retrieval internal database
+
2007-11-05 Mickael Remond <mremond@process-one.net>
* src/ejabberd_config.erl: Refactoring: Move internal
diff --git a/src/ejabberd_auth.erl b/src/ejabberd_auth.erl
index d62cf333f..826b26200 100644
--- a/src/ejabberd_auth.erl
+++ b/src/ejabberd_auth.erl
@@ -22,13 +22,13 @@
try_register/3,
dirty_get_registered_users/0,
get_vh_registered_users/1,
- get_vh_registered_users/2,
+ get_vh_registered_users/2,
get_vh_registered_users_number/1,
- get_vh_registered_users_number/2,
+ get_vh_registered_users_number/2,
get_password/2,
get_password_s/2,
is_user_exists/2,
- is_user_exists_in_other_modules/3,
+ is_user_exists_in_other_modules/3,
remove_user/2,
remove_user/3,
plain_password_required/1,
diff --git a/src/ejabberd_auth_internal.erl b/src/ejabberd_auth_internal.erl
index 62e765421..891a5aa17 100644
--- a/src/ejabberd_auth_internal.erl
+++ b/src/ejabberd_auth_internal.erl
@@ -18,6 +18,9 @@
try_register/3,
dirty_get_registered_users/0,
get_vh_registered_users/1,
+ get_vh_registered_users/2,
+ get_vh_registered_users_number/1,
+ get_vh_registered_users_number/2,
get_password/2,
get_password_s/2,
is_user_exists/2,
@@ -122,10 +125,67 @@ get_vh_registered_users(Server) ->
LServer = jlib:nameprep(Server),
mnesia:dirty_select(
passwd,
- [{#passwd{us = '$1', _ = '_'},
- [{'==', {element, 2, '$1'}, LServer}],
+ [{#passwd{us = '$1', _ = '_'},
+ [{'==', {element, 2, '$1'}, LServer}],
['$1']}]).
+get_vh_registered_users(Server, [{from, Start}, {to, End}])
+ when is_integer(Start) and is_integer(End) ->
+ get_vh_registered_users(Server, [{limit, End-Start+1}, {offset, Start}]);
+
+get_vh_registered_users(Server, [{limit, Limit}, {offset, Offset}])
+ when is_integer(Limit) and is_integer(Offset) ->
+ case get_vh_registered_users(Server) of
+ [] ->
+ [];
+ Users ->
+ Set = lists:keysort(1, Users),
+ L = length(Set),
+ Start = if Offset < 1 -> 1;
+ Offset > L -> L;
+ true -> Offset
+ end,
+ lists:sublist(Set, Start, Limit)
+ end;
+
+get_vh_registered_users(Server, [{prefix, Prefix}])
+ when is_list(Prefix) ->
+ Set = [{U,S} || {U, S} <- get_vh_registered_users(Server), lists:prefix(Prefix, U)],
+ lists:keysort(1, Set);
+
+get_vh_registered_users(Server, [{prefix, Prefix}, {from, Start}, {to, End}])
+ when is_list(Prefix) and is_integer(Start) and is_integer(End) ->
+ get_vh_registered_users(Server, [{prefix, Prefix}, {limit, End-Start+1}, {offset, Start}]);
+
+get_vh_registered_users(Server, [{prefix, Prefix}, {limit, Limit}, {offset, Offset}])
+ when is_list(Prefix) and is_integer(Limit) and is_integer(Offset) ->
+ case [{U,S} || {U, S} <- get_vh_registered_users(Server), lists:prefix(Prefix, U)] of
+ [] ->
+ [];
+ Users ->
+ Set = lists:keysort(1, Users),
+ L = length(Set),
+ Start = if Offset < 1 -> 1;
+ Offset > L -> L;
+ true -> Offset
+ end,
+ lists:sublist(Set, Start, Limit)
+ end;
+
+get_vh_registered_users(Server, _) ->
+ get_vh_registered_users(Server).
+
+get_vh_registered_users_number(Server) ->
+ Set = get_vh_registered_users(Server),
+ length(Set).
+
+get_vh_registered_users_number(Server, [{prefix, Prefix}]) when is_list(Prefix) ->
+ Set = [{U, S} || {U, S} <- get_vh_registered_users(Server), lists:prefix(Prefix, U)],
+ length(Set);
+
+get_vh_registered_users_number(Server, _) ->
+ get_vh_registered_users_number(Server).
+
get_password(User, Server) ->
LUser = jlib:nodeprep(User),
LServer = jlib:nameprep(Server),
diff --git a/src/ejabberd_auth_odbc.erl b/src/ejabberd_auth_odbc.erl
index cc65aa053..1f2228ea1 100644
--- a/src/ejabberd_auth_odbc.erl
+++ b/src/ejabberd_auth_odbc.erl
@@ -18,9 +18,9 @@
try_register/3,
dirty_get_registered_users/0,
get_vh_registered_users/1,
- get_vh_registered_users/2,
+ get_vh_registered_users/2,
get_vh_registered_users_number/1,
- get_vh_registered_users_number/2,
+ get_vh_registered_users_number/2,
get_password/2,
get_password_s/2,
is_user_exists/2,