From eb330ac0e0db29c6e6dc4108f33490dec349d0b9 Mon Sep 17 00:00:00 2001 From: Badlop Date: Tue, 27 Nov 2007 18:54:06 +0000 Subject: * src/mod_configure.erl: The command get-user-lastlogin is now compatible with both Mnesia and ODBC (EJAB-383) * src/mod_last.erl: Likewise * src/mod_last_odbc.erl: Likewise SVN Revision: 995 --- src/mod_configure.erl | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/mod_configure.erl') diff --git a/src/mod_configure.erl b/src/mod_configure.erl index 24f40b33c..e49dc7007 100644 --- a/src/mod_configure.erl +++ b/src/mod_configure.erl @@ -1606,11 +1606,11 @@ set_form(_From, _Host, ?NS_ADMINL("get-user-lastlogin"), Lang, XData) -> case ejabberd_sm:get_user_resources(User, Server) of [] -> US = {User, Server}, - case mnesia:dirty_read({last_activity, US}) of - [] -> + case get_last_info(User, Server) of + not_found -> ?T(Lang, "Never"); - [E] -> - Shift = element(3, E), + {ok, Timestamp, _Status} -> + Shift = Timestamp, TimeStamp = {Shift div 1000000, Shift rem 1000000, 0}, @@ -1711,6 +1711,16 @@ stop_node(From, Host, ENode, Action, XData) -> {result, []}. +get_last_info(User, Server) -> + ML = lists:member(mod_last, gen_mod:loaded_modules(Server)), + MLO = lists:member(mod_last_odbc, gen_mod:loaded_modules(Server)), + case {ML, MLO} of + {true, _} -> mod_last:get_last_info(User, Server); + {false, true} -> mod_last_odbc:get_last_info(User, Server); + {false, false} -> not_found + end. + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% adhoc_sm_commands(_Acc, From, -- cgit v1.2.3