mirror of
https://github.com/processone/ejabberd.git
synced 2024-10-09 15:06:54 +02:00
Support in user list page of WebAdmin when mod_offline is disabled (EJAB-377)
SVN Revision: 2877
This commit is contained in:
parent
e7a8bf6154
commit
ee77257d41
@ -39,6 +39,7 @@
|
||||
remove_expired_messages/0,
|
||||
remove_old_messages/1,
|
||||
remove_user/2,
|
||||
get_queue_length/2,
|
||||
webadmin_page/3,
|
||||
webadmin_user/4,
|
||||
webadmin_user_parse_query/5]).
|
||||
@ -612,9 +613,11 @@ user_queue_parse_query(US, Query) ->
|
||||
us_to_list({User, Server}) ->
|
||||
jlib:jid_to_string({User, Server, ""}).
|
||||
|
||||
get_queue_length(User, Server) ->
|
||||
length(mnesia:dirty_read({offline_msg, {User, Server}})).
|
||||
|
||||
webadmin_user(Acc, User, Server, Lang) ->
|
||||
US = {jlib:nodeprep(User), jlib:nameprep(Server)},
|
||||
QueueLen = length(mnesia:dirty_read({offline_msg, US})),
|
||||
QueueLen = get_queue_length(jlib:nodeprep(User), jlib:nameprep(Server)),
|
||||
FQueueLen = [?AC("queue/",
|
||||
integer_to_list(QueueLen))],
|
||||
Acc ++ [?XCT("h3", "Offline Messages:")] ++ FQueueLen ++ [?C(" "), ?INPUTT("submit", "removealloffline", "Remove All Offline Messages")].
|
||||
|
@ -38,6 +38,7 @@
|
||||
pop_offline_messages/3,
|
||||
get_sm_features/5,
|
||||
remove_user/2,
|
||||
get_queue_length/2,
|
||||
webadmin_page/3,
|
||||
webadmin_user/4,
|
||||
webadmin_user_parse_query/5]).
|
||||
@ -479,11 +480,8 @@ user_queue_parse_query(Username, LServer, Query) ->
|
||||
us_to_list({User, Server}) ->
|
||||
jlib:jid_to_string({User, Server, ""}).
|
||||
|
||||
webadmin_user(Acc, User, Server, Lang) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
Username = ejabberd_odbc:escape(LUser),
|
||||
QueueLen = case catch ejabberd_odbc:sql_query(
|
||||
get_queue_length(Username, LServer) ->
|
||||
case catch ejabberd_odbc:sql_query(
|
||||
LServer,
|
||||
["select count(*) from spool"
|
||||
" where username='", Username, "';"]) of
|
||||
@ -491,7 +489,13 @@ webadmin_user(Acc, User, Server, Lang) ->
|
||||
SCount;
|
||||
_ ->
|
||||
0
|
||||
end,
|
||||
end.
|
||||
|
||||
webadmin_user(Acc, User, Server, Lang) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
Username = ejabberd_odbc:escape(LUser),
|
||||
QueueLen = get_queue_length(Username, LServer),
|
||||
FQueueLen = [?AC("queue/", QueueLen)],
|
||||
Acc ++ [?XCT("h3", "Offline Messages:")] ++ FQueueLen ++ [?C(" "), ?INPUTT("submit", "removealloffline", "Remove All Offline Messages")].
|
||||
|
||||
|
@ -1546,6 +1546,7 @@ list_users_in_diapason(Host, Diap, Lang, URLFunc) ->
|
||||
|
||||
list_given_users(Host, Users, Prefix, Lang, URLFunc) ->
|
||||
ModLast = get_lastactivity_module(Host),
|
||||
ModOffline = get_offlinemsg_module(Host),
|
||||
?XE("table",
|
||||
[?XE("thead",
|
||||
[?XE("tr",
|
||||
@ -1556,10 +1557,10 @@ list_given_users(Host, Users, Prefix, Lang, URLFunc) ->
|
||||
lists:map(
|
||||
fun(_SU = {Server, User}) ->
|
||||
US = {User, Server},
|
||||
QueueLen = length(mnesia:dirty_read({offline_msg, US})),
|
||||
QueueLenStr = get_offlinemsg_length(ModOffline, User, Server),
|
||||
FQueueLen = [?AC(URLFunc({users_queue, Prefix,
|
||||
User, Server}),
|
||||
pretty_string_int(QueueLen))],
|
||||
QueueLenStr)],
|
||||
FLast =
|
||||
case ejabberd_sm:get_user_resources(User, Server) of
|
||||
[] ->
|
||||
@ -1591,6 +1592,19 @@ list_given_users(Host, Users, Prefix, Lang, URLFunc) ->
|
||||
end, Users)
|
||||
)]).
|
||||
|
||||
get_offlinemsg_length(ModOffline, User, Server) ->
|
||||
case ModOffline of
|
||||
none -> "disabled";
|
||||
_ -> pretty_string_int(ModOffline:get_queue_length(User, Server))
|
||||
end.
|
||||
|
||||
get_offlinemsg_module(Server) ->
|
||||
case [mod_offline, mod_offline_odbc] -- gen_mod:loaded_modules(Server) of
|
||||
[mod_offline, mod_offline_odbc] -> none;
|
||||
[mod_offline_odbc] -> mod_offline;
|
||||
[mod_offline] -> mod_offline_odbc
|
||||
end.
|
||||
|
||||
get_lastactivity_module(Server) ->
|
||||
case lists:member(mod_last, gen_mod:loaded_modules(Server)) of
|
||||
true -> mod_last;
|
||||
|
Loading…
Reference in New Issue
Block a user