mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-26 16:26:24 +01:00
Call in WebAdmin the proper mod_last backend module (EJAB-1031)
SVN Revision: 2800
This commit is contained in:
parent
dfa966a576
commit
2a09bdad13
@ -170,6 +170,8 @@ store_last_info(User, Server, TimeStamp, Status)
|
|||||||
|
|
||||||
%% @spec (LUser::string(), LServer::string()) ->
|
%% @spec (LUser::string(), LServer::string()) ->
|
||||||
%% {ok, Timestamp::integer(), Status::string()} | not_found
|
%% {ok, Timestamp::integer(), Status::string()} | not_found
|
||||||
|
get_last_info(LUser, LServer) when is_list(LUser), is_list(LServer) ->
|
||||||
|
get_last_info(list_to_binary(LUser), list_to_binary(LServer));
|
||||||
get_last_info(LUser, LServer) when is_binary(LUser), is_binary(LServer) ->
|
get_last_info(LUser, LServer) when is_binary(LUser), is_binary(LServer) ->
|
||||||
case catch mnesia:dirty_read(last_activity, {LUser, LServer}) of
|
case catch mnesia:dirty_read(last_activity, {LUser, LServer}) of
|
||||||
{'EXIT', _Reason} ->
|
{'EXIT', _Reason} ->
|
||||||
|
@ -1489,7 +1489,7 @@ list_users(Host, Query, Lang, URLFunc) ->
|
|||||||
FUsers =
|
FUsers =
|
||||||
case length(SUsers) of
|
case length(SUsers) of
|
||||||
N when N =< 100 ->
|
N when N =< 100 ->
|
||||||
[list_given_users(SUsers, "../", Lang, URLFunc)];
|
[list_given_users(Host, SUsers, "../", Lang, URLFunc)];
|
||||||
N ->
|
N ->
|
||||||
NParts = trunc(math:sqrt(N * 0.618)) + 1,
|
NParts = trunc(math:sqrt(N * 0.618)) + 1,
|
||||||
M = trunc(N / NParts) + 1,
|
M = trunc(N / NParts) + 1,
|
||||||
@ -1567,9 +1567,10 @@ list_users_in_diapason(Host, Diap, Lang, URLFunc) ->
|
|||||||
N1 = list_to_integer(S1),
|
N1 = list_to_integer(S1),
|
||||||
N2 = list_to_integer(S2),
|
N2 = list_to_integer(S2),
|
||||||
Sub = lists:sublist(SUsers, N1, N2 - N1 + 1),
|
Sub = lists:sublist(SUsers, N1, N2 - N1 + 1),
|
||||||
[list_given_users(Sub, "../../", Lang, URLFunc)].
|
[list_given_users(Host, Sub, "../../", Lang, URLFunc)].
|
||||||
|
|
||||||
list_given_users(Users, Prefix, Lang, URLFunc) ->
|
list_given_users(Host, Users, Prefix, Lang, URLFunc) ->
|
||||||
|
ModLast = get_lastactivity_module(Host),
|
||||||
?XE('table',
|
?XE('table',
|
||||||
[?XE('thead',
|
[?XE('thead',
|
||||||
[?XE('tr',
|
[?XE('tr',
|
||||||
@ -1593,11 +1594,10 @@ list_given_users(Users, Prefix, Lang, URLFunc) ->
|
|||||||
FLast =
|
FLast =
|
||||||
case ejabberd_sm:get_user_resources(UserB, ServerB) of
|
case ejabberd_sm:get_user_resources(UserB, ServerB) of
|
||||||
[] ->
|
[] ->
|
||||||
case mnesia:dirty_read({last_activity, US}) of
|
case ModLast:get_last_info(User, Server) of
|
||||||
[] ->
|
not_found ->
|
||||||
?T("Never");
|
?T("Never");
|
||||||
[E] ->
|
{ok, Shift, _Status} ->
|
||||||
Shift = element(3, E),
|
|
||||||
TimeStamp = {Shift div 1000000,
|
TimeStamp = {Shift div 1000000,
|
||||||
Shift rem 1000000,
|
Shift rem 1000000,
|
||||||
0},
|
0},
|
||||||
@ -1622,6 +1622,13 @@ list_given_users(Users, Prefix, Lang, URLFunc) ->
|
|||||||
end, Users)
|
end, Users)
|
||||||
)]).
|
)]).
|
||||||
|
|
||||||
|
get_lastactivity_module(Server) ->
|
||||||
|
case lists:member(mod_last, gen_mod:loaded_modules(Server)) of
|
||||||
|
true -> mod_last;
|
||||||
|
_ -> mod_last_odbc
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
||||||
us_to_list({User, Server}) ->
|
us_to_list({User, Server}) ->
|
||||||
exmpp_jid:to_list(User, Server, undefined).
|
exmpp_jid:to_list(User, Server, undefined).
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user