// Leave a message functionality $leaveamessage = (string) $Params['user_parameters_unordered']['leaveamessage'] == 'true' || isset($startDataFields['force_leave_a_message']) && $startDataFields['force_leave_a_message'] == true ? true : false; $tpl->set('forceoffline', false); $additionalParams = array(); if ((string) $Params['user_parameters_unordered']['offline'] == 'true' && $leaveamessage == true) { $additionalParams['offline'] = true; $tpl->set('forceoffline', true); } $tpl->set('leaveamessage', $leaveamessage); if (isset($_POST['StartChat']) && $disabled_department === false) { // Validate post data $Errors = erLhcoreClassChatValidator::validateStartChat($inputData, $startDataFields, $chat, $additionalParams); if (count($Errors) == 0 && !isset($_POST['switchLang'])) { $chat->setIP(); erLhcoreClassModelChat::detectLocation($chat); $statusGeoAdjustment = erLhcoreClassChat::getAdjustment(erLhcoreClassModelChatConfig::fetch('geoadjustment_data')->data_value, $inputData->vid); if ($statusGeoAdjustment['status'] == 'hidden') { // This should never happen exit('Chat not available in your country'); } if (isset($additionalParams['offline']) && $additionalParams['offline'] == true || $statusGeoAdjustment['status'] == 'offline') { erLhcoreClassChatMail::sendMailRequest($inputData, $chat, array('chatprefill' => isset($chatPrefill) ? $chatPrefill : false)); if (isset($chatPrefill) && $chatPrefill instanceof erLhcoreClassModelChat) { erLhcoreClassChatValidator::updateInitialChatAttributes($chatPrefill, $chat); } erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.chat_offline_request', array('input_data' => $inputData, 'chat' => $chat, 'prefill' => array('chatprefill' => isset($chatPrefill) ? $chatPrefill : false))); $Result['parent_messages'][] = 'lh_callback:offline_request_cb'; $tpl->set('request_send', true); } else { $chat->time = time(); $chat->status = 0;
if (is_array($Params['user_parameters_unordered']['department'])) { erLhcoreClassChat::validateFilterIn($Params['user_parameters_unordered']['department']); $department = $Params['user_parameters_unordered']['department']; } else { $department = false; } if (is_array($Params['user_parameters_unordered']['ua'])) { $uarguments = $Params['user_parameters_unordered']['ua']; } else { $uarguments = false; } $proactiveInviteActive = erLhcoreClassModelChatConfig::fetch('pro_active_invite')->current_value; erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.chatcheckoperatormessage', array('proactive_active' => &$proactiveInviteActive)); $userInstance = erLhcoreClassModelChatOnlineUser::handleRequest(array('uactiv' => (int) $Params['user_parameters_unordered']['uactiv'], 'wopen' => (int) $Params['user_parameters_unordered']['wopen'], 'tpl' => &$tpl, 'tz' => $Params['user_parameters_unordered']['tz'], 'message_seen_timeout' => erLhcoreClassModelChatConfig::fetch('message_seen_timeout')->current_value, 'department' => $department, 'identifier' => (string) $Params['user_parameters_unordered']['identifier'], 'pages_count' => (int) $Params['user_parameters_unordered']['count_page'] == 1 ? true : false, 'vid' => (string) $Params['user_parameters_unordered']['vid'], 'check_message_operator' => true, 'pro_active_limitation' => erLhcoreClassModelChatConfig::fetch('pro_active_limitation')->current_value, 'pro_active_invite' => $proactiveInviteActive)); // Exit if not required $statusGeoAdjustment = erLhcoreClassChat::getAdjustment(erLhcoreClassModelChatConfig::fetch('geoadjustment_data')->data_value, '', false, $userInstance); if ($statusGeoAdjustment['status'] == 'offline' || $statusGeoAdjustment['status'] == 'hidden') { echo "lh_inst.stopCheckNewMessage();"; // Stop check for messages and save resources exit; } if ((int) $Params['user_parameters_unordered']['count_page'] == 1 && erLhcoreClassModelChatConfig::fetch('track_footprint')->current_value == 1 && isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER'])) { erLhcoreClassModelChatOnlineUserFootprint::addPageView($userInstance); } if ($userInstance !== false) { if ($userInstance->invitation_id == -1) { $userInstance->invitation_id = 0; $userInstance->invitation_assigned = true; $userInstance->saveThis(); } $tpl->set('priority', is_numeric($Params['user_parameters_unordered']['priority']) ? (int) $Params['user_parameters_unordered']['priority'] : false);