Esempio n. 1
0
                    $msg->name_support = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/startchat', 'Live Support');
                    $msg->user_id = -2;
                    $msg->time = time() + 5;
                    erLhcoreClassChat::getSession()->save($msg);
                    if ($chat->last_msg_id < $msg->id) {
                        $chat->last_msg_id = $msg->id;
                    }
                }
                erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.auto_responder_triggered', array('chat' => &$chat));
                $chat->saveThis();
            }
            erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.chat_started', array('chat' => &$chat, 'msg' => $messageInitial));
            erLhcoreClassChat::updateDepartmentStats($chat->department);
            // Paid chat settings
            if (isset($paidChatSettings)) {
                erLhcoreClassChatPaid::processPaidChatWorkflow(array('chat' => $chat, 'paid_chat_params' => $paidChatSettings));
            }
            // Redirect user
            erLhcoreClassModule::redirect('chat/chat/' . $chat->id . '/' . $chat->hash . $themeAppend);
            exit;
        }
    } else {
        // Show errors only if user is not switching form mode
        if ($Params['user_parameters_unordered']['switchform'] != 'true' && !isset($_POST['switchLang'])) {
            $tpl->set('errors', $Errors);
        }
    }
}
$tpl->set('start_data_fields', $startDataFields);
$definition = array('name' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw', null, FILTER_REQUIRE_ARRAY), 'value' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw', null, FILTER_REQUIRE_ARRAY), 'type' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'string', null, FILTER_REQUIRE_ARRAY), 'size' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'string', null, FILTER_REQUIRE_ARRAY), 'req' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'string', null, FILTER_REQUIRE_ARRAY), 'sh' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'string', null, FILTER_REQUIRE_ARRAY), 'hattr' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'string', null, FILTER_REQUIRE_ARRAY), 'value_items_admin' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw', null, FILTER_REQUIRE_ARRAY), 'via_hidden' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw', null, FILTER_REQUIRE_ARRAY), 'encattr' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw', null, FILTER_REQUIRE_ARRAY), 'via_encrypted' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw', null, FILTER_REQUIRE_ARRAY));
$form = new ezcInputForm(INPUT_GET, $definition);
        $tpl->set('theme', $theme);
        $modeAppend .= '/(theme)/' . $theme->id;
    } catch (Exception $e) {
    }
}
if ($Params['user_parameters_unordered']['sound'] !== null && is_numeric($Params['user_parameters_unordered']['sound'])) {
    erLhcoreClassModelUserSetting::setSetting('chat_message', (int) $Params['user_parameters_unordered']['sound'] == 1 ? 1 : 0);
}
if ($Params['user_parameters_unordered']['cstarted'] !== null && $Params['user_parameters_unordered']['cstarted'] != '') {
    $Result['parent_messages'][] = 'lh_callback:' . (string) strip_tags($Params['user_parameters_unordered']['cstarted']);
}
try {
    $chat = erLhcoreClassChat::getSession()->load('erLhcoreClassModelChat', $Params['user_parameters']['chat_id']);
    erLhcoreClassChat::setTimeZoneByChat($chat);
    if (is_numeric($Params['user_parameters_unordered']['pchat'])) {
        erLhcoreClassChatPaid::openChatWidget(array('tpl' => &$tpl, 'pchat' => $Params['user_parameters_unordered']['pchat'], 'chat' => $chat));
    }
    if ($chat->hash == $Params['user_parameters']['hash']) {
        $tpl->set('chat_id', $Params['user_parameters']['chat_id']);
        $tpl->set('hash', $Params['user_parameters']['hash']);
        $tpl->set('chat', $chat);
        $tpl->set('chat_widget_mode', true);
        $tpl->set('chat_embed_mode', $embedMode);
        $tpl->set('survey', is_numeric($Params['user_parameters_unordered']['survey']) ? (int) $Params['user_parameters_unordered']['survey'] : false);
        $Result['chat'] = $chat;
        // User online
        if ($chat->user_status != 0) {
            $db = ezcDbInstance::get();
            $db->beginTransaction();
            $chat->support_informed = 1;
            $chat->user_typing = time();