mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-22 17:28:25 +01:00
WebAdmin: Improve pages to handle disabled modules
This commit is contained in:
parent
b2e6749fd2
commit
c900f0ad83
@ -747,46 +747,99 @@ list_users(Host, Level, PageSize, RPath, R, RegisterEl) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
list_users(Host, Level, PageSize, RPath, R, Usernames, RegisterEl) ->
|
list_users(Host, Level, PageSize, RPath, R, Usernames, RegisterEl) ->
|
||||||
|
IsOffline = gen_mod:is_loaded(Host, mod_offline),
|
||||||
|
IsMam = gen_mod:is_loaded(Host, mod_mam),
|
||||||
|
IsRoster = gen_mod:is_loaded(Host, mod_roster),
|
||||||
|
IsLast = gen_mod:is_loaded(Host, mod_last),
|
||||||
Columns =
|
Columns =
|
||||||
[<<"user">>,
|
[<<"user">>,
|
||||||
{<<"offline">>, right},
|
list_users_element(IsOffline, column, offline, {}),
|
||||||
{<<"roster">>, right},
|
list_users_element(IsMam, column, mam, {}),
|
||||||
{<<"timestamp">>, left},
|
list_users_element(IsRoster, column, roster, {}),
|
||||||
{<<"status">>, left}],
|
list_users_element(IsLast, column, timestamp, {}),
|
||||||
|
list_users_element(IsLast, column, status, {})],
|
||||||
Rows =
|
Rows =
|
||||||
[{make_command(echo,
|
[list_to_tuple(lists:flatten([make_command(echo,
|
||||||
R,
|
R,
|
||||||
[{<<"sentence">>,
|
[{<<"sentence">>,
|
||||||
jid:encode(
|
jid:encode(
|
||||||
jid:make(Username, Host))}],
|
jid:make(Username, Host))}],
|
||||||
[{only, raw_and_value}, {result_links, [{sentence, user, Level, <<"">>}]}]),
|
[{only, raw_and_value},
|
||||||
|
{result_links,
|
||||||
|
[{sentence, user, Level, <<"">>}]}]),
|
||||||
|
list_users_element(IsOffline,
|
||||||
|
row,
|
||||||
|
offline,
|
||||||
|
{R, Username, Host, Level}),
|
||||||
|
list_users_element(IsMam,
|
||||||
|
row,
|
||||||
|
mam,
|
||||||
|
{R, Username, Host, Level}),
|
||||||
|
list_users_element(IsRoster,
|
||||||
|
row,
|
||||||
|
roster,
|
||||||
|
{R, Username, Host, Level}),
|
||||||
|
list_users_element(IsLast, row, last, {R, Username, Host})]))
|
||||||
|
|| Username <- Usernames],
|
||||||
|
Table = make_table(PageSize, RPath, lists:flatten(Columns), Rows),
|
||||||
|
Result =
|
||||||
|
[RegisterEl,
|
||||||
|
make_command(registered_users, R, [], [{only, presentation}]),
|
||||||
|
list_users_element(IsOffline, presentation, offline, R),
|
||||||
|
list_users_element(IsMam, presentation, mam, R),
|
||||||
|
list_users_element(IsRoster, presentation, roster, R),
|
||||||
|
list_users_element(IsLast, presentation, last, R),
|
||||||
|
Table],
|
||||||
|
lists:flatten(Result).
|
||||||
|
|
||||||
|
list_users_element(false, _, _, _) ->
|
||||||
|
[];
|
||||||
|
list_users_element(_, column, offline, _) ->
|
||||||
|
{<<"offline">>, right};
|
||||||
|
list_users_element(_, column, mam, _) ->
|
||||||
|
{<<"mam">>, right};
|
||||||
|
list_users_element(_, column, roster, _) ->
|
||||||
|
{<<"roster">>, right};
|
||||||
|
list_users_element(_, column, timestamp, _) ->
|
||||||
|
{<<"timestamp">>, left};
|
||||||
|
list_users_element(_, column, status, _) ->
|
||||||
|
{<<"status">>, left};
|
||||||
|
list_users_element(_, row, offline, {R, Username, Host, Level}) ->
|
||||||
make_command(get_offline_count,
|
make_command(get_offline_count,
|
||||||
R,
|
R,
|
||||||
[{<<"user">>, Username}, {<<"host">>, Host}],
|
[{<<"user">>, Username}, {<<"host">>, Host}],
|
||||||
[{only, raw_and_value},
|
[{only, raw_and_value},
|
||||||
{result_links,
|
{result_links,
|
||||||
[{value, arg_host, Level, <<"user/", Username/binary, "/queue/">>}]}]),
|
[{value, arg_host, Level, <<"user/", Username/binary, "/queue/">>}]}]);
|
||||||
|
list_users_element(_, row, mam, {R, Username, Host, Level}) ->
|
||||||
|
make_command(get_mam_count,
|
||||||
|
R,
|
||||||
|
[{<<"user">>, Username}, {<<"host">>, Host}],
|
||||||
|
[{only, raw_and_value},
|
||||||
|
{result_links,
|
||||||
|
[{value, arg_host, Level, <<"user/", Username/binary, "/mam/">>}]}]);
|
||||||
|
list_users_element(_, row, roster, {R, Username, Host, Level}) ->
|
||||||
make_command(get_roster_count,
|
make_command(get_roster_count,
|
||||||
R,
|
R,
|
||||||
[{<<"user">>, Username}, {<<"host">>, Host}],
|
[{<<"user">>, Username}, {<<"host">>, Host}],
|
||||||
[{only, raw_and_value},
|
[{only, raw_and_value},
|
||||||
{result_links,
|
{result_links,
|
||||||
[{value, arg_host, Level, <<"user/", Username/binary, "/roster/">>}]}]),
|
[{value, arg_host, Level, <<"user/", Username/binary, "/roster/">>}]}]);
|
||||||
?C(element(1,
|
list_users_element(_, row, last, {R, Username, Host}) ->
|
||||||
make_command_raw_value(get_last,
|
[?C(element(1,
|
||||||
R,
|
make_command_raw_value(get_last, R, [{<<"user">>, Username}, {<<"host">>, Host}]))),
|
||||||
[{<<"user">>, Username}, {<<"host">>, Host}]))),
|
|
||||||
?C(element(2,
|
?C(element(2,
|
||||||
make_command_raw_value(get_last,
|
make_command_raw_value(get_last,
|
||||||
R,
|
R,
|
||||||
[{<<"user">>, Username}, {<<"host">>, Host}])))}
|
[{<<"user">>, Username}, {<<"host">>, Host}])))];
|
||||||
|| Username <- Usernames],
|
list_users_element(_, presentation, offline, R) ->
|
||||||
[RegisterEl,
|
make_command(get_offline_count, R, [], [{only, presentation}]);
|
||||||
make_command(registered_users, R, [], [{only, presentation}]),
|
list_users_element(_, presentation, mam, R) ->
|
||||||
make_command(get_offline_count, R, [], [{only, presentation}]),
|
make_command(get_mam_count, R, [], [{only, presentation}]);
|
||||||
make_command(get_roster_count, R, [], [{only, presentation}]),
|
list_users_element(_, presentation, roster, R) ->
|
||||||
make_command(get_last, R, [], [{only, presentation}]),
|
make_command(get_roster_count, R, [], [{only, presentation}]);
|
||||||
make_table(PageSize, RPath, Columns, Rows)].
|
list_users_element(_, presentation, last, R) ->
|
||||||
|
make_command(get_last, R, [], [{only, presentation}]).
|
||||||
|
|
||||||
list_users_diapason(Host, R, Usernames, N, RegisterEl) ->
|
list_users_diapason(Host, R, Usernames, N, RegisterEl) ->
|
||||||
URLFunc = fun url_func/1,
|
URLFunc = fun url_func/1,
|
||||||
@ -952,6 +1005,17 @@ user_info(User, Server, #request{q = Query, lang = Lang} = R) ->
|
|||||||
Res = user_parse_query(User, Server, Query),
|
Res = user_parse_query(User, Server, Query),
|
||||||
UserItems = ejabberd_hooks:run_fold(webadmin_user,
|
UserItems = ejabberd_hooks:run_fold(webadmin_user,
|
||||||
LServer, [], [User, Server, R]),
|
LServer, [], [User, Server, R]),
|
||||||
|
Lasts = case gen_mod:is_loaded(Server, mod_last) of
|
||||||
|
true ->
|
||||||
|
[make_command(get_last, R,
|
||||||
|
[{<<"user">>, User}, {<<"host">>, Server}],
|
||||||
|
[]),
|
||||||
|
make_command(set_last, R,
|
||||||
|
[{<<"user">>, User}, {<<"host">>, Server}],
|
||||||
|
[])];
|
||||||
|
false ->
|
||||||
|
[]
|
||||||
|
end,
|
||||||
[?XC(<<"h1">>, (str:translate_and_format(Lang, ?T("User ~ts"),
|
[?XC(<<"h1">>, (str:translate_and_format(Lang, ?T("User ~ts"),
|
||||||
[us_to_list(US)])))]
|
[us_to_list(US)])))]
|
||||||
++
|
++
|
||||||
@ -968,13 +1032,8 @@ user_info(User, Server, #request{q = Query, lang = Lang} = R) ->
|
|||||||
[{result_links, [{node, node, 4, <<>>}]}]),
|
[{result_links, [{node, node, 4, <<>>}]}]),
|
||||||
make_command(change_password, R,
|
make_command(change_password, R,
|
||||||
[{<<"user">>, User}, {<<"host">>, Server}],
|
[{<<"user">>, User}, {<<"host">>, Server}],
|
||||||
[{style, danger}]),
|
[{style, danger}])] ++
|
||||||
make_command(get_last, R,
|
Lasts ++
|
||||||
[{<<"user">>, User}, {<<"host">>, Server}],
|
|
||||||
[]),
|
|
||||||
make_command(set_last, R,
|
|
||||||
[{<<"user">>, User}, {<<"host">>, Server}],
|
|
||||||
[])] ++
|
|
||||||
UserItems ++
|
UserItems ++
|
||||||
[?P,
|
[?P,
|
||||||
make_command(unregister, R,
|
make_command(unregister, R,
|
||||||
|
Loading…
Reference in New Issue
Block a user