$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; $chat->hash = erLhcoreClassChat::generateHash(); $chat->referrer = isset($_POST['URLRefer']) ? $_POST['URLRefer'] : ''; $chat->session_referrer = isset($_POST['r']) ? $_POST['r'] : ''; if (empty($chat->nick)) { $chat->nick = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/startchat', 'Visitor'); } // Store chat $chat->saveThis();
$chatID = $vid->chat_id; $checkHash = false; } else { echo json_encode(array('stored' => 'false')); exit; } } } try { if ($chatID > 0) { $chat = erLhcoreClassChat::getSession()->load('erLhcoreClassModelChat', $chatID); } else { $chat = false; } if (($checkHash == true && $chat !== false && $chat->hash == $hash || $checkHash == false) && (is_object($vid) || ($chat !== false && $chat->status == erLhcoreClassModelChat::STATUS_PENDING_CHAT || $chat->status == erLhcoreClassModelChat::STATUS_ACTIVE_CHAT))) { erLhcoreClassChatValidator::validateCustomFieldsRefresh($chat); $chat->user_typing = time(); $chat->user_typing_txt = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/refreshcustomfields', 'Data refreshed'); $chat->operation_admin .= "lhinst.updateVoteStatus(" . $chat->id . ");"; $chat->saveThis(); // Force operators to check for new messages erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.data_changed_chat', array('chat' => &$chat)); echo json_encode(array('stored' => 'true')); exit; } } catch (Exception $e) { // Do nothing } } echo json_encode(array('stored' => 'false')); exit;
<?php // Set new chat owner $currentUser = erLhcoreClassUser::instance(); $currentUser->getUserID(); $chat = erLhcoreClassChat::getSession()->load('erLhcoreClassModelChat', $Params['user_parameters']['chat_id']); // Chat can be closed only by owner if (erLhcoreClassChat::hasAccessToRead($chat) && $currentUser->hasAccessTo('lhchat', 'modifychat')) { $tpl = erLhcoreClassTemplate::getInstance('lhchat/modifychat.tpl.php'); if (ezcInputForm::hasPostData()) { $Errors = erLhcoreClassChatValidator::validateChatModify($chat); if (count($Errors) == 0) { $chat->saveThis(); $tpl->set('chat_updated', true); } else { $tpl->set('errors', $Errors); } } $tpl->set('chat', $chat); $Result['content'] = $tpl->fetch(); $Result['pagelayout'] = 'popup'; } else { exit; }
<?php $tpl = erLhcoreClassTemplate::getInstance('lhchat/editnick.tpl.php'); $nickChanged = false; try { $chat = erLhcoreClassChat::getSession()->load('erLhcoreClassModelChat', $Params['user_parameters']['chat_id']); if ($chat->hash == $Params['user_parameters']['hash'] && ($chat->status == erLhcoreClassModelChat::STATUS_PENDING_CHAT || $chat->status == erLhcoreClassModelChat::STATUS_ACTIVE_CHAT)) { if (ezcInputForm::hasPostData()) { $Errors = erLhcoreClassChatValidator::validateNickChange($chat); if (!empty($Errors)) { $tpl->set('errors', $Errors); } else { $chat->saveThis(); $tpl->set('updated', true); $chat->user_typing = time(); $chat->user_typing_txt = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/voteaction', 'User has updated his profile information'); $chat->operation_admin .= "lhinst.updateVoteStatus(" . $chat->id . ");"; $nickChanged = true; } } $tpl->set('chat', $chat); } else { exit; } } catch (Exception $e) { exit; } echo $tpl->fetch(); flush(); session_write_close(); if (function_exists('fastcgi_finish_request')) {