* @revision 05 * @license http://creativecommons.org/licenses/by-sa/3.0/de/ Creative Commons Attribution-Sha * @homepage http://oss.tiggerswelt.net/xmpp * @copyright Copyright © 2008 tiggersWelt.net */ class XMPP_Transport_Registration extends tiggerXMPP_XEP_0077_Entity { private $Fields; // {{{ __construct /** * Initialize this class * * @access friendly * @return void */ function __construct ($JID, $Parent = null) { // Setup our parent class parent::__construct ($JID, $Parent); // Set our fields $this->Fields = array ( new tiggerXMPP_XEP_0077_Field (tiggerXMPP_XEP_0077_Field::NAME_USERNAME), new tiggerXMPP_XEP_0077_Field (tiggerXMPP_XEP_0077_Field::NAME_PASSWORD), ); } // }}} // {{{ getFields /** * Retrive fields for registration * * @param string $ForJID (optional) * * @access public * @return array */ public function getFields ($ForJID = "") { return $this->Fields; } // }}} // {{{ setData /** * Store authentication-information for a JID * * @param string $ForJID * @param array $Data * * @access public * @return bool */ public function setData ($ForJID, $Data) { // Get handle our our parent XMPP $Parent = $this->Parent->getParent (); if (!is_a ($Parent, "XMPP_ICQ_Transport") && !is_subclass_of ($Parent, "XMPP_ICQ_Transport")) return false; // Reformat our JID $JID = $Parent->getJID (true, true, false, $ForJID); // Peek fields from registration $Username = $Data ["username"][0]->getValue (); $Password = $Data ["password"][0]->getValue (); // Check if client is already registered if (is_object ($Client = $Parent->getClient ($JID))) return $Client->setLogin ($Username, $Password); return $Parent->addClient ($JID, $Username, $Password); } // }}} } ?>