25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-26 16:26:24 +01:00

Improvements in the WebAdmin browsing menus.

SVN Revision: 2336
This commit is contained in:
Badlop 2009-06-25 17:04:03 +00:00
parent 6ac4157fc1
commit e37b26e068

View File

@ -47,6 +47,95 @@
?XMLATTR('name', Name), ?XMLATTR('name', Name),
?XMLATTR('value', Value)])). ?XMLATTR('value', Value)])).
%%%==================================
%%%% get_acl_access
%% @spec (Path::[string()]) -> {HostOfRule, AccessRule}
%% All accounts can access those URLs
get_acl_rule([]) -> {"localhost", all};
get_acl_rule(["style.css"]) -> {"localhost", all};
get_acl_rule(["logo.png"]) -> {"localhost", all};
get_acl_rule(["logo-fill.png"]) -> {"localhost", all};
get_acl_rule(["favicon.ico"]) -> {"localhost", all};
get_acl_rule(["additions.js"]) -> {"localhost", all};
%% This page only displays vhosts that the user is admin:
get_acl_rule(["vhosts"]) -> {"localhost", all};
%% The pages of a vhost are only accesible if the user is admin of that vhost:
get_acl_rule(["server", VHost | _RPath]) -> {VHost, configure};
%% Default rule: only global admins can access any other random page
get_acl_rule(_RPath) -> {global, configure}.
%%%==================================
%%%% Menu Items Access
get_jid(Auth, HostHTTP) ->
case get_auth_admin(Auth, HostHTTP, []) of
{ok, {User, Server}} ->
exmpp_jid:make(User, Server, "");
{unauthorized, Error} ->
?ERROR_MSG("Unauthorized ~p: ~p", [Auth, Error]),
throw({unauthorized, Auth})
end.
get_menu_items(global, cluster, Lang, JID) ->
{Base, _, Items} = make_server_menu([], [], Lang, JID),
lists:map(
fun({URI, Name}) ->
{Base++URI++"/", Name};
({URI, Name, _SubMenu}) ->
{Base++URI++"/", Name}
end,
Items
);
get_menu_items(Host, cluster, Lang, JID) ->
{Base, _, Items} = make_host_menu(Host, [], Lang, JID),
lists:map(
fun({URI, Name}) ->
{Base++URI++"/", Name};
({URI, Name, _SubMenu}) ->
{Base++URI++"/", Name}
end,
Items
);
get_menu_items(Host, Node, Lang, JID) ->
{Base, _, Items} = make_host_node_menu(Host, Node, Lang, JID),
lists:map(
fun({URI, Name}) ->
{Base++URI++"/", Name};
({URI, Name, _SubMenu}) ->
{Base++URI++"/", Name}
end,
Items
).
is_allowed_path(BasePath, {Path, _}, JID) ->
is_allowed_path(BasePath ++ [Path], JID);
is_allowed_path(BasePath, {Path, _, _}, JID) ->
is_allowed_path(BasePath ++ [Path], JID).
is_allowed_path(["admin" | Path], JID) ->
is_allowed_path(Path, JID);
is_allowed_path(Path, JID) ->
{HostOfRule, AccessRule} = get_acl_rule(Path),
allow == acl:match_rule(HostOfRule, AccessRule, JID).
%% @spec(Path) -> URL
%% where Path = [string()]
%% URL = string()
%% Convert ["admin", "user", "tom"] -> "/admin/user/tom/"
%%path_to_url(Path) ->
%% "/" ++ string:join(Path, "/") ++ "/".
%% @spec(URL) -> Path
%% where Path = [string()]
%% URL = string()
%% Convert "admin/user/tom" -> ["admin", "user", "tom"]
url_to_path(URL) ->
string:tokens(URL, "/").
%%%================================== %%%==================================
%%%% process/2 %%%% process/2
@ -74,13 +163,15 @@ process(["doc", LocalFile], _Request) ->
end end
end; end;
process(["server", SHost | RPath], #request{auth = Auth, lang = Lang, host = HostHTTP} = Request) -> process(["server", SHost | RPath] = Path, #request{auth = Auth, lang = Lang, host = HostHTTP} = Request) ->
Host = exmpp_stringprep:nameprep(SHost), Host = exmpp_stringprep:nameprep(SHost),
case lists:member(Host, ?MYHOSTS) of case lists:member(Host, ?MYHOSTS) of
true -> true ->
case get_auth_admin(Auth, Host, HostHTTP) of case get_auth_admin(Auth, HostHTTP, Path) of
{ok, {User, Server}} -> {ok, {User, Server}} ->
AJID = get_jid(Auth, HostHTTP),
process_admin(Host, Request#request{path = RPath, process_admin(Host, Request#request{path = RPath,
auth = {auth_jid, Auth, AJID},
us = {User, Server}}); us = {User, Server}});
{unauthorized, "no-auth-provided"} -> {unauthorized, "no-auth-provided"} ->
{401, {401,
@ -99,9 +190,11 @@ process(["server", SHost | RPath], #request{auth = Auth, lang = Lang, host = Hos
end; end;
process(RPath, #request{auth = Auth, lang = Lang, host = HostHTTP} = Request) -> process(RPath, #request{auth = Auth, lang = Lang, host = HostHTTP} = Request) ->
case get_auth_admin(Auth, global, HostHTTP) of case get_auth_admin(Auth, HostHTTP, RPath) of
{ok, {User, Server}} -> {ok, {User, Server}} ->
AJID = get_jid(Auth, HostHTTP),
process_admin(global, Request#request{path = RPath, process_admin(global, Request#request{path = RPath,
auth = {auth_jid, Auth, AJID},
us = {User, Server}}); us = {User, Server}});
{unauthorized, "no-auth-provided"} -> {unauthorized, "no-auth-provided"} ->
{401, {401,
@ -116,19 +209,20 @@ process(RPath, #request{auth = Auth, lang = Lang, host = HostHTTP} = Request) ->
ejabberd_web:make_xhtml([?XCT('h1', "Unauthorized")])} ejabberd_web:make_xhtml([?XCT('h1', "Unauthorized")])}
end. end.
get_auth_admin(Auth, Host, HostHTTP) -> get_auth_admin(Auth, HostHTTP, RPath) ->
case Auth of case Auth of
{SJID, Pass} -> {SJID, Pass} ->
try try
{HostOfRule, AccessRule} = get_acl_rule(RPath),
JID = exmpp_jid:parse(SJID), JID = exmpp_jid:parse(SJID),
User = exmpp_jid:node_as_list(JID), User = exmpp_jid:node_as_list(JID),
Server = exmpp_jid:domain_as_list(JID), Server = exmpp_jid:domain_as_list(JID),
case User == undefined of case User == undefined of
true -> true ->
%% If only specified username, not username@server %% If only specified username, not username@server
get_auth_account(Host, Server, HostHTTP, Pass); get_auth_account(HostOfRule, AccessRule, User, HostHTTP, Pass);
false -> false ->
get_auth_account(Host, User, Server, Pass) get_auth_account(HostOfRule, AccessRule, User, Server, Pass)
end end
catch catch
_ -> _ ->
@ -138,10 +232,10 @@ get_auth_admin(Auth, Host, HostHTTP) ->
{unauthorized, "no-auth-provided"} {unauthorized, "no-auth-provided"}
end. end.
get_auth_account(Host, User, Server, Pass) -> get_auth_account(HostOfRule, AccessRule, User, Server, Pass) ->
case ejabberd_auth:check_password(User, Server, Pass) of case ejabberd_auth:check_password(User, Server, Pass) of
true -> true ->
case acl:match_rule(Host, configure, case acl:match_rule(HostOfRule, AccessRule,
exmpp_jid:make(User, Server)) of exmpp_jid:make(User, Server)) of
deny -> deny ->
{unauthorized, "unprivileged-account"}; {unauthorized, "unprivileged-account"};
@ -160,15 +254,16 @@ get_auth_account(Host, User, Server, Pass) ->
%%%================================== %%%==================================
%%%% make_xhtml %%%% make_xhtml
make_xhtml(Els, Host, Lang) -> make_xhtml(Els, Host, Lang, JID) ->
make_xhtml(Els, Host, cluster, Lang). make_xhtml(Els, Host, cluster, Lang, JID).
%% @spec (Els, Host, Node, Lang) -> {200, [html], xmlelement()} %% @spec (Els, Host, Node, Lang, JID) -> {200, [html], xmlelement()}
%% where Host = global | string() %% where Host = global | string()
%% Node = cluster | atom() %% Node = cluster | atom()
make_xhtml(Els, Host, Node, Lang) -> %% JID = jid()
make_xhtml(Els, Host, Node, Lang, JID) ->
Base = get_base_path(Host, cluster), %% Enforcing 'cluster' on purpose here Base = get_base_path(Host, cluster), %% Enforcing 'cluster' on purpose here
MenuItems = make_navigation(Host, Node, Lang), MenuItems = make_navigation(Host, Node, Lang, JID),
{200, [html], {200, [html],
#xmlel{ns = ?NS_XHTML, name = 'html', attrs = [ #xmlel{ns = ?NS_XHTML, name = 'html', attrs = [
exmpp_xml:attribute(?NS_XML, 'lang', Lang), exmpp_xml:attribute(?NS_XML, 'lang', Lang),
@ -661,41 +756,25 @@ logo_fill() ->
process_admin(global, process_admin(global,
#request{path = [], #request{path = [],
auth = {_, _, AJID},
lang = Lang}) -> lang = Lang}) ->
Base = get_base_path(global, cluster), %%Base = get_base_path(global, cluster),
MenuItems2 = make_menu_items(global, cluster, Base, Lang),
make_xhtml(?H1GL(?T("Administration"), "toc", "Contents") ++ make_xhtml(?H1GL(?T("Administration"), "toc", "Contents") ++
[?XE('ul', [?XE('ul',
[?LI([?ACT("/admin/acls/", "Access Control Lists"), ?C(" "), [?LI([?ACT(MIU, MIN)]) || {MIU, MIN} <- get_menu_items(global, cluster, Lang, AJID)]
?ACT("/admin/acls-raw/", "(Raw)")]),
?LI([?ACT("/admin/access/", "Access Rules"), ?C(" "),
?ACT("/admin/access-raw/", "(Raw)")]),
?LI([?ACT("/admin/vhosts/", "Virtual Hosts")]),
?LI([?ACT("/admin/nodes/", "Nodes")]),
?LI([?ACT("/admin/stats/", "Statistics")])
] ++ MenuItems2
) )
], global, Lang); ], global, Lang, AJID);
process_admin(Host, process_admin(Host,
#request{path = [], #request{path = [],
auth = {_, _Auth, AJID},
lang = Lang}) -> lang = Lang}) ->
Base = get_base_path(Host, cluster), %%Base = get_base_path(Host, cluster),
MenuItems2 = make_menu_items(Host, cluster, Base, Lang),
make_xhtml([?XCT('h1', "Administration"), make_xhtml([?XCT('h1', "Administration"),
?XE('ul', ?XE('ul',
[?LI([?ACT(Base ++ "acls/", "Access Control Lists"), ?C(" "), [?LI([?ACT(MIU, MIN)]) || {MIU, MIN} <- get_menu_items(Host, cluster, Lang, AJID)]
?ACT(Base ++ "acls-raw/", "(Raw)")]),
?LI([?ACT(Base ++ "access/", "Access Rules"), ?C(" "),
?ACT(Base ++ "access-raw/", "(Raw)")]),
?LI([?ACT(Base ++ "users/", "Users")]),
?LI([?ACT(Base ++ "online-users/", "Online Users")]),
?LI([?ACT(Base ++ "last-activity/", "Last Activity")]),
?LI([?ACT(Base ++ "nodes/", "Nodes")]),
?LI([?ACT(Base ++ "stats/", "Statistics")])
] ++ MenuItems2
) )
], Host, Lang); ], Host, Lang, AJID);
process_admin(Host, #request{path = ["style.css"]}) -> process_admin(Host, #request{path = ["style.css"]}) ->
{200, [{"Content-Type", "text/css"}, last_modified(), cache_control_public()], css(Host)}; {200, [{"Content-Type", "text/css"}, last_modified(), cache_control_public()], css(Host)};
@ -715,6 +794,7 @@ process_admin(_Host, #request{path = ["additions.js"]}) ->
process_admin(Host, process_admin(Host,
#request{path = ["acls-raw"], #request{path = ["acls-raw"],
q = Query, q = Query,
auth = {_, _Auth, AJID},
lang = Lang}) -> lang = Lang}) ->
Res = case lists:keysearch("acls", 1, Query) of Res = case lists:keysearch("acls", 1, Query) of
@ -752,11 +832,12 @@ process_admin(Host,
?BR, ?BR,
?INPUTT("submit", "submit", "Submit") ?INPUTT("submit", "submit", "Submit")
]) ])
], Host, Lang); ], Host, Lang, AJID);
process_admin(Host, process_admin(Host,
#request{method = Method, #request{method = Method,
path = ["acls"], path = ["acls"],
auth = {_, _Auth, AJID},
q = Query, q = Query,
lang = Lang}) -> lang = Lang}) ->
?DEBUG("query: ~p", [Query]), ?DEBUG("query: ~p", [Query]),
@ -795,10 +876,11 @@ process_admin(Host,
?C(" "), ?C(" "),
?INPUTT("submit", "submit", "Submit") ?INPUTT("submit", "submit", "Submit")
]) ])
], Host, Lang); ], Host, Lang, AJID);
process_admin(Host, process_admin(Host,
#request{path = ["access-raw"], #request{path = ["access-raw"],
auth = {_, _Auth, AJID},
q = Query, q = Query,
lang = Lang}) -> lang = Lang}) ->
SetAccess = SetAccess =
@ -859,12 +941,13 @@ process_admin(Host,
?BR, ?BR,
?INPUTT("submit", "submit", "Submit") ?INPUTT("submit", "submit", "Submit")
]) ])
], Host, Lang); ], Host, Lang, AJID);
process_admin(Host, process_admin(Host,
#request{method = Method, #request{method = Method,
path = ["access"], path = ["access"],
q = Query, q = Query,
auth = {_, _Auth, AJID},
lang = Lang}) -> lang = Lang}) ->
?DEBUG("query: ~p", [Query]), ?DEBUG("query: ~p", [Query]),
Res = case Method of Res = case Method of
@ -895,11 +978,12 @@ process_admin(Host,
?BR, ?BR,
?INPUTT("submit", "delete", "Delete Selected") ?INPUTT("submit", "delete", "Delete Selected")
]) ])
], Host, Lang); ], Host, Lang, AJID);
process_admin(Host, process_admin(Host,
#request{path = ["access", SName], #request{path = ["access", SName],
q = Query, q = Query,
auth = {_, _Auth, AJID},
lang = Lang}) -> lang = Lang}) ->
?DEBUG("query: ~p", [Query]), ?DEBUG("query: ~p", [Query]),
Name = list_to_atom(SName), Name = list_to_atom(SName),
@ -934,36 +1018,41 @@ process_admin(Host,
?BR, ?BR,
?INPUTT("submit", "submit", "Submit") ?INPUTT("submit", "submit", "Submit")
]) ])
], Host, Lang); ], Host, Lang, AJID);
process_admin(global, process_admin(global,
#request{path = ["vhosts"], #request{path = ["vhosts"],
auth = {_, _Auth, AJID},
lang = Lang}) -> lang = Lang}) ->
Res = list_vhosts(Lang), Res = list_vhosts(Lang, AJID),
make_xhtml(?H1GL(?T("ejabberd virtual hosts"), "virtualhost", "Virtual Hosting") ++ Res, global, Lang); make_xhtml(?H1GL(?T("ejabberd virtual hosts"), "virtualhost", "Virtual Hosting") ++ Res, global, Lang, AJID);
process_admin(Host, process_admin(Host,
#request{path = ["users"], #request{path = ["users"],
q = Query, q = Query,
auth = {_, _Auth, AJID},
lang = Lang}) when is_list(Host) -> lang = Lang}) when is_list(Host) ->
Res = list_users(Host, Query, Lang, fun url_func/1), Res = list_users(Host, Query, Lang, fun url_func/1),
make_xhtml([?XCT('h1', "Users")] ++ Res, Host, Lang); make_xhtml([?XCT('h1', "Users")] ++ Res, Host, Lang, AJID);
process_admin(Host, process_admin(Host,
#request{path = ["users", Diap], #request{path = ["users", Diap],
auth = {_, _Auth, AJID},
lang = Lang}) when is_list(Host) -> lang = Lang}) when is_list(Host) ->
Res = list_users_in_diapason(Host, Diap, Lang, fun url_func/1), Res = list_users_in_diapason(Host, Diap, Lang, fun url_func/1),
make_xhtml([?XCT('h1', "Users")] ++ Res, Host, Lang); make_xhtml([?XCT('h1', "Users")] ++ Res, Host, Lang, AJID);
process_admin(Host, process_admin(Host,
#request{ #request{
path = ["online-users"], path = ["online-users"],
auth = {_, _Auth, AJID},
lang = Lang}) when is_list(Host) -> lang = Lang}) when is_list(Host) ->
Res = list_online_users(Host, Lang), Res = list_online_users(Host, Lang),
make_xhtml([?XCT('h1', "Online Users")] ++ Res, Host, Lang); make_xhtml([?XCT('h1', "Online Users")] ++ Res, Host, Lang, AJID);
process_admin(Host, process_admin(Host,
#request{path = ["last-activity"], #request{path = ["last-activity"],
auth = {_, _Auth, AJID},
q = Query, q = Query,
lang = Lang}) when is_list(Host) -> lang = Lang}) when is_list(Host) ->
?DEBUG("query: ~p", [Query]), ?DEBUG("query: ~p", [Query]),
@ -999,55 +1088,61 @@ process_admin(Host,
?C(" "), ?C(" "),
?INPUTT("submit", "integral", "Show Integral Table") ?INPUTT("submit", "integral", "Show Integral Table")
])] ++ ])] ++
Res, Host, Lang); Res, Host, Lang, AJID);
process_admin(Host, process_admin(Host,
#request{path = ["stats"], #request{path = ["stats"],
auth = {_, _Auth, AJID},
lang = Lang}) -> lang = Lang}) ->
Res = get_stats(Host, Lang), Res = get_stats(Host, Lang),
make_xhtml([?XCT('h1', "Statistics")] ++ Res, Host, Lang); make_xhtml([?XCT('h1', "Statistics")] ++ Res, Host, Lang, AJID);
process_admin(Host, process_admin(Host,
#request{path = ["user", U], #request{path = ["user", U],
auth = {_, _Auth, AJID},
q = Query, q = Query,
lang = Lang}) -> lang = Lang}) ->
case ejabberd_auth:is_user_exists(U, Host) of case ejabberd_auth:is_user_exists(U, Host) of
true -> true ->
Res = user_info(U, Host, Query, Lang), Res = user_info(U, Host, Query, Lang),
make_xhtml(Res, Host, Lang); make_xhtml(Res, Host, Lang, AJID);
false -> false ->
make_xhtml([?XCT('h1', "Not Found")], Host, Lang) make_xhtml([?XCT('h1', "Not Found")], Host, Lang, AJID)
end; end;
process_admin(Host, process_admin(Host,
#request{path = ["nodes"], #request{path = ["nodes"],
auth = {_, _Auth, AJID},
lang = Lang}) -> lang = Lang}) ->
Res = get_nodes(Lang), Res = get_nodes(Lang),
make_xhtml(Res, Host, Lang); make_xhtml(Res, Host, Lang, AJID);
process_admin(Host, process_admin(Host,
#request{path = ["node", SNode | NPath], #request{path = ["node", SNode | NPath],
auth = {_, _Auth, AJID},
q = Query, q = Query,
lang = Lang}) -> lang = Lang}) ->
case search_running_node(SNode) of case search_running_node(SNode) of
false -> false ->
make_xhtml([?XCT('h1', "Node not found")], Host, Lang); make_xhtml([?XCT('h1', "Node not found")], Host, Lang, AJID);
Node -> Node ->
Res = get_node(Host, Node, NPath, Query, Lang), Res = get_node(Host, Node, NPath, Query, Lang),
make_xhtml(Res, Host, Node, Lang) make_xhtml(Res, Host, Node, Lang, AJID)
end; end;
%%%================================== %%%==================================
%%%% process_admin default case %%%% process_admin default case
process_admin(Host, #request{lang = Lang} = Request) -> process_admin(Host, #request{lang = Lang,
auth = {_, _Auth, AJID}
} = Request) ->
{Hook, Opts} = case Host of {Hook, Opts} = case Host of
global -> {webadmin_page_main, [Request]}; global -> {webadmin_page_main, [Request]};
Host -> {webadmin_page_host, [Host, Request]} Host -> {webadmin_page_host, [Host, Request]}
end, end,
case ejabberd_hooks:run_fold(Hook, list_to_binary(Host), [], Opts) of case ejabberd_hooks:run_fold(Hook, list_to_binary(Host), [], Opts) of
[] -> setelement(1, make_xhtml([?XC('h1', "Not Found")], Host, Lang), 404); [] -> setelement(1, make_xhtml([?XC('h1', "Not Found")], Host, Lang, AJID), 404);
Res -> make_xhtml(Res, Host, Lang) Res -> make_xhtml(Res, Host, Lang, AJID)
end. end.
%%%================================== %%%==================================
@ -1350,8 +1445,17 @@ parse_access_rule(Text) ->
%%%================================== %%%==================================
%%%% list_vhosts %%%% list_vhosts
list_vhosts(Lang) -> list_vhosts(Lang, JID) ->
Hosts = ?MYHOSTS, Hosts = ?MYHOSTS,
HostsAllowed = lists:filter(
fun(Host) ->
allow == acl:match_rule(Host, configure, JID)
end,
Hosts
),
list_vhosts2(Lang, HostsAllowed).
list_vhosts2(Lang, Hosts) ->
SHosts = lists:sort(Hosts), SHosts = lists:sort(Hosts),
[?XE('table', [?XE('table',
[?XE('thead', [?XE('thead',
@ -2449,14 +2553,24 @@ pretty_string_int(String) when is_list(String) ->
%%%================================== %%%==================================
%%%% navigation menu %%%% navigation menu
%% @spec (Host, Node, Lang) -> [LI] %% @spec (Host, Node, Lang, JID::jid()) -> [LI]
make_navigation(Host, Node, Lang) -> make_navigation(Host, Node, Lang, JID) ->
HostNodeMenu = make_host_node_menu(Host, Node, Lang), Menu = make_navigation_menu(Host, Node, Lang, JID),
HostMenu = make_host_menu(Host, HostNodeMenu, Lang),
NodeMenu = make_node_menu(Host, Node, Lang),
Menu = make_server_menu(HostMenu, NodeMenu, Lang),
make_menu_items(Lang, Menu). make_menu_items(Lang, Menu).
%% @spec (Host, Node, Lang, JID::jid()) -> Menu
%% where Host = global | string()
%% Node = cluster | string()
%% Lang = string()
%% Menu = {URL, Title} | {URL, Title, [Menu]}
%% URL = string()
%% Title = string()
make_navigation_menu(Host, Node, Lang, JID) ->
HostNodeMenu = make_host_node_menu(Host, Node, Lang, JID),
HostMenu = make_host_menu(Host, HostNodeMenu, Lang, JID),
NodeMenu = make_node_menu(Host, Node, Lang),
make_server_menu(HostMenu, NodeMenu, Lang, JID).
%% @spec (Host, Node, Base, Lang) -> [LI] %% @spec (Host, Node, Base, Lang) -> [LI]
make_menu_items(global, cluster, Base, Lang) -> make_menu_items(global, cluster, Base, Lang) ->
HookItems = get_menu_items_hook(server, Lang), HookItems = get_menu_items_hook(server, Lang),
@ -2475,19 +2589,21 @@ make_menu_items(Host, Node, Base, Lang) ->
make_menu_items(Lang, {Base, "", HookItems}). make_menu_items(Lang, {Base, "", HookItems}).
make_host_node_menu(global, _, _Lang) -> make_host_node_menu(global, _, _Lang, _JID) ->
{"", "", []}; {"", "", []};
make_host_node_menu(_, cluster, _Lang) -> make_host_node_menu(_, cluster, _Lang, _JID) ->
{"", "", []}; {"", "", []};
make_host_node_menu(Host, Node, Lang) -> make_host_node_menu(Host, Node, Lang, JID) ->
HostNodeBase = get_base_path(Host, Node), HostNodeBase = get_base_path(Host, Node),
HostNodeFixed = [{"modules/", "Modules"}], HostNodeFixed = [{"modules/", "Modules"}]
HostNodeHook = get_menu_items_hook({hostnode, Host, Node}, Lang), ++ get_menu_items_hook({hostnode, Host, Node}, Lang),
{HostNodeBase, atom_to_list(Node), HostNodeFixed ++ HostNodeHook}. HostNodeBasePath = url_to_path(HostNodeBase),
HostNodeFixed2 = [Tuple || Tuple <- HostNodeFixed, is_allowed_path(HostNodeBasePath, Tuple, JID)],
{HostNodeBase, atom_to_list(Node), HostNodeFixed2}.
make_host_menu(global, _HostNodeMenu, _Lang) -> make_host_menu(global, _HostNodeMenu, _Lang, _JID) ->
{"", "", []}; {"", "", []};
make_host_menu(Host, HostNodeMenu, Lang) -> make_host_menu(Host, HostNodeMenu, Lang, JID) ->
HostBase = get_base_path(Host, cluster), HostBase = get_base_path(Host, cluster),
HostFixed = [{"acls", "Access Control Lists"}, HostFixed = [{"acls", "Access Control Lists"},
{"access", "Access Rules"}, {"access", "Access Rules"},
@ -2495,9 +2611,11 @@ make_host_menu(Host, HostNodeMenu, Lang) ->
{"online-users", "Online Users"}, {"online-users", "Online Users"},
{"last-activity", "Last Activity"}, {"last-activity", "Last Activity"},
{"nodes", "Nodes", HostNodeMenu}, {"nodes", "Nodes", HostNodeMenu},
{"stats", "Statistics"}], {"stats", "Statistics"}]
HostHook = get_menu_items_hook({host, Host}, Lang), ++ get_menu_items_hook({host, Host}, Lang),
{HostBase, Host, HostFixed ++ HostHook}. HostBasePath = url_to_path(HostBase),
HostFixed2 = [Tuple || Tuple <- HostFixed, is_allowed_path(HostBasePath, Tuple, JID)],
{HostBase, Host, HostFixed2}.
make_node_menu(_Host, cluster, _Lang) -> make_node_menu(_Host, cluster, _Lang) ->
{"", "", []}; {"", "", []};
@ -2507,21 +2625,23 @@ make_node_menu(global, Node, Lang) ->
{"backup/", "Backup"}, {"backup/", "Backup"},
{"ports/", "Listened Ports"}, {"ports/", "Listened Ports"},
{"stats/", "Statistics"}, {"stats/", "Statistics"},
{"update/", "Update"}], {"update/", "Update"}]
NodeHook = get_menu_items_hook({node, Node}, Lang), ++ get_menu_items_hook({node, Node}, Lang),
{NodeBase, atom_to_list(Node), NodeFixed ++ NodeHook}; {NodeBase, atom_to_list(Node), NodeFixed};
make_node_menu(_Host, _Node, _Lang) -> make_node_menu(_Host, _Node, _Lang) ->
{"", "", []}. {"", "", []}.
make_server_menu(HostMenu, NodeMenu, Lang) -> make_server_menu(HostMenu, NodeMenu, Lang, JID) ->
Base = get_base_path(global, cluster), Base = get_base_path(global, cluster),
Fixed = [{"acls", "Access Control Lists"}, Fixed = [{"acls", "Access Control Lists"},
{"access", "Access Rules"}, {"access", "Access Rules"},
{"vhosts", "Virtual Hosts", HostMenu}, {"vhosts", "Virtual Hosts", HostMenu},
{"nodes", "Nodes", NodeMenu}, {"nodes", "Nodes", NodeMenu},
{"stats", "Statistics"}], {"stats", "Statistics"}]
Hook = get_menu_items_hook(server, Lang), ++ get_menu_items_hook(server, Lang),
{Base, "ejabberd", Fixed ++ Hook}. BasePath = url_to_path(Base),
Fixed2 = [Tuple || Tuple <- Fixed, is_allowed_path(BasePath, Tuple, JID)],
{Base, "ejabberd", Fixed2}.
get_menu_items_hook({hostnode, Host, Node}, Lang) -> get_menu_items_hook({hostnode, Host, Node}, Lang) ->