mirror of
https://github.com/processone/ejabberd.git
synced 2024-10-09 15:06:54 +02:00
* src/web/ejabberd_web_admin.erl: Run new hook
webadmin_user_parse_query when POST in web admin user page (thanks to Oleg Palij)(EJAB-747) * src/mod_offline.erl: Add button "Remove All Offline Messages" in a user page (thanks to Oleg Palij)(EJAB-747) * src/mod_offline_odbc.erl: Likewise SVN Revision: 1643
This commit is contained in:
parent
42115a8cfb
commit
2af52abdba
@ -1,5 +1,12 @@
|
||||
2008-10-12 Badlop <badlop@process-one.net>
|
||||
|
||||
* src/web/ejabberd_web_admin.erl: Run new hook
|
||||
webadmin_user_parse_query when POST in web admin user
|
||||
page (thanks to Oleg Palij)(EJAB-747)
|
||||
* src/mod_offline.erl: Add button "Remove All Offline Messages" in
|
||||
a user page (thanks to Oleg Palij)(EJAB-747)
|
||||
* src/mod_offline_odbc.erl: Likewise
|
||||
|
||||
* src/web/ejabberd_web_admin.erl: Improve Web Admin navigation
|
||||
menu for vhosts and nodes (EJAB-734)
|
||||
|
||||
|
@ -39,7 +39,8 @@
|
||||
remove_old_messages/1,
|
||||
remove_user/2,
|
||||
webadmin_page/3,
|
||||
webadmin_user/4]).
|
||||
webadmin_user/4,
|
||||
webadmin_user_parse_query/5]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("jlib.hrl").
|
||||
@ -69,6 +70,8 @@ start(Host, Opts) ->
|
||||
?MODULE, webadmin_page, 50),
|
||||
ejabberd_hooks:add(webadmin_user, Host,
|
||||
?MODULE, webadmin_user, 50),
|
||||
ejabberd_hooks:add(webadmin_user_parse_query, Host,
|
||||
?MODULE, webadmin_user_parse_query, 50),
|
||||
MaxOfflineMsgs = gen_mod:get_opt(user_max_messages, Opts, infinity),
|
||||
register(gen_mod:get_module_proc(Host, ?PROCNAME),
|
||||
spawn(?MODULE, init, [MaxOfflineMsgs])).
|
||||
@ -137,6 +140,8 @@ stop(Host) ->
|
||||
?MODULE, webadmin_page, 50),
|
||||
ejabberd_hooks:delete(webadmin_user, Host,
|
||||
?MODULE, webadmin_user, 50),
|
||||
ejabberd_hooks:delete(webadmin_user_parse_query, Host,
|
||||
?MODULE, webadmin_user_parse_query, 50),
|
||||
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
|
||||
exit(whereis(Proc), stop),
|
||||
{wait, Proc}.
|
||||
@ -554,4 +559,24 @@ webadmin_user(Acc, User, Server, Lang) ->
|
||||
QueueLen = length(mnesia:dirty_read({offline_msg, US})),
|
||||
FQueueLen = [?AC("queue/",
|
||||
integer_to_list(QueueLen))],
|
||||
Acc ++ [?XCT("h3", "Offline Messages:")] ++ FQueueLen.
|
||||
Acc ++ [?XCT("h3", "Offline Messages:")] ++ FQueueLen ++ [?C(" "), ?INPUTT("submit", "removealloffline", "Remove All Offline Messages")].
|
||||
|
||||
webadmin_user_parse_query(_, "removealloffline", User, Server, _Query) ->
|
||||
US = {User, Server},
|
||||
F = fun() ->
|
||||
mnesia:write_lock_table(offline_msg),
|
||||
lists:foreach(
|
||||
fun(Msg) ->
|
||||
mnesia:delete_object(Msg)
|
||||
end, mnesia:dirty_read({offline_msg, US}))
|
||||
end,
|
||||
case mnesia:transaction(F) of
|
||||
{aborted, Reason} ->
|
||||
?ERROR_MSG("Failed to remove offline messages: ~p", [Reason]),
|
||||
{stop, error};
|
||||
{atomic, ok} ->
|
||||
?INFO_MSG("Removed all offline messages for ~s@~s", [User, Server]),
|
||||
{stop, ok}
|
||||
end;
|
||||
webadmin_user_parse_query(Acc, _Action, _User, _Server, _Query) ->
|
||||
Acc.
|
||||
|
@ -38,7 +38,8 @@
|
||||
pop_offline_messages/3,
|
||||
remove_user/2,
|
||||
webadmin_page/3,
|
||||
webadmin_user/4]).
|
||||
webadmin_user/4,
|
||||
webadmin_user_parse_query/5]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("jlib.hrl").
|
||||
@ -63,6 +64,8 @@ start(Host, Opts) ->
|
||||
?MODULE, webadmin_page, 50),
|
||||
ejabberd_hooks:add(webadmin_user, Host,
|
||||
?MODULE, webadmin_user, 50),
|
||||
ejabberd_hooks:add(webadmin_user_parse_query, Host,
|
||||
?MODULE, webadmin_user_parse_query, 50),
|
||||
MaxOfflineMsgs = gen_mod:get_opt(user_max_messages, Opts, infinity),
|
||||
register(gen_mod:get_module_proc(Host, ?PROCNAME),
|
||||
spawn(?MODULE, init, [Host, MaxOfflineMsgs])).
|
||||
@ -149,6 +152,8 @@ stop(Host) ->
|
||||
?MODULE, webadmin_page, 50),
|
||||
ejabberd_hooks:delete(webadmin_user, Host,
|
||||
?MODULE, webadmin_user, 50),
|
||||
ejabberd_hooks:delete(webadmin_user_parse_query, Host,
|
||||
?MODULE, webadmin_user_parse_query, 50),
|
||||
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
|
||||
exit(whereis(Proc), stop),
|
||||
ok.
|
||||
@ -439,7 +444,22 @@ webadmin_user(Acc, User, Server, Lang) ->
|
||||
0
|
||||
end,
|
||||
FQueueLen = [?AC("queue/", QueueLen)],
|
||||
Acc ++ [?XCT("h3", "Offline Messages:")] ++ FQueueLen.
|
||||
Acc ++ [?XCT("h3", "Offline Messages:")] ++ FQueueLen ++ [?C(" "), ?INPUTT("submit", "removealloffline", "Remove All Offline Messages")].
|
||||
|
||||
webadmin_user_parse_query(_, "removealloffline", User, Server, _Query) ->
|
||||
case catch odbc_queries:del_spool_msg(Server, User) of
|
||||
{'EXIT', Reason} ->
|
||||
?ERROR_MSG("Failed to remove offline messages: ~p", [Reason]),
|
||||
{stop, error};
|
||||
{error, Reason} ->
|
||||
?ERROR_MSG("Failed to remove offline messages: ~p", [Reason]),
|
||||
{stop, error};
|
||||
_ ->
|
||||
?INFO_MSG("Removed all offline messages for ~s@~s", [User, Server]),
|
||||
{stop, ok}
|
||||
end;
|
||||
webadmin_user_parse_query(Acc, _Action, _User, _Server, _Query) ->
|
||||
Acc.
|
||||
|
||||
%% ------------------------------------------------
|
||||
%% mod_offline: number of messages quota management
|
||||
|
@ -1470,25 +1470,31 @@ user_info(User, Server, Query, Lang) ->
|
||||
|
||||
|
||||
user_parse_query(User, Server, Query) ->
|
||||
case lists:keysearch("chpassword", 1, Query) of
|
||||
{value, _} ->
|
||||
case lists:keysearch("password", 1, Query) of
|
||||
{value, {_, undefined}} ->
|
||||
error;
|
||||
{value, {_, Password}} ->
|
||||
ejabberd_auth:set_password(User, Server, Password),
|
||||
ok;
|
||||
_ ->
|
||||
error
|
||||
end;
|
||||
_ ->
|
||||
case lists:keysearch("removeuser", 1, Query) of
|
||||
{value, _} ->
|
||||
ejabberd_auth:remove_user(User, Server),
|
||||
ok;
|
||||
false ->
|
||||
nothing
|
||||
end
|
||||
lists:foldl(fun({Action, _Value}, Acc) when Acc == nothing ->
|
||||
user_parse_query1(Action, User, Server, Query);
|
||||
({_Action, _Value}, Acc) ->
|
||||
Acc
|
||||
end, nothing, Query).
|
||||
|
||||
user_parse_query1("password", _User, _Server, _Query) ->
|
||||
nothing;
|
||||
user_parse_query1("chpassword", User, Server, Query) ->
|
||||
case lists:keysearch("password", 1, Query) of
|
||||
{value, {_, undefined}} ->
|
||||
error;
|
||||
{value, {_, Password}} ->
|
||||
ejabberd_auth:set_password(User, Server, Password),
|
||||
ok;
|
||||
_ ->
|
||||
error
|
||||
end;
|
||||
user_parse_query1("removeuser", User, Server, _Query) ->
|
||||
ejabberd_auth:remove_user(User, Server),
|
||||
ok;
|
||||
user_parse_query1(Action, User, Server, Query) ->
|
||||
case ejabberd_hooks:run_fold(webadmin_user_parse_query, Server, [], [Action, User, Server, Query]) of
|
||||
[] -> nothing;
|
||||
Res -> Res
|
||||
end.
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user