mod_admin_extra : set_vcard, more occurrences of an element

Hi,

The ORGUNIT element can occur zero or more times inside the ORG element (as we can see in specs).

But I'm afraid we can't add multiple occurrences of an element using set_vcard.

Is there another way to do that? (note that I have no knowledge in erlang to modify mod_admin_extra)

Thanks in advance

The original Get command only

The original Get command only gets the first element:

$ ejabberdctl get_vcard2 badlop localhost ORG ORGUNIT
org unit 1

This new Get command gets all the elements. Note: it requires exmpp to work correctly:

$ ejabberdctl get_vcard2_multi badlop localhost ORG ORGUNIT
org unit 1
org unit 2
org unit 3

The original Set command can only set 1 element:

$ ejabberdctl set_vcard2 badlop localhost ORG ORGUNIT MyOrgUnit11
$ ejabberdctl get_vcard2_multi badlop localhost ORG ORGUNIT
MyOrgUnit11

I wrote a new Set command that supports multiple elements, but it can only be used with ejabberd_xmlrpc or mod_rest, not with ejabberdctl.

I didn't test it. If you try it, please:
1. Comment if it works correctly
2. Provide some example code to allow me and other people to try the command, written in Python/PHP/JavaScript/whatever language you used.

I've committed all the changes to mod_admin_extra SVN r1100.

It works but...

Thanks a lot, it works.

If I understand well, set_vcard2_multi requires an array containing a structure of "content". Like this

xmlrpc:call({127, 0, 0, 1}, 4560, "/",
    {call, set_vcard2_multi,
[{struct, [
    {user, "vincent"},
    {host, "localhost"},
    {name, "ORG"},
    {subname, "ORGUNIT"},
    {contents,
{array,
    [{struct, [
{content, "test"},
{content, "test2"}
    ]}]
}
    }
]}]
    }).

While get_vcard2_mutli returns an array of structures :

{ok,{response,[{struct,[{contents,{array,[{struct,[{content,"test"}]},
                                          {struct,[{content,"test2"}]}]}}]}]}}

Could it be possible that both methods use a simple array of string?

In addition to the consistency problem, in php (and many languages, I suppose) we can not create an associative array with several times one key.

Of course, if I'm wrong, don't hesitate to correct me!

Try recent git and svn

Mataemon wrote:

in php (and many languages, I suppose) we can not create an associative array with several times one key.
Of course, if I'm wrong, don't hesitate to correct me!

I've made some changes to the following files:
ejabberd_ctl.erl
ejabberd_xmlrpc.erl
mod_admin_extra.erl

Mataemon wrote:

If I understand well, set_vcard2_multi requires an array containing a structure of "content". Like this

While get_vcard2_mutli returns an array of structures :

Could it be possible that both methods use a simple array of string?

Yes, with those changes now it works like this:

xmlrpc:call({127, 0, 0, 1}, 4560, "/", {call, set_vcard2_multi,
  [{struct, [
    {user, "badlop"},
    {host, "localhost"},
    {name, "ORG"},
    {subname, "ORGUNIT"},
    {contents, {array, [
		"test 1C",
		"test 2C",
		"test 3C"
  ]}}]}]}).

xmlrpc:call({127, 0, 0, 1}, 4560, "/", {call, get_vcard2_multi,
  [{struct, [
    {user, "badlop"},
    {host, "localhost"},
    {name, "ORG"},
    {subname, "ORGUNIT"}
  ]}]}).

{ok,{response,[{struct,[{contents,{array,["test 1C","test 2C","test 3C"]}}]}]}}

Hi, Is there a way to use

Hi,

Is there a way to use "ejabberdctl set_vcard2_multi" from the console with a php script. I successfully used set_vcard to sing keys but for multi keys I don't know hot to pass the array of string. Any suggestion?

By the way, I can't compile ejabberd. I have to use Ubuntu 12.04 LTS's ejabberd binary, which is version 2.1.10. Meaning I don't have ejabberd_xmlrpc.

Sorry for bring this thread back to life again.

Syndicate content