erLhcoreClassChatWorkflow::timeoutWorkflow PHP Méthode

timeoutWorkflow() public static méthode

Message for timeout
public static timeoutWorkflow ( erLhcoreClassModelChat &$chat )
$chat erLhcoreClassModelChat
    public static function timeoutWorkflow(erLhcoreClassModelChat &$chat)
    {
        $msg = new erLhcoreClassModelmsg();
        $msg->msg = trim($chat->timeout_message);
        $msg->chat_id = $chat->id;
        $msg->name_support = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/startchat', 'Live Support');
        $msg->user_id = -2;
        $msg->time = time();
        erLhcoreClassChat::getSession()->save($msg);
        if ($chat->last_msg_id < $msg->id) {
            $chat->last_msg_id = $msg->id;
        }
        $chat->wait_timeout_send++;
        if ($chat->wait_timeout_send == 1) {
            $chat->timeout_message = '';
        }
        $chat->updateThis();
    }

Usage Example

Exemple #1
0
$blocked = 'false';
$ott = '';
$LastMessageID = 0;
$userOwner = 'true';
$checkStatus = 'f';
$breakSync = false;
$saveChat = false;
$operation = '';
if (is_object($chat) && $chat->hash == $Params['user_parameters']['hash']) {
    $db = ezcDbInstance::get();
    $db->beginTransaction();
    try {
        while (true) {
            // Auto responder
            if ($chat->status == erLhcoreClassModelChat::STATUS_PENDING_CHAT && $chat->wait_timeout_send <= 0 && $chat->wait_timeout > 0 && !empty($chat->timeout_message) && time() - $chat->time > $chat->wait_timeout * ($chat->wait_timeout_repeat - abs($chat->wait_timeout_send))) {
                erLhcoreClassChatWorkflow::timeoutWorkflow($chat);
            }
            if ($chat->status == erLhcoreClassModelChat::STATUS_PENDING_CHAT && $chat->transfer_if_na == 1 && $chat->transfer_timeout_ts < time() - $chat->transfer_timeout_ac) {
                $canExecuteWorkflow = true;
                if (erLhcoreClassModelChatConfig::fetch('pro_active_limitation')->current_value >= 0) {
                    if ($chat->department !== false && $chat->department->department_transfer_id > 0) {
                        $canExecuteWorkflow = erLhcoreClassChat::getPendingChatsCountPublic($chat->department->department_transfer_id) <= erLhcoreClassModelChatConfig::fetch('pro_active_limitation')->current_value;
                    }
                }
                if ($canExecuteWorkflow == true) {
                    erLhcoreClassChatWorkflow::transferWorkflow($chat);
                }
            }
            if ($chat->reinform_timeout > 0 && $chat->unread_messages_informed == 0 && $chat->has_unread_messages == 1 && time() - $chat->last_user_msg_time > $chat->reinform_timeout) {
                $department = $chat->department;
                if ($department !== false) {