function processChatActions()
{
    global $RVISITOR;
    $count = 0;
    while (isset($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_va"])) {
        $type = $_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_vd"];
        if ($type == "OperatorSignOff") {
            $op = Server::$Operators[$_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_0"]];
            $op->SignOff();
            CacheManager::FlushKey(DATA_CACHE_KEY_OPERATORS);
        } else {
            if ($type == "SendChatTranscriptTo") {
                $value = 1;
                while (!empty($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_" . $value])) {
                    DBManager::Execute(true, "UPDATE `" . DB_PREFIX . DATABASE_CHAT_ARCHIVE . "` SET `transcript_sent`=0,`transcript_receiver`='" . DBManager::RealEscape($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_0"]) . "' WHERE `transcript_sent`=1 AND `chat_id`='" . DBManager::RealEscape($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_" . $value]) . "' LIMIT 1;");
                    $value++;
                }
                Communication::SendChatTranscripts(true);
            } else {
                if ($type == "CreatePublicGroup") {
                    if (isset(SERVER::$Operators[$_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_2"]]) && SERVER::$Operators[$_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_2"]]->ClientWeb) {
                        continue;
                    }
                    $room = new UserGroup();
                    $room->IsDynamic = true;
                    $room->Id = $_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_0"];
                    $room->Descriptions["EN"] = $_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_1"];
                    $room->Owner = $_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_2"];
                    $room->Save();
                    $room->AddMember($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_2"], false);
                    CacheManager::FlushKey(DATA_CACHE_KEY_OPERATORS);
                    CacheManager::FlushKey(DATA_CACHE_KEY_GROUPS);
                } else {
                    if ($type == "DeletePublicGroup") {
                        $room = new UserGroup();
                        $room->Id = $_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_0"];
                        $room->Destroy();
                        CacheManager::FlushKey(DATA_CACHE_KEY_OPERATORS);
                    } else {
                        if ($type == "JoinPublicGroup") {
                            if (isset(SERVER::$Operators[$_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_2"]])) {
                                if (!SERVER::$Operators[$_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_2"]]->ClientWeb || SERVER::$Operators[$_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_2"]]->Status == USER_STATUS_OFFLINE) {
                                    $room = new UserGroup();
                                    $room->Id = $_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_0"];
                                    $room->AddMember($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_2"], false);
                                    CacheManager::FlushKey(DATA_CACHE_KEY_OPERATORS);
                                }
                            }
                        } else {
                            if ($type == "QuitPublicGroup") {
                                $room = new UserGroup();
                                $room->Id = $_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_0"];
                                $room->RemoveMember($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_1"]);
                                CacheManager::FlushKey(DATA_CACHE_KEY_OPERATORS);
                            } else {
                                if ($type == "StartOverlayChat") {
                                    $chat = new VisitorChat($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_va"], $_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_vb"]);
                                    $chat->RequestInitChat(CALLER_SYSTEM_ID);
                                } else {
                                    if ($type == "AddVisitorComment") {
                                        $visitor = new Visitor($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_0"]);
                                        $visitor->SaveComment(CALLER_SYSTEM_ID, $_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_1"]);
                                    } else {
                                        if ($type == "DownloadRecentHistory") {
                                            $RVISITOR = new Visitor($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_0"]);
                                            $RVISITOR->LoadRecentVisits(true, $_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_1"]);
                                        } else {
                                            if ($type == "SetTranslation") {
                                                $chat = new VisitorChat($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_va"], $_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_vb"]);
                                                $chat->ChatId = $_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_0"];
                                                $chat->SetTranslation($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_1"]);
                                            } else {
                                                if ($type == "SetChatTicketParam") {
                                                    $ticket = new CommercialChatVoucher("", $_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_0"]);
                                                    $ticket->Load();
                                                    $ticket->SetVoucherParams(!empty($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_1"]), !empty($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_2"]), !empty($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_3"]), !empty($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_4"]), !empty($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_5"]), !empty($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_6"]));
                                                } else {
                                                    if (strlen($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_vb"]) > 0 && strlen($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_va"]) > 0) {
                                                        $chat = new VisitorChat($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_va"], $_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_vb"]);
                                                        $chat->ChatId = $_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_vc"];
                                                        $chat->Load();
                                                        if ($type == "SetCallMeBackStatus") {
                                                            $chat->SetCallMeBackStatus($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_0"]);
                                                        } else {
                                                            if ($type == "JoinChatInvisible") {
                                                                $chat->JoinChat(CALLER_SYSTEM_ID, true, !empty($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_0"]));
                                                            } else {
                                                                if ($type == "JoinChat") {
                                                                    $chat->JoinChat(CALLER_SYSTEM_ID, false, !empty($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_0"]));
                                                                } else {
                                                                    if ($type == "SetPriority") {
                                                                        $chat->SetPriority($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_0"]);
                                                                    } else {
                                                                        if ($type == "SetTargetOperator") {
                                                                            $chat->SetTargetOperator($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_0"]);
                                                                        } else {
                                                                            if ($type == "SetTargetGroup") {
                                                                                $chat->SetTargetGroup($_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_0"]);
                                                                            } else {
                                                                                if ($type == "AcceptChat") {
                                                                                    $chat->InternalActivate();
                                                                                } else {
                                                                                    if ($type == "CloseChat") {
                                                                                        $chat->InternalClose(CALLER_SYSTEM_ID);
                                                                                    } else {
                                                                                        if ($type == "TakeChat") {
                                                                                            $chat->TakeChat(CALLER_SYSTEM_ID, $_POST[POST_INTERN_PROCESS_CHAT_ACTION . "_" . $count . "_ve_0"]);
                                                                                        } else {
                                                                                            if ($type == "DeclineChat") {
                                                                                                $chat->InternalDecline(CALLER_SYSTEM_ID);
                                                                                            } else {
                                                                                                if ($type == "LeaveChat") {
                                                                                                    $chat->LeaveChat(CALLER_SYSTEM_ID);
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        $count++;
    }
}
 static function WriteDataUpdateTime($_areaIndex, $_reload = false, $_connector = null, $_prefix = "", $_mtime = 0)
 {
     if (!(isset(CacheManager::$DataUpdateTimesMemory[$_areaIndex]) && CacheManager::$DataUpdateTimesMemory[$_areaIndex] == $_mtime)) {
         CacheManager::$DataUpdateTimesMemory[$_areaIndex] = $_mtime;
         $result = $_connector->Query(true, "SELECT * FROM `" . $_prefix . DATABASE_DATA_UPDATES . "`;");
         if (DBManager::GetRowCount($result) == 0 && !$_reload) {
             $_connector->Query(true, "TRUNCATE `" . $_prefix . DATABASE_DATA_UPDATES . "`;");
             $_connector->Query(true, "INSERT INTO `" . $_prefix . DATABASE_DATA_UPDATES . "` (`update_tickets`, `update_archive`, `update_feedbacks`, `update_emails`, `update_events`, `update_vouchers`, `update_filters`, `update_reports`) VALUES ('0', '0', '0', '0', '0', '0', '0', '0');");
             CacheManager::WriteDataUpdateTime($_areaIndex, true, $_connector, $_prefix, $_mtime);
         } else {
             $_connector->Query(true, "UPDATE `" . $_prefix . DATABASE_DATA_UPDATES . "` SET `" . DBManager::RealEscape($_areaIndex) . "`=" . $_mtime . ";");
             CacheManager::FlushKey(DATA_CACHE_KEY_DATA_TIMES);
         }
     }
 }
 function AddMember($_id, $_persistant = false)
 {
     DBManager::Execute(true, "REPLACE INTO `" . DB_PREFIX . DATABASE_GROUP_MEMBERS . "` (`user_id`, `group_id`, `persistent`) VALUES ('" . DBManager::RealEscape($_id) . "', '" . DBManager::RealEscape($this->Id) . "', " . ($_persistant ? "1" : "0") . ");");
     CacheManager::FlushKey(DATA_CACHE_KEY_GROUPS);
 }