mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-20 17:27:00 +01: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>
|
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
|
* src/web/ejabberd_web_admin.erl: Improve Web Admin navigation
|
||||||
menu for vhosts and nodes (EJAB-734)
|
menu for vhosts and nodes (EJAB-734)
|
||||||
|
|
||||||
|
@ -39,7 +39,8 @@
|
|||||||
remove_old_messages/1,
|
remove_old_messages/1,
|
||||||
remove_user/2,
|
remove_user/2,
|
||||||
webadmin_page/3,
|
webadmin_page/3,
|
||||||
webadmin_user/4]).
|
webadmin_user/4,
|
||||||
|
webadmin_user_parse_query/5]).
|
||||||
|
|
||||||
-include("ejabberd.hrl").
|
-include("ejabberd.hrl").
|
||||||
-include("jlib.hrl").
|
-include("jlib.hrl").
|
||||||
@ -69,6 +70,8 @@ start(Host, Opts) ->
|
|||||||
?MODULE, webadmin_page, 50),
|
?MODULE, webadmin_page, 50),
|
||||||
ejabberd_hooks:add(webadmin_user, Host,
|
ejabberd_hooks:add(webadmin_user, Host,
|
||||||
?MODULE, webadmin_user, 50),
|
?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),
|
MaxOfflineMsgs = gen_mod:get_opt(user_max_messages, Opts, infinity),
|
||||||
register(gen_mod:get_module_proc(Host, ?PROCNAME),
|
register(gen_mod:get_module_proc(Host, ?PROCNAME),
|
||||||
spawn(?MODULE, init, [MaxOfflineMsgs])).
|
spawn(?MODULE, init, [MaxOfflineMsgs])).
|
||||||
@ -137,6 +140,8 @@ stop(Host) ->
|
|||||||
?MODULE, webadmin_page, 50),
|
?MODULE, webadmin_page, 50),
|
||||||
ejabberd_hooks:delete(webadmin_user, Host,
|
ejabberd_hooks:delete(webadmin_user, Host,
|
||||||
?MODULE, webadmin_user, 50),
|
?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),
|
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
|
||||||
exit(whereis(Proc), stop),
|
exit(whereis(Proc), stop),
|
||||||
{wait, Proc}.
|
{wait, Proc}.
|
||||||
@ -554,4 +559,24 @@ webadmin_user(Acc, User, Server, Lang) ->
|
|||||||
QueueLen = length(mnesia:dirty_read({offline_msg, US})),
|
QueueLen = length(mnesia:dirty_read({offline_msg, US})),
|
||||||
FQueueLen = [?AC("queue/",
|
FQueueLen = [?AC("queue/",
|
||||||
integer_to_list(QueueLen))],
|
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,
|
pop_offline_messages/3,
|
||||||
remove_user/2,
|
remove_user/2,
|
||||||
webadmin_page/3,
|
webadmin_page/3,
|
||||||
webadmin_user/4]).
|
webadmin_user/4,
|
||||||
|
webadmin_user_parse_query/5]).
|
||||||
|
|
||||||
-include("ejabberd.hrl").
|
-include("ejabberd.hrl").
|
||||||
-include("jlib.hrl").
|
-include("jlib.hrl").
|
||||||
@ -63,6 +64,8 @@ start(Host, Opts) ->
|
|||||||
?MODULE, webadmin_page, 50),
|
?MODULE, webadmin_page, 50),
|
||||||
ejabberd_hooks:add(webadmin_user, Host,
|
ejabberd_hooks:add(webadmin_user, Host,
|
||||||
?MODULE, webadmin_user, 50),
|
?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),
|
MaxOfflineMsgs = gen_mod:get_opt(user_max_messages, Opts, infinity),
|
||||||
register(gen_mod:get_module_proc(Host, ?PROCNAME),
|
register(gen_mod:get_module_proc(Host, ?PROCNAME),
|
||||||
spawn(?MODULE, init, [Host, MaxOfflineMsgs])).
|
spawn(?MODULE, init, [Host, MaxOfflineMsgs])).
|
||||||
@ -149,6 +152,8 @@ stop(Host) ->
|
|||||||
?MODULE, webadmin_page, 50),
|
?MODULE, webadmin_page, 50),
|
||||||
ejabberd_hooks:delete(webadmin_user, Host,
|
ejabberd_hooks:delete(webadmin_user, Host,
|
||||||
?MODULE, webadmin_user, 50),
|
?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),
|
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
|
||||||
exit(whereis(Proc), stop),
|
exit(whereis(Proc), stop),
|
||||||
ok.
|
ok.
|
||||||
@ -439,7 +444,22 @@ webadmin_user(Acc, User, Server, Lang) ->
|
|||||||
0
|
0
|
||||||
end,
|
end,
|
||||||
FQueueLen = [?AC("queue/", QueueLen)],
|
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
|
%% mod_offline: number of messages quota management
|
||||||
|
@ -1470,8 +1470,15 @@ user_info(User, Server, Query, Lang) ->
|
|||||||
|
|
||||||
|
|
||||||
user_parse_query(User, Server, Query) ->
|
user_parse_query(User, Server, Query) ->
|
||||||
case lists:keysearch("chpassword", 1, Query) of
|
lists:foldl(fun({Action, _Value}, Acc) when Acc == nothing ->
|
||||||
{value, _} ->
|
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
|
case lists:keysearch("password", 1, Query) of
|
||||||
{value, {_, undefined}} ->
|
{value, {_, undefined}} ->
|
||||||
error;
|
error;
|
||||||
@ -1481,14 +1488,13 @@ user_parse_query(User, Server, Query) ->
|
|||||||
_ ->
|
_ ->
|
||||||
error
|
error
|
||||||
end;
|
end;
|
||||||
_ ->
|
user_parse_query1("removeuser", User, Server, _Query) ->
|
||||||
case lists:keysearch("removeuser", 1, Query) of
|
|
||||||
{value, _} ->
|
|
||||||
ejabberd_auth:remove_user(User, Server),
|
ejabberd_auth:remove_user(User, Server),
|
||||||
ok;
|
ok;
|
||||||
false ->
|
user_parse_query1(Action, User, Server, Query) ->
|
||||||
nothing
|
case ejabberd_hooks:run_fold(webadmin_user_parse_query, Server, [], [Action, User, Server, Query]) of
|
||||||
end
|
[] -> nothing;
|
||||||
|
Res -> Res
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user