function fromArray($arr) { $this->name = $arr['name']; $this->attribs = $arr['attribs']; $this->text = $arr['text']; $this->html = $arr['html']; $this->subtags = array(); foreach ($arr['tags'] as $subtag) { $newobj = new CXMLTag(); $newobj->fromArray($subtag); $this->subtags[] = $newobj; } }
function xmpp_invite($from, $to, $room, $reason = "") { global $ircdata, $xmppparams; $fromjid = to_utf($ircdata->nicks[from_utf($from)]['jid'] ? $ircdata->nicks[from_utf($from)]['jid'] : $from . '@' . $xmppparams['componentname'] . '/irc'); $tojid = $ircdata->nicks[from_utf($to)]['jid']; if (!$tojid) { return ''; } $passw = to_utf($ircdata->channels[from_utf($room)]['modes']['k']); $room = $room . '@' . $xmppparams['componentname']; xmpp_normalize_room($room); // XEP MUC $obj = new CXMLTag('message', array('from' => $room, 'to' => $tojid)); $x = new CXMLTag('x', array('xmlns' => FEAT_MUC . '#user')); $invite = new CXMLTag('invite', array('from' => $fromjid)); if (!$reason) { $reason = 'Invite from IRC chat from ' . $from; } $invite->subtags[] = new CXMLTag('reason', array(), $reason); $x->subtags[] = $invite; if ($passw) { $password = new CXMLTag('password', array(), to_utf($passw)); $x->subtags[] = $password; } $obj->subtags[] = $x; // XEP Direct MUC // $obj = new CXMLTag('message',array('from' => $fromjid, 'to' => xmpp_bare_jid($tojid))); $x = new CXMLTag('x', array('xmlns' => 'jabber:x:conference', 'jid' => $room)); $x->attribs['reason'] = $reason; if ($passw) { $x->attribs['password'] = to_utf($passw); } $obj->subtags[] = $x; return $obj->toString(); }