25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

Support in user list page of WebAdmin when mod_offline is disabled (EJAB-377)

SVN Revision: 2878
This commit is contained in:
Badlop 2010-01-12 12:06:43 +00:00
parent a658348ac1
commit 9df6e1fe0a
3 changed files with 37 additions and 34 deletions

View File

@ -39,6 +39,7 @@
remove_expired_messages/0, remove_expired_messages/0,
remove_old_messages/1, remove_old_messages/1,
remove_user/2, remove_user/2,
get_queue_length/2,
webadmin_page/3, webadmin_page/3,
webadmin_user/4, webadmin_user/4,
webadmin_user_parse_query/5]). webadmin_user_parse_query/5]).
@ -702,19 +703,12 @@ user_queue_parse_query(US, Query) ->
us_to_list({User, Server}) -> us_to_list({User, Server}) ->
exmpp_jid: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) -> webadmin_user(Acc, User, Server, Lang) ->
FQueueLen = try QueueLen = get_queue_length(exmpp_stringprep:nodeprep(User), exmpp_stringprep:nameprep(Server)),
US = { FQueueLen = [?AC("queue/", integer_to_list(QueueLen))],
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,
Acc ++ [?XCT("h3", "Offline Messages:")] ++ FQueueLen ++ [?C(" "), ?INPUTT("submit", "removealloffline", "Remove All Offline Messages")]. Acc ++ [?XCT("h3", "Offline Messages:")] ++ FQueueLen ++ [?C(" "), ?INPUTT("submit", "removealloffline", "Remove All Offline Messages")].
webadmin_user_parse_query(_, "removealloffline", User, Server, _Query) -> webadmin_user_parse_query(_, "removealloffline", User, Server, _Query) ->

View File

@ -38,6 +38,7 @@
pop_offline_messages/3, pop_offline_messages/3,
get_sm_features/5, get_sm_features/5,
remove_user/2, remove_user/2,
get_queue_length/2,
webadmin_page/3, webadmin_page/3,
webadmin_user/4, webadmin_user/4,
webadmin_user_parse_query/5]). webadmin_user_parse_query/5]).
@ -495,12 +496,8 @@ user_queue_parse_query(Username, LServer, Query) ->
us_to_list({User, Server}) -> us_to_list({User, Server}) ->
exmpp_jid:to_list(User, Server). exmpp_jid:to_list(User, Server).
webadmin_user(Acc, User, Server, Lang) -> get_queue_length(Username, LServer) ->
FQueueLen = try case catch ejabberd_odbc:sql_query(
LUser = exmpp_stringprep:nodeprep(User),
LServer = exmpp_stringprep:nameprep(Server),
Username = ejabberd_odbc:escape(LUser),
QueueLen = case catch ejabberd_odbc:sql_query(
LServer, LServer,
["select count(*) from spool" ["select count(*) from spool"
" where username='", Username, "';"]) of " where username='", Username, "';"]) of
@ -508,12 +505,14 @@ webadmin_user(Acc, User, Server, Lang) ->
SCount; SCount;
_ -> _ ->
0 0
end, end.
[?AC("queue/", QueueLen)]
catch webadmin_user(Acc, User, Server, Lang) ->
_ -> LUser = exmpp_stringprep:nodeprep(User),
[?C("?")] LServer = exmpp_stringprep:nameprep(Server),
end, 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")]. Acc ++ [?XCT("h3", "Offline Messages:")] ++ FQueueLen ++ [?C(" "), ?INPUTT("submit", "removealloffline", "Remove All Offline Messages")].
webadmin_user_parse_query(_, "removealloffline", User, Server, _Query) -> webadmin_user_parse_query(_, "removealloffline", User, Server, _Query) ->

View File

@ -1571,6 +1571,7 @@ list_users_in_diapason(Host, Diap, Lang, URLFunc) ->
list_given_users(Host, Users, Prefix, Lang, URLFunc) -> list_given_users(Host, Users, Prefix, Lang, URLFunc) ->
ModLast = get_lastactivity_module(Host), ModLast = get_lastactivity_module(Host),
ModOffline = get_offlinemsg_module(Host),
?XE('table', ?XE('table',
[?XE('thead', [?XE('thead',
[?XE('tr', [?XE('tr',
@ -1583,14 +1584,10 @@ list_given_users(Host, Users, Prefix, Lang, URLFunc) ->
ServerB = list_to_binary(Server), ServerB = list_to_binary(Server),
UserB = list_to_binary(User), UserB = list_to_binary(User),
US = {UserB, ServerB}, US = {UserB, ServerB},
FQueueLen = try QueueLenStr = get_offlinemsg_length(ModOffline, UserB, ServerB),
QueueLen = length(mnesia:dirty_read({offline_msg, US})), FQueueLen = [?AC(URLFunc({users_queue, Prefix,
[?AC(URLFunc({users_queue, Prefix,
User, Server}), User, Server}),
pretty_string_int(QueueLen))] QueueLenStr)],
catch
_:_ -> [#xmlcdata{cdata = <<"Can't access the offline messages storage.">>}]
end,
FLast = FLast =
case ejabberd_sm:get_user_resources(UserB, ServerB) of case ejabberd_sm:get_user_resources(UserB, ServerB) of
[] -> [] ->
@ -1622,6 +1619,19 @@ list_given_users(Host, Users, Prefix, Lang, URLFunc) ->
end, Users) 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) -> get_lastactivity_module(Server) ->
case lists:member(mod_last, gen_mod:loaded_modules(Server)) of case lists:member(mod_last, gen_mod:loaded_modules(Server)) of
true -> mod_last; true -> mod_last;