]> granicus.if.org Git - ejabberd/commitdiff
Call in WebAdmin the proper mod_last backend module (EJAB-1031)
authorBadlop <badlop@process-one.net>
Wed, 9 Dec 2009 17:46:51 +0000 (17:46 +0000)
committerBadlop <badlop@process-one.net>
Wed, 9 Dec 2009 17:46:51 +0000 (17:46 +0000)
SVN Revision: 2798

src/mod_last.erl
src/web/ejabberd_web_admin.erl

index 5e621726f6b99c1bfc341a57cad31952164cd3a1..2b17d9d07e4a7dd0e05d7b2cf52929d3f5ee9766 100644 (file)
@@ -175,7 +175,7 @@ store_last_info(User, Server, TimeStamp, Status) ->
     mnesia:transaction(F).
 
 %% @spec (LUser::string(), LServer::string()) ->
-%%      {ok, Timestamp::integer(), Status::string()} | not_found
+%%      {ok, TimeStamp::integer(), Status::string()} | not_found
 get_last_info(LUser, LServer) ->
     case catch mnesia:dirty_read(last_activity, {LUser, LServer}) of
        {'EXIT', _Reason} ->
index d8e5ac848af48e64cc6616f06021a38c18ab480c..ccc38d8795d914e101117ecb96a16886e1373296 100644 (file)
@@ -1467,7 +1467,7 @@ list_users(Host, Query, Lang, URLFunc) ->
     FUsers =
        case length(SUsers) of
            N when N =< 100 ->
-               [list_given_users(SUsers, "../", Lang, URLFunc)];
+               [list_given_users(Host, SUsers, "../", Lang, URLFunc)];
            N ->
                NParts = trunc(math:sqrt(N * 0.618)) + 1,
                M = trunc(N / NParts) + 1,
@@ -1542,9 +1542,10 @@ list_users_in_diapason(Host, Diap, Lang, URLFunc) ->
     N1 = list_to_integer(S1),
     N2 = list_to_integer(S2),
     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("thead",
             [?XE("tr",
@@ -1562,11 +1563,10 @@ list_given_users(Users, Prefix, Lang, URLFunc) ->
                       FLast =
                           case ejabberd_sm:get_user_resources(User, Server) of
                               [] ->
-                                  case mnesia:dirty_read({last_activity, US}) of
-                                      [] ->
+                                  case ModLast:get_last_info(User, Server) of
+                                      not_found ->
                                           ?T("Never");
-                                      [E] ->
-                                          Shift = element(3, E),
+                                      {ok, Shift, _Status} ->
                                           TimeStamp = {Shift div 1000000,
                                                        Shift rem 1000000,
                                                        0},
@@ -1591,6 +1591,13 @@ list_given_users(Users, Prefix, Lang, URLFunc) ->
               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}) ->
     jlib:jid_to_string({User, Server, ""}).