aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlexey Shchepin <alexey@process-one.net>2004-08-02 22:17:05 +0000
committerAlexey Shchepin <alexey@process-one.net>2004-08-02 22:17:05 +0000
commita8f4e8450339ab1f15af2fcfc5b919d9ebc57a50 (patch)
treeed199487ca7b8af258cfb5fece2dd985d2350ea7 /src
parent* src/tls/tls.erl: Added recv_data/2 function (diff)
* src/web/ejabberd_web_admin.erl: Added user's roster page
* src/mod_irc/mod_irc_connection.erl: Bugfix SVN Revision: 253
Diffstat (limited to 'src')
-rw-r--r--src/mod_irc/mod_irc_connection.erl4
-rw-r--r--src/web/ejabberd_web_admin.erl66
2 files changed, 68 insertions, 2 deletions
diff --git a/src/mod_irc/mod_irc_connection.erl b/src/mod_irc/mod_irc_connection.erl
index 671c98328..f4e1c29d3 100644
--- a/src/mod_irc/mod_irc_connection.erl
+++ b/src/mod_irc/mod_irc_connection.erl
@@ -303,8 +303,8 @@ handle_info({route_chan, Channel, Resource,
{xmlelement, "iq", Attrs, Els} = El},
StateName, StateData) ->
From = StateData#state.user,
- To = {lists:concat([Channel, "%", StateData#state.server]),
- StateData#state.myname, StateData#state.nick},
+ To = jlib:make_jid(lists:concat([Channel, "%", StateData#state.server]),
+ StateData#state.myname, StateData#state.nick),
case jlib:iq_query_info(El) of
#iq{xmlns = ?NS_MUC_ADMIN} = IQ ->
iq_admin(StateData, Channel, From, To, IQ);
diff --git a/src/web/ejabberd_web_admin.erl b/src/web/ejabberd_web_admin.erl
index 457ebee58..550d3ecd0 100644
--- a/src/web/ejabberd_web_admin.erl
+++ b/src/web/ejabberd_web_admin.erl
@@ -778,6 +778,13 @@ process_admin(#request{user = User,
make_xhtml(Res, Lang);
process_admin(#request{user = User,
+ path = ["user", U, "roster"],
+ q = Query,
+ lang = Lang} = Request) ->
+ Res = user_roster(U, Query, Lang),
+ make_xhtml(Res, Lang);
+
+process_admin(#request{user = User,
path = ["nodes"],
q = Query,
lang = Lang} = Request) ->
@@ -1135,6 +1142,65 @@ user_parse_query(User, Query) ->
end.
+-record(roster, {uj,
+ user,
+ jid,
+ name = "",
+ subscription = none,
+ ask = none,
+ groups = [],
+ xattrs = [],
+ xs = []}).
+
+ask_to_pending(subscribe) -> out;
+ask_to_pending(unsubscribe) -> none;
+ask_to_pending(Ask) -> Ask.
+
+user_roster(User, Query, Lang) ->
+ %Res = user_parse_query(User, Query),
+ Res = nothing, % TODO
+ LUser = jlib:nameprep(User),
+ Items = mnesia:dirty_index_read(roster, LUser, #roster.user),
+ SItems = lists:sort(Items),
+ FItems =
+ case SItems of
+ [] ->
+ [?CT("None")];
+ _ ->
+ [?XE("table",
+ [?XE("thead",
+ [?XE("tr",
+ [?XCT("td", "JID"),
+ ?XCT("td", "Name"),
+ ?XCT("td", "Subscription"),
+ ?XCT("td", "Pending")
+ ])]),
+ ?XE("tbody",
+ lists:map(
+ fun(R) ->
+ ?XE("tr",
+ [?XE("td", [?C(jlib:jid_to_string(
+ R#roster.jid))]),
+ ?XE("td", [?C(R#roster.name)]),
+ ?XE("td",
+ [?C(atom_to_list(
+ R#roster.subscription))]),
+ ?XE("td",
+ [?C(atom_to_list(
+ ask_to_pending(
+ R#roster.ask)))])])
+ end, SItems))])]
+ end,
+ [?XC("h1", "Roster of " ++ User)] ++
+ case Res of
+ ok -> [?CT("submitted"), ?P];
+ error -> [?CT("bad format"), ?P];
+ nothing -> []
+ end ++
+ [?XAE("form", [{"method", "post"}],
+ FItems)].
+
+
get_nodes(Lang) ->
RunningNodes = mnesia:system_info(running_db_nodes),
StoppedNodes = lists:usort(mnesia:system_info(db_nodes) ++