コード例 #1
0
function listen($_user)
{
    global $CONFIG, $GROUPS, $INTERNAL, $USER, $INTLIST, $INTBUSY;
    $USER = $_user;
    if (!IS_FILTERED) {
        if ($USER->Browsers[0]->ChatId == 0) {
            $USER->Browsers[0]->SetChatId();
        }
        if ($USER->Browsers[0]->Status == CHAT_STATUS_OPEN) {
            initData(true, false, false, false);
            if (isset($_POST[POST_EXTERN_USER_GROUP]) && empty($USER->Browsers[0]->DesiredChatGroup)) {
                $USER->Browsers[0]->DesiredChatGroup = AJAXDecode($_POST[POST_EXTERN_USER_GROUP]);
            }
            $USER->Browsers[0]->SetCookieGroup();
            getInternal();
            if (count($INTLIST) + $INTBUSY > 0) {
                $USER->AddFunctionCall("lz_chat_set_id('" . $USER->Browsers[0]->ChatId . "');", false);
                $chatPosition = getQueuePosition($USER->UserId, $USER->Browsers[0]->DesiredChatGroup);
                $chatWaitingTime = getQueueWaitingTime($chatPosition, $INTBUSY);
                login();
                $USER->Browsers[0]->SetWaiting(!($chatPosition == 1 && count($INTLIST) > 0 && !(!empty($USER->Browsers[0]->DesiredChatPartner) && $INTERNAL[$USER->Browsers[0]->DesiredChatPartner]->Status == USER_STATUS_BUSY)));
                if (!$USER->Browsers[0]->Waiting) {
                    $USER->AddFunctionCall("lz_chat_show_connected();", false);
                    $USER->AddFunctionCall("lz_chat_set_status(lz_chat_data.STATUS_ALLOCATED);", false);
                    if ($CONFIG["gl_alloc_mode"] != ALLOCATION_MODE_ALL || !empty($USER->Browsers[0]->DesiredChatPartner)) {
                        $USER->Browsers[0]->CreateChat($INTERNAL[$USER->Browsers[0]->DesiredChatPartner], $USER);
                    } else {
                        foreach ($INTLIST as $intid => $am) {
                            $USER->Browsers[0]->CreateChat($INTERNAL[$intid], $USER);
                        }
                    }
                } else {
                    $USER->AddFunctionCall("lz_chat_show_queue_position(" . $chatPosition . "," . min($chatWaitingTime, 30) . ");", false);
                }
            }
        } else {
            activeListen();
        }
    } else {
        displayFiltered();
    }
    return $USER;
}
コード例 #2
0
function listen($_user)
{
    global $CONFIG, $GROUPS, $INTERNAL, $USER, $INTLIST, $INTBUSY;
    $USER = $_user;
    if (!IS_FILTERED) {
        if (isnull($USER->Browsers[0]->Chat)) {
            getData(true, false, false, false);
            $USER->Browsers[0]->SetCookieGroup();
            if (isset($_POST[POST_EXTERN_USER_GROUP])) {
                $USER->Browsers[0]->DesiredChatGroup = utf8_decode($_POST[POST_EXTERN_USER_GROUP]);
                $USER->Browsers[0]->SetCookieGroup();
            }
            getInternal();
            $chatId = getChatId($USER, $USER->Browsers[0]->DesiredChatGroup);
            $chatPosition = getQueuePosition($chatId, $USER->Browsers[0]->DesiredChatGroup);
            $chatWaitingTime = getQueueWaitingTime($chatPosition, $INTBUSY);
            login();
            $USER->Browsers[0]->Waiting = !($chatPosition == 1 && count($INTLIST) > 0 && !(!isnull($USER->Browsers[0]->DesiredChatPartner) && $INTERNAL[$USER->Browsers[0]->DesiredChatPartner]->Status != USER_STATUS_ONLINE));
            if (!$USER->Browsers[0]->Waiting) {
                $USER->AddFunctionCall("lz_chat_show_connected();", false);
                $USER->Browsers[0]->DestroyChatFiles();
                $USER->AddFunctionCall("lz_chat_set_status(lz_chat_data.STATUS_ALLOCATED);", false);
                if ($CONFIG["gl_alloc_mode"] != ALLOCATION_MODE_ALL || !isnull($USER->Browsers[0]->DesiredChatPartner)) {
                    $USER->Browsers[0]->CreateChat($INTERNAL[$USER->Browsers[0]->DesiredChatPartner], $chatId);
                } else {
                    foreach ($INTLIST as $intid => $am) {
                        $USER->Browsers[0]->CreateChat($INTERNAL[$intid], $chatId);
                    }
                }
            } else {
                $USER->AddFunctionCall("lz_chat_show_queue_position(" . $chatPosition . "," . $chatWaitingTime . ");", false);
            }
            closeOpenChatLog($USER->Browsers[0]->DesiredChatPartner, $USER->Browsers[0]->SystemId);
        } else {
            activeListen();
        }
    } else {
        displayFiltered();
    }
    return $USER;
}