From 06600d491aa658d30b6f1479c4d1333672969fda Mon Sep 17 00:00:00 2001 From: Ivan Borzenkov Date: Sun, 7 Mar 2010 23:31:18 +0300 Subject: [PATCH] Add to roster --- XMPPHP/XMPP.php | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/XMPPHP/XMPP.php b/XMPPHP/XMPP.php index 97793bc..0349d37 100644 --- a/XMPPHP/XMPP.php +++ b/XMPPHP/XMPP.php @@ -218,6 +218,41 @@ class XMPPHP_XMPP extends XMPPHP_XMLStream { #$this->send(""); } + /** + * Add user to Roster + * + * @param string $jid + * @param string $name + */ + public function RosterAddUser($jid, $name=null, $group=null) { + $payload = "\n". + ($group?''.htmlspecialchars($group, ENT_QUOTES, 'UTF-8').'':''); + $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 = " + + $payload + + "; + return $this->send($xml); + } + /** * Message handler *