mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
Support in user list page of WebAdmin when mod_offline is disabled (EJAB-377)
SVN Revision: 2878
This commit is contained in:
parent
a658348ac1
commit
9df6e1fe0a
@ -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]).
|
||||
@ -702,19 +703,12 @@ user_queue_parse_query(US, Query) ->
|
||||
us_to_list({User, Server}) ->
|
||||
exmpp_jid:to_list(User, Server).
|
||||
|
||||
get_queue_length(User, Server) ->
|
||||
length(mnesia:dirty_read({offline_msg, {User, Server}})).
|
||||
|
||||
webadmin_user(Acc, User, Server, Lang) ->
|
||||
FQueueLen = try
|
||||
US = {
|
||||
exmpp_stringprep:nodeprep(User),
|
||||
exmpp_stringprep:nameprep(Server)
|
||||
},
|
||||
QueueLen = length(mnesia:dirty_read({offline_msg, US})),
|
||||
[?AC("queue/",
|
||||
integer_to_list(QueueLen))]
|
||||
catch
|
||||
_ ->
|
||||
[?C("?")]
|
||||
end,
|
||||
QueueLen = get_queue_length(exmpp_stringprep:nodeprep(User), exmpp_stringprep:nameprep(Server)),
|
||||
FQueueLen = [?AC("queue/", integer_to_list(QueueLen))],
|
||||
Acc ++ [?XCT("h3", "Offline Messages:")] ++ FQueueLen ++ [?C(" "), ?INPUTT("submit", "removealloffline", "Remove All Offline Messages")].
|
||||
|
||||
webadmin_user_parse_query(_, "removealloffline", User, Server, _Query) ->
|
||||
|
@ -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]).
|
||||
@ -495,12 +496,8 @@ user_queue_parse_query(Username, LServer, Query) ->
|
||||
us_to_list({User, Server}) ->
|
||||
exmpp_jid:to_list(User, Server).
|
||||
|
||||
webadmin_user(Acc, User, Server, Lang) ->
|
||||
FQueueLen = try
|
||||
LUser = exmpp_stringprep:nodeprep(User),
|
||||
LServer = exmpp_stringprep: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
|
||||
@ -508,12 +505,14 @@ webadmin_user(Acc, User, Server, Lang) ->
|
||||
SCount;
|
||||
_ ->
|
||||
0
|
||||
end,
|
||||
[?AC("queue/", QueueLen)]
|
||||
catch
|
||||
_ ->
|
||||
[?C("?")]
|
||||
end,
|
||||
end.
|
||||
|
||||
webadmin_user(Acc, User, Server, Lang) ->
|
||||
LUser = exmpp_stringprep:nodeprep(User),
|
||||
LServer = exmpp_stringprep: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")].
|
||||
|
||||
webadmin_user_parse_query(_, "removealloffline", User, Server, _Query) ->
|
||||
|
@ -1571,6 +1571,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',
|
||||
@ -1583,14 +1584,10 @@ list_given_users(Host, Users, Prefix, Lang, URLFunc) ->
|
||||
ServerB = list_to_binary(Server),
|
||||
UserB = list_to_binary(User),
|
||||
US = {UserB, ServerB},
|
||||
FQueueLen = try
|
||||
QueueLen = length(mnesia:dirty_read({offline_msg, US})),
|
||||
[?AC(URLFunc({users_queue, Prefix,
|
||||
QueueLenStr = get_offlinemsg_length(ModOffline, UserB, ServerB),
|
||||
FQueueLen = [?AC(URLFunc({users_queue, Prefix,
|
||||
User, Server}),
|
||||
pretty_string_int(QueueLen))]
|
||||
catch
|
||||
_:_ -> [#xmlcdata{cdata = <<"Can't access the offline messages storage.">>}]
|
||||
end,
|
||||
QueueLenStr)],
|
||||
FLast =
|
||||
case ejabberd_sm:get_user_resources(UserB, ServerB) of
|
||||
[] ->
|
||||
@ -1622,6 +1619,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