Beispiel #1
0
 public function sendMessageToAllDepartmentOperators($params)
 {
     if ($this->settings['enabled'] == true) {
         // Determine what operators should receive this message
         $db = ezcDbInstance::get();
         $stmt = $db->prepare("SELECT user_id FROM lh_userdep WHERE dep_id = 0 OR dep_id = :dep_id AND lh_userdep.last_activity > :last_activity");
         $stmt->bindValue(':dep_id', $params['chat']->dep_id, PDO::PARAM_INT);
         $stmt->bindValue(':last_activity', time() - (int) erLhcoreClassModelChatConfig::fetch('sync_sound_settings')->data['online_timeout'], PDO::PARAM_INT);
         $stmt->execute();
         $usersId = $stmt->fetchAll(PDO::FETCH_COLUMN);
         if (!empty($usersId)) {
             $accountsXMPP = erLhcoreClassModelXMPPAccount::getList(array('filter' => array('type' => erLhcoreClassModelXMPPAccount::USER_TYPE_OPERATOR, 'sendmessage' => 1), 'filterin' => array('user_id' => $usersId)));
             // Change user nick to proper one
             $rpc = new \GameNet\Jabber\RpcClient(array('server' => $this->settings['rpc_server'], 'host' => $this->settings['xmpp_host'], 'account_host' => $this->settings['rpc_account_host'], 'username' => $this->settings['rpc_username'], 'password' => $this->settings['rpc_password']));
             $paramsOnlineUser = erLhcoreClassExtensionXmppserviceHandler::getNickAndStatusByChat($params['chat']);
             // Nick
             $rpc->setNick($params['xmpp_account']->username_plain, $paramsOnlineUser['nick'], $paramsOnlineUser['status']);
             // Send messages
             foreach ($accountsXMPP as $xmppAccountOpetrator) {
                 if ($params['msg'] === false) {
                     $params['msg'] = new stdClass();
                     $params['msg']->msg = 'New chat request from visitor. Reply to accept a chat';
                 }
                 erLhcoreClassExtensionXmppserviceHandler::sendMessageStartChat(array('xmpp_account' => $params['xmpp_account'], 'xmpp_account_operator' => $xmppAccountOpetrator, 'host_login' => $this->settings['host_login'], 'node_api_server' => $this->settings['node_api_server'], 'chat' => $params['chat'], 'msg' => $params['msg'], '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'], 'xmpp_host' => $this->settings['xmpp_host']));
             }
         }
     }
 }
<?php

if (isset($Result['chat']) && is_numeric($Result['chat']->id)) {
    $xmppServiceExtension = erLhcoreClassModule::getExtensionInstance('erLhcoreClassExtensionXmppservice');
    if ($xmppServiceExtension->settings['enabled'] == true && ($xmppAccount = $xmppServiceExtension->getXMPPAccountByChat($Result['chat'])) !== false) {
        $pageUser = $Result['chat']->online_user !== false ? $Result['chat']->online_user->current_page : '';
        $paramsOnline = erLhcoreClassExtensionXmppserviceHandler::getNickAndStatusByChat($Result['chat'], $pageUser);
        ?>
<script>var xmppservice = {debug:<?php 
        echo $xmppServiceExtension->settings['debug'] == true ? 'true' : 'false';
        ?>
,use_notification:<?php 
        echo $xmppServiceExtension->settings['use_notification'] == true ? 'true' : 'false';
        ?>
,nick:<?php 
        echo json_encode($paramsOnline['nick']);
        ?>
,status:<?php 
        echo json_encode($paramsOnline['status']);
        ?>
,BOSH_SERVICE : '<?php 
        echo $xmppServiceExtension->settings['bosh_service'];
        ?>
', USR : <?php 
        echo json_encode($xmppAccount->username);
        ?>
,PSW : <?php 
        echo json_encode($xmppAccount->password);
        ?>
}</script>
<script type="text/javascript" language="javascript" src="<?php