Add to roster

This commit is contained in:
Ivan Borzenkov 2010-03-07 23:31:18 +03:00
parent 43b4bc94ab
commit 6e1b55fddf

View File

@ -218,6 +218,41 @@ class XMPPHP_XMPP extends XMPPHP_XMLStream {
#$this->send("<presence type='subscribed' to='{$jid}' from='{$this->fulljid}' />");
}
/**
* Add user to Roster
*
* @param string $jid
* @param string $name
*/
public function RosterAddUser($jid, $name=null, $group=null) {
$payload = "<item jid='$jid'".($name ? " name='" . htmlspecialchars($name) . "'" : '')."/>\n".
($group?'<group>'.htmlspecialchars($group, ENT_QUOTES, 'UTF-8').'</group>':'');
$this->SendIq(NULL, 'set', "jabber:iq:roster", $payload);
}
/**
* Send ID action
*
* @param string $to
* @param string $type
* @param string $xmlns
* @param string $payload
* @param string $from
*/
private function sendIq($to = NULL, $type = 'get', $xmlns = NULL, $payload = NULL, $from = NULL)
{
$id = $this->getID();
$xml = "<iq type='$type' id='$id'".
($to ? " to='$to'" : '').
($from ? " from='$from'" : '').
">
<query xmlns='$xmlns'>
$payload
</query>
</iq>";
return $this->send($xml);
}
/**
* Message handler
*