2003-01-19 21:17:56 +01:00
|
|
|
%%%----------------------------------------------------------------------
|
|
|
|
%%% File : mod_configure.erl
|
|
|
|
%%% Author : Alexey Shchepin <alexey@sevcom.net>
|
2003-02-23 21:13:39 +01:00
|
|
|
%%% Purpose : Support for online configuration of ejabberd
|
2003-01-19 21:17:56 +01:00
|
|
|
%%% Created : 19 Jan 2003 by Alexey Shchepin <alexey@sevcom.net>
|
|
|
|
%%% Id : $Id$
|
|
|
|
%%%----------------------------------------------------------------------
|
|
|
|
|
|
|
|
-module(mod_configure).
|
|
|
|
-author('alexey@sevcom.net').
|
|
|
|
-vsn('$Revision$ ').
|
|
|
|
|
2003-01-24 21:18:33 +01:00
|
|
|
-behaviour(gen_mod).
|
|
|
|
|
2005-06-20 05:18:13 +02:00
|
|
|
-export([start/2,
|
|
|
|
stop/1,
|
2003-01-21 21:36:55 +01:00
|
|
|
process_local_iq/3,
|
|
|
|
process_sm_iq/3]).
|
2003-01-19 21:17:56 +01:00
|
|
|
|
|
|
|
-include("ejabberd.hrl").
|
2003-03-09 21:46:47 +01:00
|
|
|
-include("jlib.hrl").
|
2003-01-19 21:17:56 +01:00
|
|
|
|
|
|
|
|
2005-06-20 05:18:13 +02:00
|
|
|
start(Host, Opts) ->
|
2003-01-24 21:18:33 +01:00
|
|
|
IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
|
2005-06-20 05:18:13 +02:00
|
|
|
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_EJABBERD_CONFIG,
|
2003-01-24 21:18:33 +01:00
|
|
|
?MODULE, process_local_iq, IQDisc),
|
2005-06-20 05:18:13 +02:00
|
|
|
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_EJABBERD_CONFIG,
|
2003-01-24 21:18:33 +01:00
|
|
|
?MODULE, process_sm_iq, IQDisc),
|
2003-01-21 21:36:55 +01:00
|
|
|
ok.
|
2003-01-19 21:17:56 +01:00
|
|
|
|
2005-06-20 05:18:13 +02:00
|
|
|
stop(Host) ->
|
|
|
|
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_EJABBERD_CONFIG),
|
|
|
|
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_EJABBERD_CONFIG).
|
2003-01-29 18:12:23 +01:00
|
|
|
|
2003-01-19 21:17:56 +01:00
|
|
|
|
2005-06-20 05:18:13 +02:00
|
|
|
process_local_iq(From, To, #iq{id = ID, type = Type, xmlns = XMLNS,
|
2004-02-26 23:00:04 +01:00
|
|
|
lang = Lang, sub_el = SubEl} = IQ) ->
|
2005-06-20 05:18:13 +02:00
|
|
|
case acl:match_rule(To#jid.lserver, configure, From) of
|
2003-01-19 21:17:56 +01:00
|
|
|
deny ->
|
2003-12-17 21:13:21 +01:00
|
|
|
IQ#iq{type = error, sub_el = [SubEl, ?ERR_NOT_ALLOWED]};
|
2003-01-19 21:17:56 +01:00
|
|
|
allow ->
|
|
|
|
case Type of
|
|
|
|
set ->
|
2004-02-15 21:10:40 +01:00
|
|
|
XDataEl = find_xdata_el(SubEl),
|
|
|
|
case XDataEl of
|
|
|
|
false ->
|
|
|
|
IQ#iq{type = error, sub_el = [SubEl, ?ERR_NOT_ACCEPTABLE]};
|
|
|
|
{xmlelement, _Name, Attrs, SubEls} ->
|
|
|
|
case xml:get_attr_s("type", Attrs) of
|
|
|
|
"cancel" ->
|
|
|
|
IQ#iq{type = result,
|
|
|
|
sub_el = [{xmlelement, "query",
|
|
|
|
[{"xmlns", XMLNS}], []}]};
|
|
|
|
"submit" ->
|
|
|
|
XData = jlib:parse_xdata_submit(XDataEl),
|
|
|
|
case XData of
|
|
|
|
invalid ->
|
2003-12-17 21:13:21 +01:00
|
|
|
IQ#iq{type = error,
|
2004-02-15 21:10:40 +01:00
|
|
|
sub_el = [SubEl, ?ERR_BAD_REQUEST]};
|
|
|
|
_ ->
|
|
|
|
Node =
|
|
|
|
string:tokens(
|
|
|
|
xml:get_tag_attr_s("node", SubEl),
|
|
|
|
"/"),
|
|
|
|
case set_form(Node, Lang, XData) of
|
|
|
|
{result, Res} ->
|
|
|
|
IQ#iq{type = result,
|
|
|
|
sub_el =
|
|
|
|
[{xmlelement, "query",
|
|
|
|
[{"xmlns", XMLNS}],
|
|
|
|
Res
|
|
|
|
}]};
|
|
|
|
{error, Error} ->
|
|
|
|
IQ#iq{type = error,
|
|
|
|
sub_el = [SubEl, Error]}
|
|
|
|
end
|
|
|
|
end;
|
|
|
|
_ ->
|
|
|
|
IQ#iq{type = error,
|
|
|
|
sub_el = [SubEl, ?ERR_BAD_REQUEST]}
|
|
|
|
end
|
2003-01-19 21:17:56 +01:00
|
|
|
end;
|
|
|
|
get ->
|
|
|
|
Node =
|
|
|
|
string:tokens(xml:get_tag_attr_s("node", SubEl), "/"),
|
|
|
|
case get_form(Node, Lang) of
|
|
|
|
{result, Res} ->
|
2003-12-17 21:13:21 +01:00
|
|
|
IQ#iq{type = result,
|
|
|
|
sub_el =
|
|
|
|
[{xmlelement, "query", [{"xmlns", XMLNS}],
|
|
|
|
Res
|
|
|
|
}]};
|
2003-03-09 21:46:47 +01:00
|
|
|
{error, Error} ->
|
2003-12-17 21:13:21 +01:00
|
|
|
IQ#iq{type = error,
|
|
|
|
sub_el = [SubEl, Error]}
|
2003-01-19 21:17:56 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end.
|
|
|
|
|
|
|
|
-define(TLFIELD(Type, Label, Var),
|
|
|
|
{xmlelement, "field", [{"type", Type},
|
|
|
|
{"label", translate:translate(Lang, Label)},
|
|
|
|
{"var", Var}], []}).
|
|
|
|
|
2003-01-21 21:36:55 +01:00
|
|
|
-define(XFIELD(Type, Label, Var, Val),
|
|
|
|
{xmlelement, "field", [{"type", Type},
|
|
|
|
{"label", translate:translate(Lang, Label)},
|
|
|
|
{"var", Var}],
|
|
|
|
[{xmlelement, "value", [], [{xmlcdata, Val}]}]}).
|
|
|
|
|
2003-01-19 21:17:56 +01:00
|
|
|
-define(TABLEFIELD(Table, Val),
|
|
|
|
{xmlelement, "field", [{"type", "list-single"},
|
|
|
|
{"label", atom_to_list(Table)},
|
|
|
|
{"var", atom_to_list(Table)}],
|
|
|
|
[{xmlelement, "value", [], [{xmlcdata, atom_to_list(Val)}]},
|
|
|
|
{xmlelement, "option", [{"label",
|
|
|
|
translate:translate(Lang, "RAM copy")}],
|
|
|
|
[{xmlelement, "value", [], [{xmlcdata, "ram_copies"}]}]},
|
|
|
|
{xmlelement, "option", [{"label",
|
|
|
|
translate:translate(Lang,
|
|
|
|
"RAM and disc copy")}],
|
|
|
|
[{xmlelement, "value", [], [{xmlcdata, "disc_copies"}]}]},
|
|
|
|
{xmlelement, "option", [{"label",
|
2003-01-21 21:36:55 +01:00
|
|
|
translate:translate(Lang,
|
|
|
|
"Disc only copy")}],
|
2003-01-19 21:17:56 +01:00
|
|
|
[{xmlelement, "value", [], [{xmlcdata, "disc_only_copies"}]}]},
|
|
|
|
{xmlelement, "option", [{"label",
|
|
|
|
translate:translate(Lang, "Remote copy")}],
|
|
|
|
[{xmlelement, "value", [], [{xmlcdata, "unknown"}]}]}
|
|
|
|
]}).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
get_form(["running nodes", ENode, "DB"], Lang) ->
|
|
|
|
case search_running_node(ENode) of
|
|
|
|
false ->
|
2003-10-16 20:17:44 +02:00
|
|
|
{error, ?ERR_ITEM_NOT_FOUND};
|
2003-01-19 21:17:56 +01:00
|
|
|
Node ->
|
|
|
|
case rpc:call(Node, mnesia, system_info, [tables]) of
|
2003-12-17 21:13:21 +01:00
|
|
|
{badrpc, _Reason} ->
|
2003-03-09 21:46:47 +01:00
|
|
|
{error, ?ERR_INTERNAL_SERVER_ERROR};
|
2003-01-19 21:17:56 +01:00
|
|
|
Tables ->
|
2003-01-21 21:36:55 +01:00
|
|
|
STables = lists:sort(Tables),
|
2004-02-15 21:10:40 +01:00
|
|
|
{result, [{xmlelement, "x", [{"xmlns", ?NS_XDATA}],
|
|
|
|
[{xmlelement, "title", [],
|
|
|
|
[{xmlcdata,
|
|
|
|
translate:translate(
|
2004-02-26 23:00:04 +01:00
|
|
|
Lang, "DB Tables Configuration at ") ++
|
|
|
|
ENode}]},
|
2004-02-15 21:10:40 +01:00
|
|
|
{xmlelement, "instructions", [],
|
|
|
|
[{xmlcdata,
|
|
|
|
translate:translate(
|
|
|
|
Lang, "Choose storage type of tables")}]} |
|
|
|
|
lists:map(
|
|
|
|
fun(Table) ->
|
|
|
|
case rpc:call(Node,
|
|
|
|
mnesia,
|
|
|
|
table_info,
|
|
|
|
[Table, storage_type]) of
|
|
|
|
{badrpc, _} ->
|
|
|
|
?TABLEFIELD(Table, unknown);
|
|
|
|
Type ->
|
|
|
|
?TABLEFIELD(Table, Type)
|
|
|
|
end
|
|
|
|
end, STables)
|
|
|
|
]}]}
|
2003-01-19 21:17:56 +01:00
|
|
|
end
|
|
|
|
end;
|
|
|
|
|
2003-01-28 20:45:13 +01:00
|
|
|
get_form(["running nodes", ENode, "modules", "stop"], Lang) ->
|
|
|
|
case search_running_node(ENode) of
|
|
|
|
false ->
|
2003-10-16 20:17:44 +02:00
|
|
|
{error, ?ERR_ITEM_NOT_FOUND};
|
2003-01-28 20:45:13 +01:00
|
|
|
Node ->
|
|
|
|
case rpc:call(Node, gen_mod, loaded_modules, []) of
|
2003-12-17 21:13:21 +01:00
|
|
|
{badrpc, _Reason} ->
|
2003-03-09 21:46:47 +01:00
|
|
|
{error, ?ERR_INTERNAL_SERVER_ERROR};
|
2003-01-28 20:45:13 +01:00
|
|
|
Modules ->
|
|
|
|
SModules = lists:sort(Modules),
|
2004-02-15 21:10:40 +01:00
|
|
|
{result, [{xmlelement, "x", [{"xmlns", ?NS_XDATA}],
|
|
|
|
[{xmlelement, "title", [],
|
|
|
|
[{xmlcdata,
|
|
|
|
translate:translate(
|
2004-02-26 23:00:04 +01:00
|
|
|
Lang, "Stop Modules at ") ++ ENode}]},
|
2004-02-15 21:10:40 +01:00
|
|
|
{xmlelement, "instructions", [],
|
|
|
|
[{xmlcdata,
|
|
|
|
translate:translate(
|
|
|
|
Lang, "Choose modules to stop")}]} |
|
|
|
|
lists:map(fun(M) ->
|
|
|
|
S = atom_to_list(M),
|
|
|
|
?XFIELD("boolean", S, S, "0")
|
|
|
|
end, SModules)
|
|
|
|
]}]}
|
2003-01-28 20:45:13 +01:00
|
|
|
end
|
|
|
|
end;
|
|
|
|
|
|
|
|
get_form(["running nodes", ENode, "modules", "start"], Lang) ->
|
2004-02-15 21:10:40 +01:00
|
|
|
{result, [{xmlelement, "x", [{"xmlns", ?NS_XDATA}],
|
|
|
|
[{xmlelement, "title", [],
|
|
|
|
[{xmlcdata,
|
|
|
|
translate:translate(
|
2004-02-26 23:00:04 +01:00
|
|
|
Lang, "Start Modules at ") ++ ENode}]},
|
2004-02-15 21:10:40 +01:00
|
|
|
{xmlelement, "instructions", [],
|
|
|
|
[{xmlcdata,
|
|
|
|
translate:translate(
|
|
|
|
Lang, "Enter list of {Module, [Options]}")}]},
|
|
|
|
{xmlelement, "field", [{"type", "text-multi"},
|
|
|
|
{"label",
|
|
|
|
translate:translate(
|
|
|
|
Lang, "List of modules to start")},
|
|
|
|
{"var", "modules"}],
|
|
|
|
[{xmlelement, "value", [], [{xmlcdata, "[]."}]}]
|
|
|
|
}
|
|
|
|
]}]};
|
2003-01-28 20:45:13 +01:00
|
|
|
|
2003-02-22 20:11:00 +01:00
|
|
|
get_form(["running nodes", ENode, "backup", "backup"], Lang) ->
|
2004-02-15 21:10:40 +01:00
|
|
|
{result, [{xmlelement, "x", [{"xmlns", ?NS_XDATA}],
|
|
|
|
[{xmlelement, "title", [],
|
|
|
|
[{xmlcdata,
|
|
|
|
translate:translate(
|
2004-02-26 23:00:04 +01:00
|
|
|
Lang, "Backup to File at ") ++ ENode}]},
|
2004-02-15 21:10:40 +01:00
|
|
|
{xmlelement, "instructions", [],
|
|
|
|
[{xmlcdata,
|
|
|
|
translate:translate(
|
|
|
|
Lang, "Enter path to backup file")}]},
|
|
|
|
{xmlelement, "field", [{"type", "text-single"},
|
|
|
|
{"label",
|
|
|
|
translate:translate(
|
|
|
|
Lang, "Path to File")},
|
|
|
|
{"var", "path"}],
|
|
|
|
[{xmlelement, "value", [], [{xmlcdata, ""}]}]
|
|
|
|
}
|
|
|
|
]}]};
|
2003-02-22 20:11:00 +01:00
|
|
|
|
|
|
|
get_form(["running nodes", ENode, "backup", "restore"], Lang) ->
|
2004-02-15 21:10:40 +01:00
|
|
|
{result, [{xmlelement, "x", [{"xmlns", ?NS_XDATA}],
|
|
|
|
[{xmlelement, "title", [],
|
|
|
|
[{xmlcdata,
|
|
|
|
translate:translate(
|
2004-02-26 23:00:04 +01:00
|
|
|
Lang, "Restore Backup from File at ") ++ ENode}]},
|
2004-02-15 21:10:40 +01:00
|
|
|
{xmlelement, "instructions", [],
|
|
|
|
[{xmlcdata,
|
|
|
|
translate:translate(
|
|
|
|
Lang, "Enter path to backup file")}]},
|
|
|
|
{xmlelement, "field", [{"type", "text-single"},
|
|
|
|
{"label",
|
|
|
|
translate:translate(
|
|
|
|
Lang, "Path to File")},
|
|
|
|
{"var", "path"}],
|
|
|
|
[{xmlelement, "value", [], [{xmlcdata, ""}]}]
|
|
|
|
}
|
|
|
|
]}]};
|
2003-02-22 20:11:00 +01:00
|
|
|
|
|
|
|
get_form(["running nodes", ENode, "backup", "textfile"], Lang) ->
|
2004-02-15 21:10:40 +01:00
|
|
|
{result, [{xmlelement, "x", [{"xmlns", ?NS_XDATA}],
|
|
|
|
[{xmlelement, "title", [],
|
|
|
|
[{xmlcdata,
|
|
|
|
translate:translate(
|
2004-02-26 23:00:04 +01:00
|
|
|
Lang, "Dump Backup to Text File at ") ++ ENode}]},
|
2004-02-15 21:10:40 +01:00
|
|
|
{xmlelement, "instructions", [],
|
|
|
|
[{xmlcdata,
|
|
|
|
translate:translate(
|
|
|
|
Lang, "Enter path to text file")}]},
|
|
|
|
{xmlelement, "field", [{"type", "text-single"},
|
|
|
|
{"label",
|
|
|
|
translate:translate(
|
|
|
|
Lang, "Path to File")},
|
|
|
|
{"var", "path"}],
|
|
|
|
[{xmlelement, "value", [], [{xmlcdata, ""}]}]
|
|
|
|
}
|
|
|
|
]}]};
|
2003-02-22 20:11:00 +01:00
|
|
|
|
2003-02-04 21:45:23 +01:00
|
|
|
get_form(["running nodes", ENode, "import", "file"], Lang) ->
|
2004-02-15 21:10:40 +01:00
|
|
|
{result, [{xmlelement, "x", [{"xmlns", ?NS_XDATA}],
|
|
|
|
[{xmlelement, "title", [],
|
|
|
|
[{xmlcdata,
|
|
|
|
translate:translate(
|
2004-02-26 23:00:04 +01:00
|
|
|
Lang, "Import User from File at ") ++ ENode}]},
|
2004-02-15 21:10:40 +01:00
|
|
|
{xmlelement, "instructions", [],
|
|
|
|
[{xmlcdata,
|
|
|
|
translate:translate(
|
|
|
|
Lang, "Enter path to jabberd1.4 spool file")}]},
|
|
|
|
{xmlelement, "field", [{"type", "text-single"},
|
|
|
|
{"label",
|
|
|
|
translate:translate(
|
|
|
|
Lang, "Path to File")},
|
|
|
|
{"var", "path"}],
|
|
|
|
[{xmlelement, "value", [], [{xmlcdata, ""}]}]
|
|
|
|
}
|
|
|
|
]}]};
|
2003-02-04 21:45:23 +01:00
|
|
|
|
|
|
|
get_form(["running nodes", ENode, "import", "dir"], Lang) ->
|
2004-02-15 21:10:40 +01:00
|
|
|
{result, [{xmlelement, "x", [{"xmlns", ?NS_XDATA}],
|
|
|
|
[{xmlelement, "title", [],
|
|
|
|
[{xmlcdata,
|
|
|
|
translate:translate(
|
2004-02-26 23:00:04 +01:00
|
|
|
Lang, "Import Users from Dir at ") ++ ENode}]},
|
2004-02-15 21:10:40 +01:00
|
|
|
{xmlelement, "instructions", [],
|
|
|
|
[{xmlcdata,
|
|
|
|
translate:translate(
|
|
|
|
Lang, "Enter path to jabberd1.4 spool dir")}]},
|
|
|
|
{xmlelement, "field", [{"type", "text-single"},
|
|
|
|
{"label",
|
|
|
|
translate:translate(
|
|
|
|
Lang, "Path to Dir")},
|
|
|
|
{"var", "path"}],
|
|
|
|
[{xmlelement, "value", [], [{xmlcdata, ""}]}]
|
|
|
|
}
|
|
|
|
]}]};
|
2003-02-04 21:45:23 +01:00
|
|
|
|
2003-01-21 21:36:55 +01:00
|
|
|
get_form(["config", "hostname"], Lang) ->
|
2004-02-15 21:10:40 +01:00
|
|
|
{result, [{xmlelement, "x", [{"xmlns", ?NS_XDATA}],
|
|
|
|
[{xmlelement, "title", [],
|
|
|
|
[{xmlcdata,
|
|
|
|
translate:translate(
|
|
|
|
Lang, "Hostname Configuration")}]},
|
|
|
|
{xmlelement, "instructions", [],
|
|
|
|
[{xmlcdata,
|
|
|
|
translate:translate(
|
|
|
|
Lang, "Choose host name")}]},
|
|
|
|
{xmlelement, "field", [{"type", "text-single"},
|
|
|
|
{"label",
|
2004-02-26 23:00:04 +01:00
|
|
|
translate:translate(Lang,
|
|
|
|
"Host name")},
|
2004-02-15 21:10:40 +01:00
|
|
|
{"var", "hostname"}],
|
|
|
|
[{xmlelement, "value", [], [{xmlcdata, ?MYNAME}]}]}
|
|
|
|
]}]};
|
2003-01-21 21:36:55 +01:00
|
|
|
|
2003-01-22 21:40:40 +01:00
|
|
|
get_form(["config", "acls"], Lang) ->
|
2004-02-15 21:10:40 +01:00
|
|
|
{result, [{xmlelement, "x", [{"xmlns", ?NS_XDATA}],
|
|
|
|
[{xmlelement, "title", [],
|
|
|
|
[{xmlcdata,
|
|
|
|
translate:translate(
|
2004-02-26 23:00:04 +01:00
|
|
|
Lang, "Access Control List Configuration")}]},
|
2004-02-15 21:10:40 +01:00
|
|
|
%{xmlelement, "instructions", [],
|
|
|
|
% [{xmlcdata,
|
|
|
|
% translate:translate(
|
|
|
|
% Lang, "")}]},
|
|
|
|
{xmlelement, "field", [{"type", "text-multi"},
|
|
|
|
{"label",
|
2004-02-26 23:00:04 +01:00
|
|
|
translate:translate(
|
|
|
|
Lang, "Access control lists")},
|
2004-02-15 21:10:40 +01:00
|
|
|
{"var", "acls"}],
|
|
|
|
lists:map(fun(S) ->
|
|
|
|
{xmlelement, "value", [], [{xmlcdata, S}]}
|
|
|
|
end,
|
|
|
|
string:tokens(
|
|
|
|
lists:flatten(io_lib:format("~p.",
|
|
|
|
[ets:tab2list(acl)])),
|
|
|
|
"\n"))
|
|
|
|
}
|
|
|
|
]}]};
|
2003-02-06 20:09:22 +01:00
|
|
|
|
|
|
|
get_form(["config", "access"], Lang) ->
|
2004-02-15 21:10:40 +01:00
|
|
|
{result, [{xmlelement, "x", [{"xmlns", ?NS_XDATA}],
|
|
|
|
[{xmlelement, "title", [],
|
|
|
|
[{xmlcdata,
|
|
|
|
translate:translate(
|
|
|
|
Lang, "Access Configuration")}]},
|
|
|
|
%{xmlelement, "instructions", [],
|
|
|
|
% [{xmlcdata,
|
|
|
|
% translate:translate(
|
|
|
|
% Lang, "")}]},
|
|
|
|
{xmlelement, "field", [{"type", "text-multi"},
|
|
|
|
{"label",
|
|
|
|
translate:translate(
|
2004-02-26 23:00:04 +01:00
|
|
|
Lang, "Access rules")},
|
2004-02-15 21:10:40 +01:00
|
|
|
{"var", "access"}],
|
|
|
|
lists:map(fun(S) ->
|
|
|
|
{xmlelement, "value", [], [{xmlcdata, S}]}
|
|
|
|
end,
|
|
|
|
string:tokens(
|
|
|
|
lists:flatten(
|
|
|
|
io_lib:format(
|
|
|
|
"~p.",
|
|
|
|
[ets:select(config,
|
|
|
|
[{{config, {access, '$1'}, '$2'},
|
|
|
|
[],
|
|
|
|
[{{access, '$1', '$2'}}]}])
|
|
|
|
])),
|
|
|
|
"\n"))
|
|
|
|
}
|
|
|
|
]}]};
|
2003-01-22 21:40:40 +01:00
|
|
|
|
2003-01-26 21:16:53 +01:00
|
|
|
get_form(["config", "remusers"], Lang) ->
|
2004-02-15 21:10:40 +01:00
|
|
|
{result, [{xmlelement, "x", [{"xmlns", ?NS_XDATA}],
|
|
|
|
[{xmlelement, "title", [],
|
|
|
|
[{xmlcdata,
|
|
|
|
translate:translate(
|
|
|
|
Lang, "Remove Users")}]},
|
|
|
|
{xmlelement, "instructions", [],
|
|
|
|
[{xmlcdata,
|
|
|
|
translate:translate(
|
|
|
|
Lang, "Choose users to remove")}]}] ++
|
|
|
|
case catch ejabberd_auth:dirty_get_registered_users() of
|
|
|
|
{'EXIT', Reason} ->
|
|
|
|
[];
|
|
|
|
Users ->
|
|
|
|
lists:map(fun(U) ->
|
|
|
|
?XFIELD("boolean", U, U, "0")
|
|
|
|
end, lists:sort(Users))
|
|
|
|
end
|
|
|
|
}]};
|
2003-01-26 21:16:53 +01:00
|
|
|
|
2003-01-19 21:17:56 +01:00
|
|
|
get_form(_, Lang) ->
|
2003-03-09 21:46:47 +01:00
|
|
|
{error, ?ERR_SERVICE_UNAVAILABLE}.
|
2003-01-19 21:17:56 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
set_form(["running nodes", ENode, "DB"], Lang, XData) ->
|
|
|
|
case search_running_node(ENode) of
|
|
|
|
false ->
|
2003-10-16 20:17:44 +02:00
|
|
|
{error, ?ERR_ITEM_NOT_FOUND};
|
2003-01-19 21:17:56 +01:00
|
|
|
Node ->
|
|
|
|
lists:foreach(
|
|
|
|
fun({SVar, SVals}) ->
|
2004-05-16 22:13:38 +02:00
|
|
|
% We believe that this is allowed only for good people
|
2003-01-19 21:17:56 +01:00
|
|
|
Table = list_to_atom(SVar),
|
|
|
|
Type = case SVals of
|
|
|
|
["unknown"] -> unknown;
|
|
|
|
["ram_copies"] -> ram_copies;
|
|
|
|
["disc_copies"] -> disc_copies;
|
|
|
|
["disc_only_copies"] -> disc_only_copies;
|
|
|
|
_ -> false
|
|
|
|
end,
|
|
|
|
if
|
|
|
|
Type == false ->
|
|
|
|
ok;
|
|
|
|
Type == unknown ->
|
|
|
|
mnesia:del_table_copy(Table, Node);
|
|
|
|
true ->
|
|
|
|
case mnesia:add_table_copy(Table, Node, Type) of
|
|
|
|
{aborted, _} ->
|
|
|
|
mnesia:change_table_copy_type(
|
|
|
|
Table, Node, Type);
|
|
|
|
_ ->
|
|
|
|
ok
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end, XData),
|
|
|
|
{result, []}
|
|
|
|
end;
|
|
|
|
|
2003-01-28 20:45:13 +01:00
|
|
|
set_form(["running nodes", ENode, "modules", "stop"], Lang, XData) ->
|
|
|
|
case search_running_node(ENode) of
|
|
|
|
false ->
|
2003-10-16 20:17:44 +02:00
|
|
|
{error, ?ERR_ITEM_NOT_FOUND};
|
2003-01-28 20:45:13 +01:00
|
|
|
Node ->
|
|
|
|
lists:foreach(
|
|
|
|
fun({Var, Vals}) ->
|
|
|
|
case Vals of
|
|
|
|
["1"] ->
|
|
|
|
Module = list_to_atom(Var),
|
|
|
|
rpc:call(Node, gen_mod, stop_module, [Module]);
|
|
|
|
_ ->
|
|
|
|
ok
|
|
|
|
end
|
|
|
|
end, XData),
|
|
|
|
{result, []}
|
|
|
|
end;
|
|
|
|
|
|
|
|
set_form(["running nodes", ENode, "modules", "start"], Lang, XData) ->
|
|
|
|
case search_running_node(ENode) of
|
|
|
|
false ->
|
2003-10-16 20:17:44 +02:00
|
|
|
{error, ?ERR_ITEM_NOT_FOUND};
|
2003-01-28 20:45:13 +01:00
|
|
|
Node ->
|
|
|
|
case lists:keysearch("modules", 1, XData) of
|
|
|
|
false ->
|
2003-05-09 21:32:59 +02:00
|
|
|
{error, ?ERR_BAD_REQUEST};
|
2003-01-28 20:45:13 +01:00
|
|
|
{value, {_, Strings}} ->
|
|
|
|
String = lists:foldl(fun(S, Res) ->
|
|
|
|
Res ++ S ++ "\n"
|
|
|
|
end, "", Strings),
|
|
|
|
case erl_scan:string(String) of
|
|
|
|
{ok, Tokens, _} ->
|
|
|
|
case erl_parse:parse_term(Tokens) of
|
|
|
|
{ok, Modules} ->
|
2003-02-01 21:21:28 +01:00
|
|
|
lists:foreach(
|
|
|
|
fun({Module, Args}) ->
|
|
|
|
rpc:call(Node,
|
|
|
|
gen_mod,
|
|
|
|
start_module,
|
|
|
|
[Module, Args])
|
|
|
|
end, Modules),
|
|
|
|
{result, []};
|
2003-01-28 20:45:13 +01:00
|
|
|
_ ->
|
2003-05-09 21:32:59 +02:00
|
|
|
{error, ?ERR_BAD_REQUEST}
|
2003-01-28 20:45:13 +01:00
|
|
|
end;
|
|
|
|
_ ->
|
2003-05-09 21:32:59 +02:00
|
|
|
{error, ?ERR_BAD_REQUEST}
|
2003-01-28 20:45:13 +01:00
|
|
|
end;
|
|
|
|
_ ->
|
2003-05-09 21:32:59 +02:00
|
|
|
{error, ?ERR_BAD_REQUEST}
|
2003-01-28 20:45:13 +01:00
|
|
|
end
|
2003-02-04 21:45:23 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
2003-02-22 20:11:00 +01:00
|
|
|
set_form(["running nodes", ENode, "backup", "backup"], Lang, XData) ->
|
|
|
|
case search_running_node(ENode) of
|
|
|
|
false ->
|
2003-10-16 20:17:44 +02:00
|
|
|
{error, ?ERR_ITEM_NOT_FOUND};
|
2003-02-22 20:11:00 +01:00
|
|
|
Node ->
|
|
|
|
case lists:keysearch("path", 1, XData) of
|
|
|
|
false ->
|
2003-05-09 21:32:59 +02:00
|
|
|
{error, ?ERR_BAD_REQUEST};
|
2003-02-22 20:11:00 +01:00
|
|
|
{value, {_, [String]}} ->
|
|
|
|
case rpc:call(Node, mnesia, backup, [String]) of
|
|
|
|
{badrpc, Reason} ->
|
2003-03-09 21:46:47 +01:00
|
|
|
{error, ?ERR_INTERNAL_SERVER_ERROR};
|
2003-02-22 20:11:00 +01:00
|
|
|
{error, Reason} ->
|
2003-03-09 21:46:47 +01:00
|
|
|
{error, ?ERR_INTERNAL_SERVER_ERROR};
|
2003-02-22 20:11:00 +01:00
|
|
|
_ ->
|
|
|
|
{result, []}
|
|
|
|
end;
|
|
|
|
_ ->
|
2003-05-09 21:32:59 +02:00
|
|
|
{error, ?ERR_BAD_REQUEST}
|
2003-02-22 20:11:00 +01:00
|
|
|
end
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
set_form(["running nodes", ENode, "backup", "restore"], Lang, XData) ->
|
|
|
|
case search_running_node(ENode) of
|
|
|
|
false ->
|
2003-10-16 20:17:44 +02:00
|
|
|
{error, ?ERR_ITEM_NOT_FOUND};
|
2003-02-22 20:11:00 +01:00
|
|
|
Node ->
|
|
|
|
case lists:keysearch("path", 1, XData) of
|
|
|
|
false ->
|
2003-05-09 21:32:59 +02:00
|
|
|
{error, ?ERR_BAD_REQUEST};
|
2003-02-22 20:11:00 +01:00
|
|
|
{value, {_, [String]}} ->
|
|
|
|
case rpc:call(Node, mnesia, restore,
|
|
|
|
[String, [{default_op, keep_tables}]]) of
|
|
|
|
{badrpc, Reason} ->
|
2003-03-09 21:46:47 +01:00
|
|
|
{error, ?ERR_INTERNAL_SERVER_ERROR};
|
2003-02-22 20:11:00 +01:00
|
|
|
{error, Reason} ->
|
2003-03-09 21:46:47 +01:00
|
|
|
{error, ?ERR_INTERNAL_SERVER_ERROR};
|
2003-02-22 20:11:00 +01:00
|
|
|
_ ->
|
|
|
|
{result, []}
|
|
|
|
end;
|
|
|
|
_ ->
|
2003-05-09 21:32:59 +02:00
|
|
|
{error, ?ERR_BAD_REQUEST}
|
2003-02-22 20:11:00 +01:00
|
|
|
end
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
set_form(["running nodes", ENode, "backup", "textfile"], Lang, XData) ->
|
|
|
|
case search_running_node(ENode) of
|
|
|
|
false ->
|
2003-10-16 20:17:44 +02:00
|
|
|
{error, ?ERR_ITEM_NOT_FOUND};
|
2003-02-22 20:11:00 +01:00
|
|
|
Node ->
|
|
|
|
case lists:keysearch("path", 1, XData) of
|
|
|
|
false ->
|
2003-05-09 21:32:59 +02:00
|
|
|
{error, ?ERR_BAD_REQUEST};
|
2003-02-22 20:11:00 +01:00
|
|
|
{value, {_, [String]}} ->
|
|
|
|
case rpc:call(Node, mnesia, dump_to_textfile, [String]) of
|
|
|
|
{badrpc, Reason} ->
|
2003-03-09 21:46:47 +01:00
|
|
|
{error, ?ERR_INTERNAL_SERVER_ERROR};
|
2003-02-22 20:11:00 +01:00
|
|
|
{error, Reason} ->
|
2003-03-09 21:46:47 +01:00
|
|
|
{error, ?ERR_INTERNAL_SERVER_ERROR};
|
2003-02-22 20:11:00 +01:00
|
|
|
_ ->
|
|
|
|
{result, []}
|
|
|
|
end;
|
|
|
|
_ ->
|
2003-05-09 21:32:59 +02:00
|
|
|
{error, ?ERR_BAD_REQUEST}
|
2003-02-22 20:11:00 +01:00
|
|
|
end
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2003-02-04 21:45:23 +01:00
|
|
|
set_form(["running nodes", ENode, "import", "file"], Lang, XData) ->
|
|
|
|
case search_running_node(ENode) of
|
|
|
|
false ->
|
2003-10-16 20:17:44 +02:00
|
|
|
{error, ?ERR_ITEM_NOT_FOUND};
|
2003-02-04 21:45:23 +01:00
|
|
|
Node ->
|
|
|
|
case lists:keysearch("path", 1, XData) of
|
|
|
|
false ->
|
2003-05-09 21:32:59 +02:00
|
|
|
{error, ?ERR_BAD_REQUEST};
|
2003-02-04 21:45:23 +01:00
|
|
|
{value, {_, [String]}} ->
|
2003-02-22 20:11:00 +01:00
|
|
|
rpc:call(Node, jd2ejd, import_file, [String]),
|
|
|
|
{result, []};
|
2003-02-04 21:45:23 +01:00
|
|
|
_ ->
|
2003-05-09 21:32:59 +02:00
|
|
|
{error, ?ERR_BAD_REQUEST}
|
2003-02-04 21:45:23 +01:00
|
|
|
end
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
set_form(["running nodes", ENode, "import", "dir"], Lang, XData) ->
|
|
|
|
case search_running_node(ENode) of
|
|
|
|
false ->
|
2003-10-16 20:17:44 +02:00
|
|
|
{error, ?ERR_ITEM_NOT_FOUND};
|
2003-02-04 21:45:23 +01:00
|
|
|
Node ->
|
|
|
|
case lists:keysearch("path", 1, XData) of
|
|
|
|
false ->
|
2003-05-09 21:32:59 +02:00
|
|
|
{error, ?ERR_BAD_REQUEST};
|
2003-02-04 21:45:23 +01:00
|
|
|
{value, {_, [String]}} ->
|
2003-10-20 20:23:30 +02:00
|
|
|
rpc:call(Node, jd2ejd, import_dir, [String]),
|
|
|
|
{result, []};
|
2003-02-04 21:45:23 +01:00
|
|
|
_ ->
|
2003-05-09 21:32:59 +02:00
|
|
|
{error, ?ERR_BAD_REQUEST}
|
2003-02-04 21:45:23 +01:00
|
|
|
end
|
2003-01-28 20:45:13 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
2003-01-21 21:36:55 +01:00
|
|
|
set_form(["config", "hostname"], Lang, XData) ->
|
|
|
|
case lists:keysearch("hostname", 1, XData) of
|
|
|
|
false ->
|
2003-05-09 21:32:59 +02:00
|
|
|
{error, ?ERR_BAD_REQUEST};
|
2003-01-21 21:36:55 +01:00
|
|
|
{value, {_, [""]}} ->
|
2003-05-09 21:32:59 +02:00
|
|
|
{error, ?ERR_BAD_REQUEST};
|
2003-01-21 21:36:55 +01:00
|
|
|
{value, {_, [NewName]}} ->
|
|
|
|
ejabberd_config:add_global_option(hostname, NewName),
|
|
|
|
{result, []};
|
|
|
|
_ ->
|
2003-05-09 21:32:59 +02:00
|
|
|
{error, ?ERR_BAD_REQUEST}
|
2003-01-21 21:36:55 +01:00
|
|
|
end;
|
2003-02-01 21:21:28 +01:00
|
|
|
|
|
|
|
set_form(["config", "acls"], Lang, XData) ->
|
|
|
|
case lists:keysearch("acls", 1, XData) of
|
|
|
|
{value, {_, Strings}} ->
|
2003-02-06 20:09:22 +01:00
|
|
|
String = lists:foldl(fun(S, Res) ->
|
|
|
|
Res ++ S ++ "\n"
|
|
|
|
end, "", Strings),
|
|
|
|
case erl_scan:string(String) of
|
|
|
|
{ok, Tokens, _} ->
|
|
|
|
case erl_parse:parse_term(Tokens) of
|
|
|
|
{ok, ACLs} ->
|
|
|
|
case acl:add_list(ACLs, true) of
|
|
|
|
ok ->
|
|
|
|
{result, []};
|
2003-02-01 21:21:28 +01:00
|
|
|
_ ->
|
2003-05-09 21:32:59 +02:00
|
|
|
{error, ?ERR_BAD_REQUEST}
|
2003-02-01 21:21:28 +01:00
|
|
|
end;
|
|
|
|
_ ->
|
2003-05-09 21:32:59 +02:00
|
|
|
{error, ?ERR_BAD_REQUEST}
|
2003-02-01 21:21:28 +01:00
|
|
|
end;
|
2003-02-06 20:09:22 +01:00
|
|
|
_ ->
|
2003-05-09 21:32:59 +02:00
|
|
|
{error, ?ERR_BAD_REQUEST}
|
2003-02-06 20:09:22 +01:00
|
|
|
end;
|
|
|
|
_ ->
|
2003-05-09 21:32:59 +02:00
|
|
|
{error, ?ERR_BAD_REQUEST}
|
2003-02-06 20:09:22 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
set_form(["config", "access"], Lang, XData) ->
|
|
|
|
SetAccess =
|
|
|
|
fun(Rs) ->
|
|
|
|
mnesia:transaction(
|
|
|
|
fun() ->
|
|
|
|
Os = mnesia:select(config,
|
|
|
|
[{{config, {access, '$1'}, '$2'},
|
|
|
|
[],
|
|
|
|
['$_']}]),
|
|
|
|
lists:foreach(fun(O) ->
|
|
|
|
mnesia:delete_object(O)
|
|
|
|
end, Os),
|
|
|
|
lists:foreach(
|
|
|
|
fun({access, Name, Rules}) ->
|
|
|
|
mnesia:write({config,
|
|
|
|
{access, Name},
|
|
|
|
Rules})
|
|
|
|
end, Rs)
|
|
|
|
end)
|
|
|
|
end,
|
|
|
|
case lists:keysearch("access", 1, XData) of
|
|
|
|
{value, {_, Strings}} ->
|
|
|
|
String = lists:foldl(fun(S, Res) ->
|
|
|
|
Res ++ S ++ "\n"
|
|
|
|
end, "", Strings),
|
|
|
|
case erl_scan:string(String) of
|
|
|
|
{ok, Tokens, _} ->
|
|
|
|
case erl_parse:parse_term(Tokens) of
|
|
|
|
{ok, Rs} ->
|
|
|
|
case SetAccess(Rs) of
|
|
|
|
{atomic, _} ->
|
|
|
|
{result, []};
|
|
|
|
E ->
|
|
|
|
io:format("A: ~p~n", [E]),
|
2003-05-09 21:32:59 +02:00
|
|
|
{error, ?ERR_BAD_REQUEST}
|
2003-02-06 20:09:22 +01:00
|
|
|
end;
|
|
|
|
_ ->
|
2003-05-09 21:32:59 +02:00
|
|
|
{error, ?ERR_BAD_REQUEST}
|
2003-02-06 20:09:22 +01:00
|
|
|
end;
|
|
|
|
_ ->
|
2003-05-09 21:32:59 +02:00
|
|
|
{error, ?ERR_BAD_REQUEST}
|
2003-02-06 20:09:22 +01:00
|
|
|
end;
|
2003-02-01 21:21:28 +01:00
|
|
|
_ ->
|
2003-05-09 21:32:59 +02:00
|
|
|
{error, ?ERR_BAD_REQUEST}
|
2003-02-01 21:21:28 +01:00
|
|
|
end;
|
2003-01-21 21:36:55 +01:00
|
|
|
|
2003-01-26 21:16:53 +01:00
|
|
|
set_form(["config", "remusers"], Lang, XData) ->
|
|
|
|
lists:foreach(
|
|
|
|
fun({Var, Vals}) ->
|
|
|
|
case Vals of
|
|
|
|
["1"] ->
|
2003-11-01 22:06:50 +01:00
|
|
|
catch ejabberd_auth:remove_user(Var);
|
2003-01-26 21:16:53 +01:00
|
|
|
_ ->
|
|
|
|
ok
|
|
|
|
end
|
|
|
|
end, XData),
|
|
|
|
{result, []};
|
|
|
|
|
2003-01-19 21:17:56 +01:00
|
|
|
set_form(_, Lang, XData) ->
|
2003-03-09 21:46:47 +01:00
|
|
|
{error, ?ERR_SERVICE_UNAVAILABLE}.
|
2003-01-19 21:17:56 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
search_running_node(SNode) ->
|
|
|
|
search_running_node(SNode, mnesia:system_info(running_db_nodes)).
|
|
|
|
|
|
|
|
search_running_node(_, []) ->
|
|
|
|
false;
|
|
|
|
search_running_node(SNode, [Node | Nodes]) ->
|
|
|
|
case atom_to_list(Node) of
|
|
|
|
SNode ->
|
|
|
|
Node;
|
|
|
|
_ ->
|
|
|
|
search_running_node(SNode, Nodes)
|
|
|
|
end.
|
|
|
|
|
2003-01-21 21:36:55 +01:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2003-01-19 21:17:56 +01:00
|
|
|
|
2003-12-17 21:13:21 +01:00
|
|
|
process_sm_iq(From, To,
|
2004-02-26 23:00:04 +01:00
|
|
|
#iq{type = Type, xmlns = XMLNS, lang = Lang, sub_el = SubEl} = IQ) ->
|
2005-06-20 05:18:13 +02:00
|
|
|
case acl:match_rule(To#jid.lserver, configure, From) of
|
2003-01-21 21:36:55 +01:00
|
|
|
deny ->
|
2003-12-17 21:13:21 +01:00
|
|
|
IQ#iq{type = error, sub_el = [SubEl, ?ERR_NOT_ALLOWED]};
|
2003-01-21 21:36:55 +01:00
|
|
|
allow ->
|
2005-04-17 20:08:34 +02:00
|
|
|
#jid{user = User, server = Server} = To,
|
2003-01-21 21:36:55 +01:00
|
|
|
case Type of
|
|
|
|
set ->
|
2004-02-15 21:10:40 +01:00
|
|
|
XDataEl = find_xdata_el(SubEl),
|
|
|
|
case XDataEl of
|
|
|
|
false ->
|
|
|
|
IQ#iq{type = error, sub_el = [SubEl, ?ERR_NOT_ACCEPTABLE]};
|
|
|
|
{xmlelement, _Name, Attrs, SubEls} ->
|
|
|
|
case xml:get_attr_s("type", Attrs) of
|
|
|
|
"cancel" ->
|
|
|
|
IQ#iq{type = result,
|
|
|
|
sub_el = [{xmlelement, "query",
|
|
|
|
[{"xmlns", XMLNS}], []}]};
|
|
|
|
"submit" ->
|
|
|
|
XData = jlib:parse_xdata_submit(XDataEl),
|
|
|
|
case XData of
|
|
|
|
invalid ->
|
2003-12-17 21:13:21 +01:00
|
|
|
IQ#iq{type = error,
|
2004-02-15 21:10:40 +01:00
|
|
|
sub_el = [SubEl, ?ERR_BAD_REQUEST]};
|
|
|
|
_ ->
|
|
|
|
Node =
|
|
|
|
string:tokens(
|
|
|
|
xml:get_tag_attr_s("node", SubEl),
|
|
|
|
"/"),
|
|
|
|
case set_sm_form(
|
2005-04-17 20:08:34 +02:00
|
|
|
User, Server, Node,
|
|
|
|
Lang, XData) of
|
2004-02-15 21:10:40 +01:00
|
|
|
{result, Res} ->
|
|
|
|
IQ#iq{type = result,
|
2005-04-17 20:08:34 +02:00
|
|
|
sub_el =
|
2004-02-15 21:10:40 +01:00
|
|
|
[{xmlelement, "query",
|
|
|
|
[{"xmlns", XMLNS}],
|
|
|
|
Res
|
|
|
|
}]};
|
|
|
|
{error, Error} ->
|
|
|
|
IQ#iq{type = error,
|
|
|
|
sub_el = [SubEl, Error]}
|
|
|
|
end
|
|
|
|
end;
|
|
|
|
_ ->
|
|
|
|
IQ#iq{type = error,
|
|
|
|
sub_el = [SubEl, ?ERR_BAD_REQUEST]}
|
|
|
|
end
|
2003-01-21 21:36:55 +01:00
|
|
|
end;
|
|
|
|
get ->
|
|
|
|
Node =
|
|
|
|
string:tokens(xml:get_tag_attr_s("node", SubEl), "/"),
|
2005-04-17 20:08:34 +02:00
|
|
|
case get_sm_form(User, Server, Node, Lang) of
|
2003-01-21 21:36:55 +01:00
|
|
|
{result, Res} ->
|
2003-12-17 21:13:21 +01:00
|
|
|
IQ#iq{type = result,
|
|
|
|
sub_el =
|
|
|
|
[{xmlelement, "query", [{"xmlns", XMLNS}],
|
|
|
|
Res
|
|
|
|
}]};
|
2003-03-09 21:46:47 +01:00
|
|
|
{error, Error} ->
|
2003-12-17 21:13:21 +01:00
|
|
|
IQ#iq{type = error, sub_el = [SubEl, Error]}
|
2003-01-21 21:36:55 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end.
|
|
|
|
|
|
|
|
|
2005-04-17 20:08:34 +02:00
|
|
|
get_sm_form(User, Server, [], Lang) ->
|
2004-02-15 21:10:40 +01:00
|
|
|
{result, [{xmlelement, "x", [{"xmlns", ?NS_XDATA}],
|
|
|
|
[{xmlelement, "title", [],
|
|
|
|
[{xmlcdata,
|
|
|
|
translate:translate(
|
2004-02-26 23:00:04 +01:00
|
|
|
Lang, "Administration of ") ++ User}]},
|
2004-02-15 21:10:40 +01:00
|
|
|
%{xmlelement, "instructions", [],
|
|
|
|
% [{xmlcdata,
|
|
|
|
% translate:translate(
|
|
|
|
% Lang, "Choose host name")}]},
|
|
|
|
{xmlelement, "field",
|
|
|
|
[{"type", "list-single"},
|
|
|
|
{"label", translate:translate(Lang, "Action on user")},
|
|
|
|
{"var", "action"}],
|
|
|
|
[{xmlelement, "value", [], [{xmlcdata, "edit"}]},
|
|
|
|
{xmlelement, "option",
|
|
|
|
[{"label", translate:translate(Lang, "Edit Properties")}],
|
|
|
|
[{xmlelement, "value", [], [{xmlcdata, "edit"}]}]},
|
|
|
|
{xmlelement, "option",
|
|
|
|
[{"label", translate:translate(Lang, "Remove User")}],
|
|
|
|
[{xmlelement, "value", [], [{xmlcdata, "remove"}]}]}
|
|
|
|
]},
|
|
|
|
?XFIELD("text-private", "Password", "password",
|
2005-04-17 20:08:34 +02:00
|
|
|
ejabberd_auth:get_password_s(User, Server))
|
2004-02-15 21:10:40 +01:00
|
|
|
%{xmlelement, "field", [{"type", "text-single"},
|
|
|
|
% {"label",
|
|
|
|
% translate:translate(Lang, "Host name")},
|
|
|
|
% {"var", "hostname"}],
|
|
|
|
% [{xmlelement, "value", [], [{xmlcdata, ?MYNAME}]}]}
|
|
|
|
]}]};
|
2003-01-21 21:36:55 +01:00
|
|
|
|
2005-04-17 20:08:34 +02:00
|
|
|
get_sm_form(_User, _Server, _Node, Lang) ->
|
2003-03-09 21:46:47 +01:00
|
|
|
{error, ?ERR_SERVICE_UNAVAILABLE}.
|
2003-01-21 21:36:55 +01:00
|
|
|
|
|
|
|
|
2005-04-17 20:08:34 +02:00
|
|
|
set_sm_form(User, Server, [], Lang, XData) ->
|
2003-10-09 20:09:05 +02:00
|
|
|
case lists:keysearch("action", 1, XData) of
|
|
|
|
{value, {_, ["edit"]}} ->
|
2003-11-09 21:18:36 +01:00
|
|
|
case lists:keysearch("password", 1, XData) of
|
|
|
|
{value, {_, [Password]}} ->
|
2005-04-17 20:08:34 +02:00
|
|
|
ejabberd_auth:set_password(User, Server, Password),
|
2003-11-09 21:18:36 +01:00
|
|
|
{result, []};
|
|
|
|
_ ->
|
|
|
|
{error, ?ERR_BAD_REQUEST}
|
|
|
|
end;
|
2003-10-09 20:09:05 +02:00
|
|
|
{value, {_, ["remove"]}} ->
|
2005-04-17 20:08:34 +02:00
|
|
|
catch ejabberd_auth:remove_user(User, Server),
|
2003-10-09 20:09:05 +02:00
|
|
|
{result, []};
|
|
|
|
_ ->
|
|
|
|
{error, ?ERR_BAD_REQUEST}
|
|
|
|
end;
|
2005-04-17 20:08:34 +02:00
|
|
|
set_sm_form(_User, _Server, _Node, Lang, XData) ->
|
2003-03-09 21:46:47 +01:00
|
|
|
{error, ?ERR_SERVICE_UNAVAILABLE}.
|
2004-02-15 21:10:40 +01:00
|
|
|
|
|
|
|
find_xdata_el({xmlelement, _Name, _Attrs, SubEls}) ->
|
|
|
|
find_xdata_el1(SubEls).
|
|
|
|
|
|
|
|
find_xdata_el1([]) ->
|
|
|
|
false;
|
|
|
|
|
|
|
|
find_xdata_el1([{xmlelement, Name, Attrs, SubEls} | Els]) ->
|
|
|
|
case xml:get_attr_s("xmlns", Attrs) of
|
|
|
|
?NS_XDATA ->
|
|
|
|
{xmlelement, Name, Attrs, SubEls};
|
|
|
|
_ ->
|
|
|
|
find_xdata_el1(Els)
|
|
|
|
end;
|
|
|
|
|
|
|
|
find_xdata_el1([_ | Els]) ->
|
|
|
|
find_xdata_el1(Els).
|