ejabberd - Comments for "mod_admin_extra : set_vcard, more occurrences of an element" https://www.ejabberd.im/node/4346 en Hi, Is there a way to use https://www.ejabberd.im/node/4346#comment-59482 <p>Hi,</p> <p>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?</p> <p>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.</p> <p>Sorry for bring this thread back to life again.</p> Mon, 04 Mar 2013 19:44:40 +0000 lgallard comment 59482 at https://www.ejabberd.im Try recent git and svn https://www.ejabberd.im/node/4346#comment-56741 <div class="quote-msg"> <div class="quote-author"><em>Mataemon</em> wrote:</div> <p>in php (and many languages, I suppose) we can not create an associative array with several times one key.<br /> Of course, if I'm wrong, don't hesitate to correct me! </p></div> <p>I've made some changes to the following files:<br /> ejabberd_ctl.erl<br /> ejabberd_xmlrpc.erl<br /> mod_admin_extra.erl</p> <div class="quote-msg"> <div class="quote-author"><em>Mataemon</em> wrote:</div> <p>If I understand well, set_vcard2_multi requires an array containing a structure of "content". Like this</p> <p>While get_vcard2_mutli returns an array of structures :</p> <p>Could it be possible that both methods use a simple array of string? </p></div> <p>Yes, with those changes now it works like this:</p> <pre> 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"]}}]}]}} </pre> Fri, 15 Oct 2010 20:02:48 +0000 mfoss comment 56741 at https://www.ejabberd.im It works but... https://www.ejabberd.im/node/4346#comment-56735 <p>Thanks a lot, it works.</p> <p>If I understand well, set_vcard2_multi requires an array containing a structure of "content". Like this</p> <div class="codeblock"><code>xmlrpc:call({127, 0, 0, 1}, 4560, &quot;/&quot;, <br />&nbsp;&nbsp;&nbsp; {call, set_vcard2_multi, <br /> [{struct, [<br /> &nbsp;&nbsp;&nbsp; {user, &quot;vincent&quot;}, <br /> &nbsp;&nbsp;&nbsp; {host, &quot;localhost&quot;}, <br /> &nbsp;&nbsp;&nbsp; {name, &quot;ORG&quot;}, <br /> &nbsp;&nbsp;&nbsp; {subname, &quot;ORGUNIT&quot;}, <br /> &nbsp;&nbsp;&nbsp; {contents, <br /> {array, <br /> &nbsp;&nbsp;&nbsp; [{struct, [<br /> {content, &quot;test&quot;},<br /> {content, &quot;test2&quot;}<br /> &nbsp;&nbsp;&nbsp; ]}]<br /> }<br /> &nbsp;&nbsp;&nbsp; }<br /> ]}] <br />&nbsp;&nbsp;&nbsp; }).</code></div> <p>While get_vcard2_mutli returns an array of structures :</p> <div class="codeblock"><code>{ok,{response,[{struct,[{contents,{array,[{struct,[{content,&quot;test&quot;}]},<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {struct,[{content,&quot;test2&quot;}]}]}}]}]}}</code></div> <p>Could it be possible that both methods use a simple array of string?</p> <p>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.</p> <p>Of course, if I'm wrong, don't hesitate to correct me!</p> Tue, 12 Oct 2010 13:18:52 +0000 Mataemon comment 56735 at https://www.ejabberd.im The original Get command only https://www.ejabberd.im/node/4346#comment-56726 <p>The original Get command only gets the first element:</p> <pre> $ ejabberdctl get_vcard2 badlop localhost ORG ORGUNIT org unit 1 </pre><p> This new Get command gets all the elements. Note: it requires exmpp to work correctly:</p> <pre> $ ejabberdctl get_vcard2_multi badlop localhost ORG ORGUNIT org unit 1 org unit 2 org unit 3 </pre><p> The original Set command can only set 1 element:</p> <pre> $ ejabberdctl set_vcard2 badlop localhost ORG ORGUNIT MyOrgUnit11 $ ejabberdctl get_vcard2_multi badlop localhost ORG ORGUNIT MyOrgUnit11 </pre><p> 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.</p> <p>I didn't test it. If you try it, please:<br /> 1. Comment if it works correctly<br /> 2. Provide some example code to allow me and other people to try the command, written in Python/PHP/JavaScript/whatever language you used.</p> <p>I've committed all the changes to mod_admin_extra SVN r1100.</p> Mon, 11 Oct 2010 14:13:00 +0000 mfoss comment 56726 at https://www.ejabberd.im