public function __get($var)
 {
     switch ($var) {
         case 'mtime_front':
             return date('Ymd') == date('Ymd', $this->mtime) ? date(erLhcoreClassModule::$dateHourFormat, $this->mtime) : date(erLhcoreClassModule::$dateDateHourFormat, $this->mtime);
             break;
         case 'is_sharing':
             return $this->finished == 0 && $this->mtime > time() - 3600;
             break;
         case 'online_user':
             $this->online_user = false;
             if ($this->online_user_id > 0) {
                 try {
                     $this->online_user = erLhcoreClassModelChatOnlineUser::fetch($this->online_user_id);
                 } catch (Exception $e) {
                     $this->online_user = false;
                 }
             }
             return $this->online_user;
             break;
         case 'chat':
             $this->chat = erLhcoreClassModelChat::fetch($this->chat_id);
             return $this->chat;
             break;
         default:
             break;
     }
 }
 public function __get($var)
 {
     switch ($var) {
         case 'time_created_front':
             $this->time_created_front = date('Ymd') == date('Ymd', $this->time) ? date(erLhcoreClassModule::$dateHourFormat, $this->time) : date(erLhcoreClassModule::$dateDateHourFormat, $this->time);
             return $this->time_created_front;
             break;
         case 'user_closed_ts_front':
             $this->user_closed_ts_front = date('Ymd') == date('Ymd', $this->user_closed_ts) ? date(erLhcoreClassModule::$dateHourFormat, $this->user_closed_ts) : date(erLhcoreClassModule::$dateDateHourFormat, $this->user_closed_ts);
             return $this->user_closed_ts_front;
             break;
         case 'is_operator_typing':
             $this->is_operator_typing = $this->operator_typing > time() - 60;
             // typing is considered if status did not changed for 30 seconds
             return $this->is_operator_typing;
             break;
         case 'is_user_typing':
             $this->is_user_typing = $this->user_typing > time() - 10;
             // typing is considered if status did not changed for 30 seconds
             return $this->is_user_typing;
             break;
         case 'wait_time_seconds':
             $this->wait_time_seconds = time() - $this->time;
             return $this->wait_time_seconds;
         case 'wait_time_front':
             $this->wait_time_front = erLhcoreClassChat::formatSeconds($this->wait_time);
             return $this->wait_time_front;
             break;
         case 'wait_time_pending':
             $this->wait_time_pending = erLhcoreClassChat::formatSeconds(time() - $this->time);
             return $this->wait_time_pending;
             break;
         case 'chat_duration_front':
             $this->chat_duration_front = erLhcoreClassChat::formatSeconds($this->chat_duration);
             return $this->chat_duration_front;
             break;
         case 'user_name':
             return $this->user_name = (string) $this->user;
             break;
         case 'plain_user_name':
             $this->plain_user_name = false;
             if ($this->user !== false) {
                 $this->plain_user_name = (string) $this->user->name_support;
             }
             return $this->plain_user_name;
             break;
         case 'user':
             $this->user = false;
             if ($this->user_id > 0) {
                 try {
                     $this->user = erLhcoreClassModelUser::fetch($this->user_id, true);
                 } catch (Exception $e) {
                     $this->user = false;
                 }
             }
             return $this->user;
             break;
         case 'operator_typing_user':
             $this->operator_typing_user = false;
             if ($this->operator_typing_id > 0) {
                 try {
                     $this->operator_typing_user = erLhcoreClassModelUser::fetch($this->operator_typing_id);
                 } catch (Exception $e) {
                     $this->operator_typing_user = false;
                 }
             }
             return $this->operator_typing_user;
             break;
         case 'online_user':
             $this->online_user = false;
             if ($this->online_user_id > 0) {
                 try {
                     $this->online_user = erLhcoreClassModelChatOnlineUser::fetch($this->online_user_id);
                 } catch (Exception $e) {
                     $this->online_user = false;
                 }
             }
             return $this->online_user;
             break;
         case 'department':
             $this->department = false;
             if ($this->dep_id > 0) {
                 try {
                     $this->department = erLhcoreClassModelDepartament::fetch($this->dep_id, true);
                 } catch (Exception $e) {
                 }
             }
             return $this->department;
             break;
         case 'product':
             $this->product = false;
             if ($this->product_id > 0) {
                 try {
                     $this->product = erLhAbstractModelProduct::fetch($this->product_id, true);
                 } catch (Exception $e) {
                 }
             }
             return $this->product;
             break;
         case 'product_name':
             $this->product_name = (string) $this->product;
             return $this->product_name;
             break;
         case 'department_name':
             return $this->department_name = (string) $this->department;
             break;
         case 'number_in_queue':
             $this->number_in_queue = 1;
             if ($this->status == self::STATUS_PENDING_CHAT) {
                 $this->number_in_queue = erLhcoreClassChat::getCount(array('filterlt' => array('id' => $this->id), 'filter' => array('dep_id' => $this->dep_id, 'status' => self::STATUS_PENDING_CHAT))) + 1;
             }
             return $this->number_in_queue;
             break;
         case 'screenshot':
             $this->screenshot = false;
             if ($this->screenshot_id > 0) {
                 try {
                     $this->screenshot = erLhcoreClassModelChatFile::fetch($this->screenshot_id);
                 } catch (Exception $e) {
                 }
             }
             return $this->screenshot;
             break;
         case 'unread_time':
             $diff = time() - $this->last_user_msg_time;
             $hours = floor($diff / 3600);
             $minits = floor(($diff - $hours * 3600) / 60);
             $seconds = $diff - $hours * 3600 - $minits * 60;
             $this->unread_time = array('hours' => $hours, 'minits' => $minits, 'seconds' => $seconds);
             return $this->unread_time;
             break;
         case 'user_tz_identifier_time':
             $date = new DateTime(null, new DateTimeZone($this->user_tz_identifier));
             $this->user_tz_identifier_time = $date->format(erLhcoreClassModule::$dateHourFormat);
             return $this->user_tz_identifier_time;
             break;
         case 'additional_data_array':
             $jsonData = json_decode($this->additional_data);
             if ($jsonData !== null) {
                 $this->additional_data_array = $jsonData;
             } else {
                 $this->additional_data_array = $this->additional_data;
             }
             return $this->additional_data_array;
             break;
         case 'chat_variables_array':
             if (!empty($this->chat_variables)) {
                 $jsonData = json_decode($this->chat_variables, true);
                 if ($jsonData !== null) {
                     $this->chat_variables_array = $jsonData;
                 } else {
                     $this->chat_variables_array = $this->chat_variables;
                 }
             } else {
                 $this->chat_variables_array = $this->chat_variables;
             }
             return $this->chat_variables_array;
             break;
         case 'user_status_front':
             if ($this->online_user !== false) {
                 $this->user_status_front = erLhcoreClassChat::setActivityByChatAndOnlineUser($this, $this->online_user);
             } else {
                 $this->user_status_front = $this->user_status == self::USER_STATUS_JOINED_CHAT ? 0 : 1;
             }
             return $this->user_status_front;
             break;
         default:
             break;
     }
 }
Пример #3
0
<?php

if (is_numeric($Params['user_parameters']['chat_id'])) {
    /*
     * If online user mode we have to make different check
     * */
    $browse = false;
    if ($Params['user_parameters_unordered']['cobrowsemode'] == 'onlineuser') {
        $onlineUser = erLhcoreClassModelChatOnlineUser::fetch($Params['user_parameters']['chat_id']);
        $browse = erLhcoreClassCoBrowse::getBrowseInstanceByOnlineUser($onlineUser);
    } else {
        $chat = erLhcoreClassChat::getSession()->load('erLhcoreClassModelChat', $Params['user_parameters']['chat_id']);
        if (erLhcoreClassChat::hasAccessToRead($chat)) {
            $browse = erLhcoreClassCoBrowse::getBrowseInstance($chat);
        }
    }
    if ($browse instanceof erLhcoreClassModelCoBrowse) {
        if ($browse->modifications != '') {
            $changes = json_decode($browse->modifications);
            $changes[] = array('url' => $browse->url);
            $changes[] = array('lmsg' => $browse->mtime > 0 ? $browse->mtime_front : '');
            $changes[] = array('finished' => array('status' => !$browse->is_sharing, 'text' => $browse->is_sharing == 0 ? erTranslationClassLhTranslation::getInstance()->getTranslation('cobrowse/browse', 'Screen sharing session has finished') : erTranslationClassLhTranslation::getInstance()->getTranslation('cobrowse/browse', 'Screen is shared')));
            if ($browse->finished == 1) {
                $changes[] = array('clear' => true);
            }
            array_unshift($changes, array('base' => $browse->url));
            echo json_encode($changes);
            $browse->modifications = '';
            $browse->saveThis();
        } else {
            $changes = array();
if (is_numeric($Params['user_parameters_unordered']['clear_list']) && $Params['user_parameters_unordered']['clear_list'] == 1) {
    if (!$currentUser->validateCSFRToken($Params['user_parameters_unordered']['csfr'])) {
        die('Invalid CSRF Token');
        exit;
    }
    erLhcoreClassModelChatOnlineUser::cleanAllRecords();
    erLhcoreClassModule::redirect('chat/onlineusers');
    exit;
}
if (is_numeric($Params['user_parameters_unordered']['deletevisitor']) && $Params['user_parameters_unordered']['deletevisitor'] > 0) {
    if (!$currentUser->validateCSFRToken($Params['user_parameters_unordered']['csfr'])) {
        die('Invalid CSRF Token');
        exit;
    }
    try {
        $visitor = erLhcoreClassModelChatOnlineUser::fetch($Params['user_parameters_unordered']['deletevisitor']);
        $visitor->removeThis();
    } catch (Exception $e) {
    }
    erLhcoreClassModule::redirect('chat/onlineusers');
    exit;
}
$is_ajax = isset($Params['user_parameters_unordered']['method']) && $Params['user_parameters_unordered']['method'] == 'ajax';
$timeout = isset($Params['user_parameters_unordered']['timeout']) && is_numeric($Params['user_parameters_unordered']['timeout']) ? (int) $Params['user_parameters_unordered']['timeout'] : 30;
$maxrows = isset($Params['user_parameters_unordered']['maxrows']) && is_numeric($Params['user_parameters_unordered']['maxrows']) ? (int) $Params['user_parameters_unordered']['maxrows'] : 50;
$filter = array('offset' => 0, 'limit' => $maxrows, 'sort' => 'last_visit DESC', 'filtergt' => array('last_visit' => time() - $timeout));
$department = isset($Params['user_parameters_unordered']['department']) && is_numeric($Params['user_parameters_unordered']['department']) ? (int) $Params['user_parameters_unordered']['department'] : false;
if ($department !== false) {
    $filter['filter']['dep_id'] = $department;
}
/**
Пример #5
0
<?php

$tpl = erLhcoreClassTemplate::getInstance('lhxml/userinfo.tpl.php');
try {
    $onlineUsers = erLhcoreClassModelChatOnlineUser::fetch((int) $Params['user_parameters']['user_id']);
    $tpl->set('onlineUsers', $onlineUsers);
    echo json_encode(array('user' => $tpl->fetch()));
} catch (Exception $e) {
    echo json_encode(array('user' => '-'));
}
exit;
 public function __get($var)
 {
     switch ($var) {
         case 'time_created_front':
             $this->time_created_front = date('Ymd') == date('Ymd', $this->time) ? date(erLhcoreClassModule::$dateHourFormat, $this->time) : date(erLhcoreClassModule::$dateDateHourFormat, $this->time);
             return $this->time_created_front;
             break;
         case 'user_closed_ts_front':
             $this->user_closed_ts_front = date('Ymd') == date('Ymd', $this->user_closed_ts) ? date(erLhcoreClassModule::$dateHourFormat, $this->user_closed_ts) : date(erLhcoreClassModule::$dateDateHourFormat, $this->user_closed_ts);
             return $this->user_closed_ts_front;
             break;
         case 'is_operator_typing':
             $this->is_operator_typing = $this->operator_typing > time() - 60;
             // typing is considered if status did not changed for 30 seconds
             return $this->is_operator_typing;
             break;
         case 'is_user_typing':
             $this->is_user_typing = $this->user_typing > time() - 10;
             // typing is considered if status did not changed for 30 seconds
             return $this->is_user_typing;
             break;
         case 'wait_time_front':
             $this->wait_time_front = erLhcoreClassChat::formatSeconds($this->wait_time);
             return $this->wait_time_front;
             break;
         case 'chat_duration_front':
             $this->chat_duration_front = erLhcoreClassChat::formatSeconds($this->chat_duration);
             return $this->chat_duration_front;
             break;
         case 'user_name':
             return $this->user_name = (string) $this->user;
             break;
         case 'user':
             $this->user = false;
             if ($this->user_id > 0) {
                 try {
                     $this->user = erLhcoreClassModelUser::fetch($this->user_id, true);
                 } catch (Exception $e) {
                     $this->user = false;
                 }
             }
             return $this->user;
             break;
         case 'operator_typing_user':
             $this->operator_typing_user = false;
             if ($this->operator_typing_id > 0) {
                 try {
                     $this->operator_typing_user = erLhcoreClassModelUser::fetch($this->operator_typing_id);
                 } catch (Exception $e) {
                     $this->operator_typing_user = false;
                 }
             }
             return $this->operator_typing_user;
             break;
         case 'online_user':
             $this->online_user = false;
             if ($this->online_user_id > 0) {
                 try {
                     $this->online_user = erLhcoreClassModelChatOnlineUser::fetch($this->online_user_id);
                 } catch (Exception $e) {
                     $this->online_user = false;
                 }
             }
             return $this->online_user;
             break;
         case 'department':
             $this->department = false;
             if ($this->dep_id > 0) {
                 try {
                     $this->department = erLhcoreClassModelDepartament::fetch($this->dep_id, true);
                 } catch (Exception $e) {
                 }
             }
             return $this->department;
             break;
         case 'department_name':
             return $this->department_name = (string) $this->department;
             break;
         case 'screenshot':
             $this->screenshot = false;
             if ($this->screenshot_id > 0) {
                 try {
                     $this->screenshot = erLhcoreClassModelChatFile::fetch($this->screenshot_id);
                 } catch (Exception $e) {
                 }
             }
             return $this->screenshot;
             break;
         case 'unread_time':
             $diff = time() - $this->last_user_msg_time;
             $hours = floor($diff / 3600);
             $minits = floor(($diff - $hours * 3600) / 60);
             $seconds = $diff - $hours * 3600 - $minits * 60;
             $this->unread_time = array('hours' => $hours, 'minits' => $minits, 'seconds' => $seconds);
             return $this->unread_time;
             break;
         case 'user_tz_identifier_time':
             $date = new DateTime(null, new DateTimeZone($this->user_tz_identifier));
             $this->user_tz_identifier_time = $date->format(erLhcoreClassModule::$dateHourFormat);
             return $this->user_tz_identifier_time;
             break;
         case 'additional_data_array':
             $jsonData = json_decode($this->additional_data);
             if ($jsonData !== null) {
                 $this->additional_data_array = $jsonData;
             } else {
                 $this->additional_data_array = $this->additional_data;
             }
             return $this->additional_data_array;
             break;
         case 'chat_variables_array':
             if (!empty($this->chat_variables)) {
                 $jsonData = json_decode($this->chat_variables, true);
                 if ($jsonData !== null) {
                     $this->chat_variables_array = $jsonData;
                 } else {
                     $this->chat_variables_array = $this->chat_variables;
                 }
             } else {
                 $this->chat_variables_array = $this->chat_variables;
             }
             return $this->chat_variables_array;
             break;
         default:
             break;
     }
 }
 public function __get($var)
 {
     switch ($var) {
         case 'time_created_front':
             $this->time_created_front = date('Ymd') == date('Ymd', $this->time) ? date(erLhcoreClassModule::$dateHourFormat, $this->time) : date(erLhcoreClassModule::$dateDateHourFormat, $this->time);
             return $this->time_created_front;
             break;
         case 'user_closed_ts_front':
             $this->user_closed_ts_front = date('Ymd') == date('Ymd', $this->user_closed_ts) ? date(erLhcoreClassModule::$dateHourFormat, $this->user_closed_ts) : date(erLhcoreClassModule::$dateDateHourFormat, $this->user_closed_ts);
             return $this->user_closed_ts_front;
             break;
         case 'is_operator_typing':
             $this->is_operator_typing = $this->operator_typing > time() - 60;
             // typing is considered if status did not changed for 30 seconds
             return $this->is_operator_typing;
             break;
         case 'is_user_typing':
             $this->is_user_typing = $this->user_typing > time() - 10;
             // typing is considered if status did not changed for 30 seconds
             return $this->is_user_typing;
             break;
         case 'wait_time_seconds':
             $this->wait_time_seconds = time() - $this->time;
             return $this->wait_time_seconds;
         case 'wait_time_front':
             $this->wait_time_front = erLhcoreClassChat::formatSeconds($this->wait_time);
             return $this->wait_time_front;
             break;
         case 'wait_time_pending':
             $this->wait_time_pending = erLhcoreClassChat::formatSeconds(time() - $this->time);
             return $this->wait_time_pending;
             break;
         case 'chat_duration_front':
             $this->chat_duration_front = erLhcoreClassChat::formatSeconds($this->chat_duration);
             return $this->chat_duration_front;
             break;
         case 'user_name':
             return $this->user_name = (string) $this->user;
             break;
         case 'plain_user_name':
             $this->plain_user_name = false;
             if ($this->user !== false) {
                 $this->plain_user_name = (string) $this->user->name_support;
             }
             return $this->plain_user_name;
             break;
         case 'user':
             $this->user = false;
             if ($this->user_id > 0) {
                 try {
                     $this->user = erLhcoreClassModelUser::fetch($this->user_id, true);
                 } catch (Exception $e) {
                     $this->user = false;
                 }
             }
             return $this->user;
             break;
         case 'operator_typing_user':
             $this->operator_typing_user = false;
             if ($this->operator_typing_id > 0) {
                 try {
                     $this->operator_typing_user = erLhcoreClassModelUser::fetch($this->operator_typing_id);
                 } catch (Exception $e) {
                     $this->operator_typing_user = false;
                 }
             }
             return $this->operator_typing_user;
             break;
         case 'online_user':
             $this->online_user = false;
             if ($this->online_user_id > 0) {
                 try {
                     $this->online_user = erLhcoreClassModelChatOnlineUser::fetch($this->online_user_id);
                 } catch (Exception $e) {
                     $this->online_user = false;
                 }
             }
             return $this->online_user;
             break;
         case 'department':
             $this->department = false;
             if ($this->dep_id > 0) {
                 try {
                     $this->department = erLhcoreClassModelDepartament::fetch($this->dep_id, true);
                 } catch (Exception $e) {
                 }
             }
             return $this->department;
             break;
         case 'department_name':
             return $this->department_name = (string) $this->department;
             break;
         case 'number_in_queue':
             $this->number_in_queue = 1;
             if ($this->status == self::STATUS_PENDING_CHAT) {
                 $this->number_in_queue = erLhcoreClassChat::getCount(array('filterlt' => array('id' => $this->id), 'filter' => array('dep_id' => $this->dep_id, 'status' => self::STATUS_PENDING_CHAT))) + 1;
             }
             return $this->number_in_queue;
             break;
         case 'screenshot':
             $this->screenshot = false;
             if ($this->screenshot_id > 0) {
                 try {
                     $this->screenshot = erLhcoreClassModelChatFile::fetch($this->screenshot_id);
                 } catch (Exception $e) {
                 }
             }
             return $this->screenshot;
             break;
         case 'unread_time':
             $diff = time() - $this->last_user_msg_time;
             $hours = floor($diff / 3600);
             $minits = floor(($diff - $hours * 3600) / 60);
             $seconds = $diff - $hours * 3600 - $minits * 60;
             $this->unread_time = array('hours' => $hours, 'minits' => $minits, 'seconds' => $seconds);
             return $this->unread_time;
             break;
         case 'user_tz_identifier_time':
             $date = new DateTime(null, new DateTimeZone($this->user_tz_identifier));
             $this->user_tz_identifier_time = $date->format(erLhcoreClassModule::$dateHourFormat);
             return $this->user_tz_identifier_time;
             break;
         case 'additional_data_array':
             $jsonData = json_decode($this->additional_data);
             if ($jsonData !== null) {
                 $this->additional_data_array = $jsonData;
             } else {
                 $this->additional_data_array = $this->additional_data;
             }
             return $this->additional_data_array;
             break;
         case 'chat_variables_array':
             if (!empty($this->chat_variables)) {
                 $jsonData = json_decode($this->chat_variables, true);
                 if ($jsonData !== null) {
                     $this->chat_variables_array = $jsonData;
                 } else {
                     $this->chat_variables_array = $this->chat_variables;
                 }
             } else {
                 $this->chat_variables_array = $this->chat_variables;
             }
             return $this->chat_variables_array;
             break;
             /**
              * @desc Returns user status based on the following logic
              * 1. Green - if widget is not closed
              * 2. Green - if widget is closed and user activity tracking enabled and user still on site and he is active
              * 3. Green - if widget is closed and user activity tracking is disabled, but we still receive pings and from last user message has not passed 5 minutes
              *
              * 4. Yellow - if widget is closed and user activity tracking enabled, but user is not active but he is still on site
              * 5. Yellow - from last user message has passed 5 minutes but user still on site
              *
              * 6. Widget is closed and we could not determine online user || None of above conditions are met.
              *
              * If user activity tracking is enabled but status checking not we default to 10 seconds status checks timeout
              *
              * @param array $params
              *
              * 1 GREEN user has activity in last 5 minutes and ping respond
              * 2 ORANGE user has no activity in last 5 minutes and ping respond
              * 3 GREY Offline user fails to respond pings for X number of times in a row
              *
              * @return int
              */
         /**
          * @desc Returns user status based on the following logic
          * 1. Green - if widget is not closed
          * 2. Green - if widget is closed and user activity tracking enabled and user still on site and he is active
          * 3. Green - if widget is closed and user activity tracking is disabled, but we still receive pings and from last user message has not passed 5 minutes
          *
          * 4. Yellow - if widget is closed and user activity tracking enabled, but user is not active but he is still on site
          * 5. Yellow - from last user message has passed 5 minutes but user still on site
          *
          * 6. Widget is closed and we could not determine online user || None of above conditions are met.
          *
          * If user activity tracking is enabled but status checking not we default to 10 seconds status checks timeout
          *
          * @param array $params
          *
          * 1 GREEN user has activity in last 5 minutes and ping respond
          * 2 ORANGE user has no activity in last 5 minutes and ping respond
          * 3 GREY Offline user fails to respond pings for X number of times in a row
          *
          * @return int
          */
         case 'user_status_front':
             $this->user_status_front = $this->user_status == self::USER_STATUS_JOINED_CHAT ? 0 : 1;
             if ($this->user_status_front == self::USER_STATUS_CLOSED_CHAT && $this->online_user !== false || erLhcoreClassChat::$onlineCondition == 1 && $this->online_user !== false) {
                 $timeout = (int) erLhcoreClassChat::$trackTimeout || 10;
                 if (erLhcoreClassChat::$trackActivity == true) {
                     if ($this->online_user->last_check_time_ago < $timeout + 10 && $this->online_user->user_active == 1) {
                         //User still on site, it does not matter that he have closed widget.
                         $this->user_status_front = 0;
                     } elseif ($this->online_user->user_active == 0 && $this->online_user->last_check_time_ago < $timeout + 10) {
                         $this->user_status_front = 2;
                     }
                 } else {
                     if ($this->online_user->last_check_time_ago < $timeout + 10 && time() - $this->last_user_msg_time < 300) {
                         //User still on site, it does not matter that he have closed widget.
                         $this->user_status_front = 0;
                     } elseif (time() - $this->last_user_msg_time >= 300 && $this->online_user->last_check_time_ago < $timeout + 10) {
                         $this->user_status_front = 2;
                     }
                 }
             }
             return $this->user_status_front;
             break;
         default:
             break;
     }
 }
 /**
  * handles messages from operator.
  * Workflow sounds like that
  * 1. Check that we can determine an operator
  * 2. Check to what messages was send, to chat or online visitor
  * 3. If message is send to online visitor check perphaps visitor has active chat
  * 4. If active chat found, send a message
  * 5. If active chat not found send message as proactive invitation
  *
  * @param array $params            
  *
  */
 public static function handleMessageFromOperator($params)
 {
     try {
         $parts = explode('.', $params['receiver']);
         if (isset($parts[1])) {
             $xmppUserLogin = $params['sender'] . '@' . $params['server'];
             $xmppUser = erLhcoreClassModelXMPPAccount::findOne(array('filter' => array('username' => $xmppUserLogin)));
             if ($xmppUser !== false) {
                 // It's message to online visitor
                 if (isset($parts[2]) && $parts[2] == 'chat') {
                     $chat = erLhcoreClassModelChat::fetch($parts[1]);
                     $user = $xmppUser->user;
                     // Messages to chat is only send if chat is not accepted or sender is chat owner
                     if ($chat->user_id == $user->id || $chat->user_id == 0) {
                         self::sendMessageToChat($chat, $xmppUser, $params['body']);
                     } else {
                         $xmppService = erLhcoreClassModule::getExtensionInstance('erLhcoreClassExtensionXmppservice');
                         $xmppService->sendMessageToOperatorAsUserByChat(array('xmpp_account_operator' => $xmppUser, 'chat' => $chat, 'msg' => '[[System Assistant]] Chat was already accepted by [' . $chat->user . '], your messages are now ignored'));
                     }
                 } else {
                     $visitorId = $parts[1];
                     $visitor = erLhcoreClassModelChatOnlineUser::fetch($visitorId);
                     // We do not have any active chat
                     if ($visitor->chat === false || !in_array($visitor->chat->status, array(erLhcoreClassModelChat::STATUS_ACTIVE_CHAT, erLhcoreClassModelChat::STATUS_PENDING_CHAT))) {
                         $visitor->operator_message = $params['body'];
                         $visitor->message_seen = 0;
                         $visitor->invitation_id = -1;
                         $visitor->operator_user_id = $xmppUser->user_id;
                         $visitor->saveThis();
                         // We have active chat
                     } else {
                         self::sendMessageToChat($visitor->chat, $xmppUser, $params['body']);
                     }
                 }
             } else {
                 throw new Exception('Could not find a operator');
             }
         } else {
             throw new Exception('Could not extract visitor ID');
         }
     } catch (Exception $e) {
         throw $e;
     }
 }