function CreateArchiveEntry($_internalUser, $_visitor, $custom = "", $etpl = "", $_customsInTranscript = true, $pdm = null) { global $CONFIG, $INPUTS, $GROUPS, $LZLANG; if ($this->ArchiveCreated) { return; } if ($INPUTS[111]->Active) { $custom .= strip_tags($INPUTS[111]->Caption) . " %efullname%\r\n"; } if ($INPUTS[112]->Active) { $custom .= strip_tags($INPUTS[112]->Caption) . " %eemail%\r\n"; } if (!empty($this->Company) && $INPUTS[113]->Active) { $custom .= strip_tags($INPUTS[113]->Caption) . " " . trim($this->Company) . "\r\n"; } if (!empty($this->Question) && $INPUTS[114]->Active) { $custom .= strip_tags($INPUTS[114]->Caption) . " " . trim($this->Question) . "\r\n"; } if (!empty($this->Phone) && $INPUTS[116]->Active) { $custom .= strip_tags($INPUTS[116]->Caption) . " " . trim($this->Phone) . "\r\n"; } if (!empty($this->ChatVoucherId)) { $custom .= strip_tags($LZLANG["client_voucher_id"]) . " " . trim($this->ChatVoucherId) . "\r\n"; } $customs = array(); if (is_array($this->Customs)) { foreach ($this->Customs as $cind => $value) { if ($INPUTS[$cind]->Active && $INPUTS[$cind]->Custom) { $customs[$INPUTS[$cind]->Name] = $value; if (!isset($GROUPS[$this->DesiredChatGroup]->ChatInputsHidden[$cind]) && $_customsInTranscript) { if ($INPUTS[$cind]->Type == "CheckBox") { $custom .= strip_tags($INPUTS[$cind]->Caption) . " " . (!empty($value) ? "<!--lang_client_yes-->" : "<!--lang_client_no-->") . "\r\n"; } else { if ($INPUTS[$cind]->Type == "ComboBox") { $custom .= strip_tags($INPUTS[$cind]->Caption) . " " . $INPUTS[$cind]->GetClientValue($value) . "\r\n"; } else { $custom .= strip_tags($INPUTS[$cind]->Caption) . " " . $value . "\r\n"; } } } } } } if (!empty($GROUPS[$this->DesiredChatGroup]->PredefinedMessages)) { $pdm = getPredefinedMessage($GROUPS[$this->DesiredChatGroup]->PredefinedMessages, $_visitor->Language); if (!empty($pdm->EmailChatTranscript)) { $etpl = $pdm->EmailChatTranscript; } } $etpl = str_replace("%external_ip%", getIP(), $etpl); $etpl = str_replace("%chat_id%", $this->ChatId, $etpl); $etpl = str_replace("%website_name%", $CONFIG["gl_site_name"], $etpl); $etpl = str_replace("%details%", $custom, $etpl); $etpl = str_replace("%group_description%", $GROUPS[$this->DesiredChatGroup]->GetDescription($_visitor->Language), $etpl); $etpl = str_replace(array("%group_name%", "%group_id%"), $this->DesiredChatGroup, $etpl); if ($this->InternalUser) { $etpl = str_replace("%operator_name%", $this->InternalUser->Fullname, $etpl); $etpl = str_replace("%operator_email%", $this->InternalUser->Email, $etpl); } $etpl = str_replace("%external_name%", "%efullname%", $etpl); $etpl = str_replace("%external_email%", "%eemail%", $etpl); $etpl = str_replace("%external_company%", $this->Company, $etpl); $etpl = str_replace("%external_phone%", $this->Phone, $etpl); $etpl = str_replace("%question%", $this->Question, $etpl); $subject = $pdm != null ? $pdm->SubjectChatTranscript : ""; $subject = getSubject($subject, $this->Email, $this->Fullname, $this->DesiredChatGroup, $this->ChatId, $this->Company, $this->Phone, getIP(), $this->Question, $GROUPS[$this->DesiredChatGroup]->GetDescription($_visitor->Language), $this->Customs); $internal = $_internalUser != null && $_internalUser->IsBot ? $_internalUser->SystemId : ""; $result = queryDB(true, "SELECT * FROM `" . DB_PREFIX . DATABASE_CHAT_ARCHIVE . "` WHERE `chat_id`='" . DBManager::RealEscape($this->ChatId) . "';"); if ($result && DBManager::GetRowCount($result) == 0) { if ($CONFIG["gl_adct"] == 1 || (!empty($CONFIG["gl_rm_chats_time"]) || empty($CONFIG["gl_rm_chats"]))) { queryDB(true, "INSERT INTO `" . DB_PREFIX . DATABASE_CHAT_ARCHIVE . "` (`time`,`endtime`,`closed`,`chat_id`,`external_id`,`fullname`,`internal_id`,`group_id`,`area_code`,`html`,`plaintext`,`transcript_text`,`email`,`company`,`iso_language`,`iso_country`,`host`,`ip`,`gzip`,`transcript_sent`,`transcript_receiver`,`question`,`customs`,`subject`,`voucher_id`) VALUES ('" . DBManager::RealEscape($this->FirstActive) . "',0,0,'" . DBManager::RealEscape($this->ChatId) . "','" . DBManager::RealEscape($this->UserId) . "','','" . DBManager::RealEscape($internal) . "','','" . DBManager::RealEscape($this->Code) . "','','','" . DBManager::RealEscape($etpl) . "','','','" . DBManager::RealEscape($_visitor->Language) . "','" . DBManager::RealEscape($_visitor->GeoCountryISO2) . "','" . DBManager::RealEscape($_visitor->Host) . "','" . DBManager::RealEscape($_visitor->IP) . "',0,0,'" . DBManager::RealEscape($this->Email) . "','','" . DBManager::RealEscape(@serialize($customs)) . "','" . DBManager::RealEscape($subject) . "','" . DBManager::RealEscape($this->ChatVoucherId) . "');"); } $this->ArchiveCreated = true; ChatRequest::AcceptAll($this->UserId); } }
function CreateArchiveEntry($_internalUser, $_visitor, $custom = "", $etpl = "", $_customsInTranscript = true, $pdm = null) { if (!empty($this->ArchiveCreated)) { return; } if (Server::$Inputs[111]->Active) { $custom .= strip_tags(Server::$Inputs[111]->Caption) . " %efullname%\r\n"; } if (Server::$Inputs[112]->Active) { $custom .= strip_tags(Server::$Inputs[112]->Caption) . " %eemail%\r\n"; } if (!empty($this->Company) && Server::$Inputs[113]->Active) { $custom .= strip_tags(Server::$Inputs[113]->Caption) . " " . trim($this->UserData->Company) . "\r\n"; } if (!empty($this->Question) && Server::$Inputs[114]->Active) { $custom .= strip_tags(Server::$Inputs[114]->Caption) . " " . trim($this->UserData->Text) . "\r\n"; } if (!empty($this->Phone) && Server::$Inputs[116]->Active) { $custom .= strip_tags(Server::$Inputs[116]->Caption) . " " . trim($this->UserData->Phone) . "\r\n"; } if (!empty($this->ChatVoucherId)) { $custom .= strip_tags(LocalizationManager::$TranslationStrings["client_voucher_id"]) . " " . trim($this->ChatVoucherId) . "\r\n"; } $customs = array(); if (is_array($this->UserData->Customs)) { foreach ($this->UserData->Customs as $cind => $value) { if (Server::$Inputs[$cind]->Active && Server::$Inputs[$cind]->Custom) { $customs[Server::$Inputs[$cind]->Name] = $value; if (!isset(Server::$Groups[$this->DesiredChatGroup]->ChatInputsHidden[$cind]) && $_customsInTranscript) { if (Server::$Inputs[$cind]->Type == "CheckBox") { $custom .= strip_tags(Server::$Inputs[$cind]->Caption) . " " . (!empty($value) ? "<!--lang_client_yes-->" : "<!--lang_client_no-->") . "\r\n"; } else { if (Server::$Inputs[$cind]->Type == "ComboBox") { $custom .= strip_tags(Server::$Inputs[$cind]->Caption) . " " . Server::$Inputs[$cind]->GetClientValue($value) . "\r\n"; } else { $custom .= strip_tags(Server::$Inputs[$cind]->Caption) . " " . $value . "\r\n"; } } } } } } $tsData = array("", ""); if (!empty(Server::$Groups[$this->DesiredChatGroup]->PredefinedMessages)) { $pdm = PredefinedMessage::GetByLanguage(Server::$Groups[$this->DesiredChatGroup]->PredefinedMessages, $_visitor->Language); if (!empty($pdm->EmailChatTranscriptBodyPlaintext)) { $tsData[0] = $pdm->EmailChatTranscriptBodyPlaintext; } if (!empty($pdm->EmailChatTranscriptBodyHTML)) { $tsData[1] = $pdm->EmailChatTranscriptBodyHTML; } } for ($i = 0; $i < count($tsData); $i++) { $tsData[$i] = str_replace("%chat_id%", $this->ChatId, $tsData[$i]); $tsData[$i] = str_replace("%details%", $custom, $tsData[$i]); $tsData[$i] = str_replace("%external_name%", "%efullname%", $tsData[$i]); $tsData[$i] = str_replace("%external_email%", "%eemail%", $tsData[$i]); $tsData[$i] = str_replace("%external_company%", $this->UserData->Company, $tsData[$i]); $tsData[$i] = str_replace("%external_phone%", $this->UserData->Phone, $tsData[$i]); $tsData[$i] = str_replace("%question%", $this->UserData->Text, $tsData[$i]); $tsData[$i] = str_replace("%feedback_link%", Feedback::GetLink("cid=" . Encoding::Base64UrlEncode($this->ChatId)), $tsData[$i]); $tsData[$i] = Server::$Groups[$this->DesiredChatGroup]->TextReplace($tsData[$i], $_visitor->Language); if (!empty($this->OperatorId)) { $tsData[$i] = Server::$Operators[$this->OperatorId]->TextReplace($tsData[$i]); } $tsData[$i] = $_visitor->TextReplace($tsData[$i]); $tsData[$i] = Configuration::Replace($tsData[$i]); } $subject = $pdm != null ? $pdm->SubjectChatTranscript : ""; $subject = Mailbox::GetSubject($subject, $this->UserData->Email, $this->UserData->Fullname, $this->DesiredChatGroup, $this->ChatId, $this->UserData->Company, $this->UserData->Phone, Communication::GetIP(), $this->UserData->Text, Server::$Groups[$this->DesiredChatGroup]->GetDescription($_visitor->Language), $this->UserData->Customs); $internal = $_internalUser != null && $_internalUser->IsBot ? $_internalUser->SystemId : ""; $result = DBManager::Execute(true, "SELECT * FROM `" . DB_PREFIX . DATABASE_CHAT_ARCHIVE . "` WHERE `chat_id`='" . DBManager::RealEscape($this->ChatId) . "';"); if ($result && DBManager::GetRowCount($result) == 0) { if (Server::$Configuration->File["gl_adct"] == 1 || (!empty(Server::$Configuration->File["gl_rm_chats_time"]) || empty(Server::$Configuration->File["gl_rm_chats"]))) { $url = Visitor::GetLastURLFromVisitor($this->UserId); DBManager::Execute(true, "INSERT INTO `" . DB_PREFIX . DATABASE_CHAT_ARCHIVE . "` (`time`,`endtime`,`closed`,`chat_id`,`external_id`,`fullname`,`internal_id`,`group_id`,`area_code`,`html`,`plaintext`,`transcript_text`,`transcript_html`,`email`,`company`,`iso_language`,`iso_country`,`host`,`ip`,`gzip`,`transcript_sent`,`transcript_receiver`,`question`,`customs`,`subject`,`voucher_id`,`ref_url`) VALUES ('" . DBManager::RealEscape($this->FirstActive) . "',0,0,'" . DBManager::RealEscape($this->ChatId) . "','" . DBManager::RealEscape($this->UserId) . "','','" . DBManager::RealEscape($internal) . "','','" . DBManager::RealEscape($this->Code) . "','','','" . DBManager::RealEscape($tsData[0]) . "','" . DBManager::RealEscape($tsData[1]) . "','','','" . DBManager::RealEscape($_visitor->Language) . "','" . DBManager::RealEscape($_visitor->GeoCountryISO2) . "','" . DBManager::RealEscape($_visitor->Host) . "','" . DBManager::RealEscape($_visitor->IP) . "',0,0,'" . DBManager::RealEscape($this->UserData->Email) . "','','" . DBManager::RealEscape(@serialize($customs)) . "','" . DBManager::RealEscape($subject) . "','" . DBManager::RealEscape($this->ChatVoucherId) . "','" . DBManager::RealEscape($url) . "');"); } $this->ArchiveCreated = 1; ChatRequest::AcceptAll($this->UserId); } }