From: Badlop Date: Thu, 15 Dec 2011 16:19:47 +0000 (+0100) Subject: Preliminary support for groupname@vhost in Displayed Groups (EJAB-506) X-Git-Tag: v3.0.0-alpha-5~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7a53b66e46322b8e3afca9144def4e1e8fb4ec53;p=ejabberd Preliminary support for groupname@vhost in Displayed Groups (EJAB-506) --- diff --git a/doc/guide.tex b/doc/guide.tex index 2157d1ef9..600dfe5e2 100644 --- a/doc/guide.tex +++ b/doc/guide.tex @@ -4201,8 +4201,9 @@ has a unique identification and the following parameters: which is only recommended for a small server with just a few hundred users. The special member directive \term{@online@} represents the online users in the virtual host. -\item[Displayed groups] A list of groups that will be in the rosters of this - group's members. +\item[Displayed groups] + A list of groups that will be in the rosters of this group's members. + A group of other vhost can be identified with \term{groupid@vhost} \end{description} Examples: diff --git a/src/mod_shared_roster.erl b/src/mod_shared_roster.erl index 50b4472c0..cef41625b 100644 --- a/src/mod_shared_roster.erl +++ b/src/mod_shared_roster.erl @@ -496,7 +496,8 @@ get_user_groups(US) -> [] end ++ get_special_users_groups(Host). -is_group_enabled(Host, Group) -> +is_group_enabled(Host1, Group1) -> + {Host, Group} = split_grouphost(Host1, Group1), case catch mnesia:dirty_read(sr_group, {Group, Host}) of [#sr_group{opts = Opts}] -> not lists:member(disabled, Opts); @@ -527,7 +528,8 @@ get_online_users(Host) -> get_group_users(HostB, Group) when is_binary(HostB) -> get_group_users(binary_to_list(HostB), Group); -get_group_users(Host, Group) -> +get_group_users(Host1, Group1) -> + {Host, Group} = split_grouphost(Host1, Group1), case get_group_opt(Host, Group, all_users, false) of true -> ejabberd_auth:get_vh_registered_users(Host); @@ -573,7 +575,8 @@ get_group_explicit_users(Host, Group) -> [] end. -get_group_name(Host, Group) -> +get_group_name(Host1, Group1) -> + {Host, Group} = split_grouphost(Host1, Group1), get_group_opt(Host, Group, name, Group). %% @spec(Host::string) @@ -1135,3 +1138,11 @@ get_opt(Opts, Opt, Default) -> us_to_list({User, Server}) -> exmpp_jid:bare_to_list(User, Server). + +split_grouphost(Host, Group) -> + case string:tokens(Group, "@") of + [GroupName, HostName] -> + {HostName, GroupName}; + [_] -> + {Host, Group} + end.