mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
* src/web/ejabberd_web.erl: Experiments with web-interface
SVN Revision: 214
This commit is contained in:
parent
20e297db3a
commit
a2b2d08ddc
@ -1,5 +1,7 @@
|
||||
2004-03-12 Alexey Shchepin <alexey@sevcom.net>
|
||||
|
||||
* src/web/ejabberd_web.erl: Experiments with web-interface
|
||||
|
||||
* src/configure.ac: Updated
|
||||
* src/Makefile.in: Likewise
|
||||
|
||||
|
@ -93,10 +93,6 @@ process_config(#request{user = User,
|
||||
path = ["acls"],
|
||||
q = Query,
|
||||
lang = Lang} = Request) ->
|
||||
case acl:match_rule(configure, jlib:make_jid(User, ?MYNAME, "")) of
|
||||
deny ->
|
||||
{401, [], make_xhtml([?XC("h1", "Not Allowed")])};
|
||||
allow ->
|
||||
Res = case lists:keysearch("acls", 1, Query) of
|
||||
{value, {_, String}} ->
|
||||
case erl_scan:string(String) of
|
||||
@ -133,11 +129,60 @@ process_config(#request{user = User,
|
||||
?BR,
|
||||
?XA("input", [{"type", "submit"}])
|
||||
])
|
||||
]);
|
||||
|
||||
process_config(#request{user = User,
|
||||
path = ["acls2"],
|
||||
q = Query,
|
||||
lang = Lang} = Request) ->
|
||||
ACLs = ets:tab2list(acl),
|
||||
make_xhtml([?XC("h1", "ejabberd ACLs configuration")] ++
|
||||
[?XAE("form", [{"method", "post"}],
|
||||
[acls_to_xhtml(ACLs),
|
||||
?BR,
|
||||
?XA("input", [{"type", "submit"}])
|
||||
])
|
||||
end;
|
||||
]);
|
||||
|
||||
process_config(_Request) ->
|
||||
{404, [], make_xhtml([?XC("h1", "Not found")])}.
|
||||
|
||||
|
||||
|
||||
acls_to_xhtml(ACLs) ->
|
||||
?XAE("table", [],
|
||||
[?XE("tbody",
|
||||
lists:map(
|
||||
fun({acl, Name, Spec}) ->
|
||||
?XE("tr",
|
||||
[?XC("td", atom_to_list(Name))] ++
|
||||
acl_spec_to_xhtml(Spec)
|
||||
)
|
||||
end, ACLs)
|
||||
)]).
|
||||
|
||||
-define(ACLINPUT(Text), ?XE("td", [?XA("input", [{"type", "text"},
|
||||
{"name", ""},
|
||||
{"value", Text}])])).
|
||||
|
||||
acl_spec_to_xhtml({user, U}) ->
|
||||
[acl_spec_select(user), ?ACLINPUT(U)];
|
||||
|
||||
acl_spec_to_xhtml(Spec) ->
|
||||
[acl_spec_select(raw),
|
||||
?ACLINPUT(lists:flatten(io_lib:format("~p.", [Spec])))
|
||||
].
|
||||
|
||||
acl_spec_select(Opt) ->
|
||||
?XE("td",
|
||||
[?XAE("select", [{"name", ""}],
|
||||
lists:map(
|
||||
fun(O) ->
|
||||
Sel = if
|
||||
O == Opt -> [{"selected", "selected"}];
|
||||
true -> []
|
||||
end,
|
||||
?XAC("option",
|
||||
Sel ++ [{"value", atom_to_list(O)}],
|
||||
atom_to_list(O))
|
||||
end, [all, user, server, raw]))]).
|
||||
|
Loading…
Reference in New Issue
Block a user