Patch Submission for mod_ctlextra
Taylor Laramie <taylor.laramie <at> globalrelay.net>
2008-03-14 11:58:02 GMT
I made some quick additions to mod_ctlextra and thought they might make
a desirable addition to the module since in it's current state it
doesn't really offer much in the way of retrieving info for shared rosters.
Name : srg-get-shared
Usage : ejabberctl ejabberd <at> localhost srg-get-shared <vhost>
Returns : a list of ':' separated values that represent all the Shared
Rosters for that particular host e.g : Shared Roster1:Shared
Roster2:somethingelse:
Name : srg-shared-info
Usage : ejabberctl ejabberd <at> localhost srg-shared-info <group> <vhost>
Returns : the values for of 'Name' and 'Description' for the provided
SR. I was actually attempting to make this more verbose in that it would
take another directive ('Detail') which would return either
'Name','Description','Display','Members' or All though my skills with
erlang are lacking at this point.
Being that, as I said, my erlang isn't that great I fully expect that
these can be written better / more efficiently so feel free (the powers
that be) to rework them accordingly if they could potentially cause
issues. Attached is a diff made from the latest SVN though let me know
if another format would be preferred.
--- mod_ctlextra.svn 2008-03-14 01:15:01.000000000 -0700
+++ src/mod_ctlextra.erl 2008-03-13 02:03:16.000000000 -0700
<at> <at> -59,6 +59,8 <at> <at>
{"srg-delete group host", "delete the group"},
{"srg-user-add user server group host", "add user <at> server to group on host"},
{"srg-user-del user server group host", "delete user <at> server from group on host"},
+ {"srg-get-shared host", "get list of shared rosters from host"},
+ {"srg-shared-info group host detail", "get list of shared rosters from host"},
%% mod_vcard
{"vcard-get user host data [data2]", "get data from the vCard of the user"},
<at> <at> -179,10 +181,20 <at> <at>
{atomic, ok} = mod_shared_roster:add_user_to_group(Host, {User, Server}, Group),
?STATUS_SUCCESS;
-ctl_process(_Val, ["srg-user-del", User, Server, Group, Host]) ->
+ctl_process(_Val, ["srg-user-del", User, Server, Group, Host ]) ->
{atomic, ok} = mod_shared_roster:remove_user_from_group(Host, {User, Server}, Group),
?STATUS_SUCCESS;
+ctl_process(_Val, ["srg-get-shared", Host]) ->
+ lists:foreach(fun(SrgGroup) -> io:format("~s:",[SrgGroup]) end, lists:sort(mod_shared_roster:list_groups(Host))),
+ io:fwrite("~n"),
+ ?STATUS_SUCCESS;
+
+ctl_process(_Val, ["srg-shared-info", Group, Host ]) ->
+ io:format("~s",[ X || {name , X} <- lists:sort(mod_shared_roster:get_group_opts(Host,Group))]),
+ io:format("::~s~n",[ X || {description , X} <- lists:sort(mod_shared_roster:get_group_opts(Host,Group))]),
+ ?STATUS_SUCCESS;
+
ctl_process(_Val, ["add-rosteritem", LocalUser, LocalServer, RemoteUser, RemoteServer, Nick,
Group, Subs]) ->
case add_rosteritem(LocalUser, LocalServer, RemoteUser, RemoteServer, Nick, Group,
list_to_atom(Subs), []) of
{atomic, ok} ->
_______________________________________________
ejabberd mailing list
ejabberd <at> jabber.ru
http://lists.jabber.ru/mailman/listinfo/ejabberd