Example #1
0
 public function registerXMPPAccountByChat($params)
 {
     if ($this->settings['enabled'] == true) {
         $chat = $params['chat'];
         // Append automated hosting subdomain if required
         $subdomainUser = '';
         if ($this->settings['subdomain'] != '') {
             $subdomainUser = '******' . $this->settings['subdomain'];
         }
         // Create DB record for XMPP user
         $xmppAccount = new erLhcoreClassModelXMPPAccount();
         $xmppAccount->lactivity = $xmppAccount->ctime = time();
         $xmppAccount->username = '******' . $chat->id . '.chat' . $subdomainUser . '@' . $this->settings['xmpp_host'];
         $xmppAccount->password = substr(md5(microtime() . rand(0, 100) . $chat->hash), 0, 20);
         $xmppAccount->user_id = $chat->id;
         $xmppAccount->type = erLhcoreClassModelXMPPAccount::USER_TYPE_CHAT;
         $xmppAccount->saveThis();
         // Forward this information to NodeJS server
         erLhcoreClassExtensionXmppserviceHandler::newChat(array('xmpp_account' => $xmppAccount, 'xmpp_host' => $this->settings['xmpp_host'], 'chat' => $chat, 'host_login' => $this->settings['host_login'], 'node_api_server' => $this->settings['node_api_server'], 'handler' => $this->settings['handler'], 'rpc_server' => $this->settings['rpc_server'], 'rpc_username' => $this->settings['rpc_username'], 'rpc_password' => $this->settings['rpc_password'], 'rpc_account_host' => $this->settings['rpc_account_host']));
         erLhcoreClassChatEventDispatcher::getInstance()->dispatch('xmppservice.chat_account_created', array('xmppaccount' => $xmppAccount, 'chat' => $chat));
         return $xmppAccount;
     }
 }