function SendAutoresponder($_visitor = null, $_browser = null, $_message = null) { if (empty($_message)) { $_message = $this->Messages[0]; } $tsData = array("", "", ""); if (!empty(Server::$Groups[$this->Group]->PredefinedMessages)) { $pdm = PredefinedMessage::GetByLanguage(Server::$Groups[$this->Group]->PredefinedMessages, $this->Language); if ($pdm != null) { if (!empty($pdm->EmailTicketResponderBodyPlaintext)) { $tsData[0] = $pdm->EmailTicketResponderBodyPlaintext; } if (!empty($pdm->EmailTicketResponderBodyHTML)) { $tsData[1] = $pdm->EmailTicketResponderBodyHTML; } $tsData[2] = $pdm->SubjectTicketResponder; } } for ($i = 0; $i < count($tsData); $i++) { $tText = ($i != 1 ? $_message->Text : nl2br($_message->Text)) . "<!--lz_ref_link-->"; $tsData[$i] = str_replace("%mailtext%", $tText, $tsData[$i]); $tsData[$i] = $_message->TextReplace($tsData[$i], $this->Group); $tsData[$i] = $this->TextReplace($tsData[$i]); $tsData[$i] = Server::$Groups[$this->Group]->TextReplace($tsData[$i], $this->Language); if (!empty($_visitor)) { $tsData[$i] = $_visitor->TextReplace($tsData[$i]); } if (!empty($_browser)) { $tsData[$i] = $_browser->TextReplace($tsData[$i]); } $tsData[$i] = Configuration::Replace($tsData[$i]); $tsData[$i] = Mailbox::FinalizeEmail($tsData[$i], $i == 1); $tsData[$i] = Server::Replace($tsData[$i]); } //$mailbox = Mailbox::GetDefaultOutgoing(); $mailbox = Mailbox::GetById(Server::$Groups[$this->Group]->TicketEmailOut, true); if ($mailbox != null) { $mb = clone $mailbox; $replytoint = Mailbox::IsValidEmail($_message->Email) ? $_message->Email : $mb->Email; $replytoex = $mb->Email; $fakeSender = ""; if (!empty(Server::$Configuration->File["gl_usmasend"]) && Mailbox::IsValidEmail($_message->Email)) { $fakeSender = $_message->Email; } if (!empty(Server::$Configuration->File["gl_scom"])) { Communication::SendEmail($mb, Server::$Configuration->File["gl_scom"], $replytoint, $tsData[0], $tsData[1], $tsData[2], false, null, $fakeSender); } if (!empty(Server::$Configuration->File["gl_sgom"])) { Communication::SendEmail($mb, Server::$Groups[$this->Group]->Email, $replytoint, $tsData[0], $tsData[1], $tsData[2], false, null, $fakeSender); } if (!empty(Server::$Configuration->File["gl_ssom"]) && Mailbox::IsValidEmail($_message->Email)) { Communication::SendEmail($mb, str_replace(";", ",", $_message->Email), $replytoex, $tsData[0], $tsData[1], $tsData[2], false, null, $fakeSender); } } }
function Generate($_user = null, $_allowBots = false) { foreach (Server::$Operators as $operator) { if ($operator->LastActive > time() - Server::$Configuration->File["timeout_clients"] && $operator->Status < USER_STATUS_OFFLINE && ($_allowBots || !$operator->IsBot) && !$operator->MobileSleep()) { if (!$operator->IsExternal(Server::$Groups)) { continue; } $igroups = $operator->GetGroupList(true); for ($count = 0; $count < count($igroups); $count++) { if ($operator->UserId == $this->ReqOperator) { if (!($this->GroupValues["req_for_group"] && $igroups[$count] != $this->ReqGroup) || isset($_GET[GET_EXTERN_PREFERENCE]) && Encoding::Base64UrlDecode($_GET[GET_EXTERN_PREFERENCE]) == "user") { $this->GroupValues["set_by_get_user"] = $igroups[$count]; } } if (!isset($this->GroupValues["groups_online_amounts"][$igroups[$count]])) { $this->GroupValues["groups_online_amounts"][$igroups[$count]] = 0; } if ($operator->IsBot) { $this->GroupValues["groups_online_amounts"][$igroups[$count]] += 1; } else { if (isset(Server::$Groups[$igroups[$count]])) { if ($operator->GetMaxChatAmountStatus(Server::$Groups[$igroups[$count]]) != USER_STATUS_AWAY) { $this->GroupValues["groups_online_amounts"][$igroups[$count]] += 2; } } } } } } $counter = 0; if (is_array(Server::$Groups)) { foreach (Server::$Groups as $id => $group) { if (!$group->IsExternal) { continue; } $used = false; $amount = isset($this->GroupValues["groups_online_amounts"]) && is_array($this->GroupValues["groups_online_amounts"]) && array_key_exists($id, $this->GroupValues["groups_online_amounts"]) && $group->IsOpeningHour() ? $this->GroupValues["groups_online_amounts"][$id] : 0; $transport = base64_encode($id) . "," . base64_encode($amount) . "," . base64_encode($group->GetDescription($_user != null ? $_user->Language : "")) . "," . base64_encode($group->Email); if ($this->GroupValues["req_for_group"] && $id == $this->ReqGroup) { $this->GroupValues["set_by_get_group"] = $id; $used = true; } elseif (Cookie::Get("login_group") != null && $id == Cookie::Get("login_group") && !isset($requested_group)) { $this->GroupValues["set_by_cookie"] = $id; $used = true; } elseif ($group->IsStandard) { $this->GroupValues["set_by_standard"] = $id; $used = true; } elseif (empty($this->GroupValues["set_by_online"])) { $this->GroupValues["set_by_online"] = $id; $used = true; } if (!in_array($id, $this->GroupValues["groups_hidden"]) && ($group->IsExternal || $used)) { $counter++; if ($amount > 0) { $this->GroupAvailable = true; $this->GroupValues["groups_online"][$id] = $transport; } else { if ($group->IsStandard) { $na[$id] = $transport; $na = array_merge($na, $this->GroupValues["groups_offline"]); $this->GroupValues["groups_offline"] = $na; } else { $this->GroupValues["groups_offline"][$id] = $transport; } } } } } if (isset($_GET[GET_EXTERN_PREFERENCE]) && Encoding::Base64UrlDecode($_GET[GET_EXTERN_PREFERENCE]) == "group") { if (isset($this->GroupValues["groups_online_amounts"][$this->ReqGroup]) && $this->GroupValues["groups_online_amounts"][$this->ReqGroup] > 0) { $this->GroupValues["set_by_get_user"] = null; $this->GroupValues["req_for_user"] = false; } } if (!empty($this->GroupValues["set_by_get_user"]) && isset($this->GroupValues["groups_online"][$this->GroupValues["set_by_get_user"]])) { $this->GroupValues["groups_output"][$this->GroupValues["set_by_get_user"]] = $this->GroupValues["groups_online"][$this->GroupValues["set_by_get_user"]]; } else { if (!empty($this->GroupValues["set_by_get_group"]) && isset($this->GroupValues["groups_online"][$this->GroupValues["set_by_get_group"]])) { $this->GroupValues["groups_output"][$this->GroupValues["set_by_get_group"]] = $this->GroupValues["groups_online"][$this->GroupValues["set_by_get_group"]]; } else { if (!empty($this->GroupValues["set_by_cookie"]) && isset($this->GroupValues["groups_online"][$this->GroupValues["set_by_cookie"]])) { $this->GroupValues["groups_output"][$this->GroupValues["set_by_cookie"]] = $this->GroupValues["groups_online"][$this->GroupValues["set_by_cookie"]]; } else { if (!empty($this->GroupValues["set_by_standard"]) && isset($this->GroupValues["groups_online"][$this->GroupValues["set_by_standard"]])) { $this->GroupValues["groups_output"][$this->GroupValues["set_by_standard"]] = $this->GroupValues["groups_online"][$this->GroupValues["set_by_standard"]]; } else { if (!empty($this->GroupValues["set_by_online"]) && isset($this->GroupValues["groups_online"][$this->GroupValues["set_by_online"]])) { $this->GroupValues["groups_output"][$this->GroupValues["set_by_online"]] = $this->GroupValues["groups_online"][$this->GroupValues["set_by_online"]]; } else { if (!empty($this->GroupValues["set_by_cookie"]) && empty($this->GroupValues["groups_output"]) && !empty($this->GroupValues["groups_offline"][$this->GroupValues["set_by_cookie"]])) { $this->GroupValues["groups_output"][$this->GroupValues["set_by_cookie"]] = $this->GroupValues["groups_offline"][$this->GroupValues["set_by_cookie"]]; } else { if (!empty($this->GroupValues["set_by_get_group"]) && empty($this->GroupValues["groups_output"]) && !empty($this->GroupValues["groups_offline"][$this->GroupValues["set_by_get_group"]])) { $this->GroupValues["groups_output"][$this->GroupValues["set_by_get_group"]] = $this->GroupValues["groups_offline"][$this->GroupValues["set_by_get_group"]]; } } } } } } } foreach ($this->GroupValues["groups_online"] as $id => $transport) { if (!isset($this->GroupValues["groups_output"][$id])) { $this->GroupValues["groups_output"][$id] = $transport; } } if (empty($this->GroupValues["set_by_get_group"]) || empty($this->GroupValues["groups_online_amounts"][$this->GroupValues["set_by_get_group"]])) { $ngroups = array(); foreach ($this->GroupValues["groups_output"] as $id => $group) { $ngroups[$id] = !empty($this->GroupValues["groups_online_amounts"][$id]) ? $this->GroupValues["groups_online_amounts"][$id] : 0; if ($id == $this->GroupValues["set_by_standard"]) { $ngroups[$id] = 10000; } } arsort($ngroups); $nsgroups = array(); foreach ($ngroups as $id => $amount) { $nsgroups[$id] = $this->GroupValues["groups_output"][$id]; } $this->GroupValues["groups_output"] = $nsgroups; } $result = array_merge($this->GroupValues["groups_output"], $this->GroupValues["groups_offline"]); foreach ($result as $key => $value) { $chat_input_fields = "new Array("; $count = 0; foreach (Server::$Groups[$key]->ChatInputsHidden as $index) { if ($count > 0) { $chat_input_fields .= ","; } $chat_input_fields .= "'" . $index . "'"; $count++; } $value .= "," . base64_encode($chat_input_fields . ");"); $chat_input_fields = "new Array("; $count = 0; foreach (Server::$Groups[$key]->ChatInputsMandatory as $index) { if ($count > 0) { $chat_input_fields .= ","; } $chat_input_fields .= "'" . $index . "'"; $count++; } $value .= "," . base64_encode($chat_input_fields . ");"); $ticket_input_fields = "new Array("; $count = 0; foreach (Server::$Groups[$key]->TicketInputsHidden as $index) { if ($count > 0) { $ticket_input_fields .= ","; } $ticket_input_fields .= "'" . $index . "'"; $count++; } $value .= "," . base64_encode($ticket_input_fields . ");"); $ticket_input_fields = "new Array("; $count = 0; foreach (Server::$Groups[$key]->TicketInputsMandatory as $index) { if ($count > 0) { $ticket_input_fields .= ","; } $ticket_input_fields .= "'" . $index . "'"; $count++; } $value .= "," . base64_encode($ticket_input_fields . ");"); $mes = PredefinedMessage::GetByLanguage(Server::$Groups[$key]->PredefinedMessages, $_user != null ? $_user->Language : ""); if ($mes != null) { $value .= "," . base64_encode($mes->ChatInformation); $value .= "," . base64_encode($mes->CallMeBackInformation); $value .= "," . base64_encode($mes->TicketInformation); } else { $value .= "," . base64_encode(""); $value .= "," . base64_encode(""); $value .= "," . base64_encode(""); } $count = 0; $com_tickets_allowed = "new Array("; foreach (Server::$Groups[$key]->ChatVouchersRequired as $cttid) { if ($count > 0) { $com_tickets_allowed .= ","; } $com_tickets_allowed .= "'" . $cttid . "'"; $count++; } $value .= "," . base64_encode($com_tickets_allowed . ");"); if (!empty($this->Result)) { $this->Result .= ";" . $value; } else { $this->Result = $value; } } if ($counter == 0) { $this->ErrorHTML = "lz_chat_data.Language.ClientErrorGroups"; } }
function AddPredefinedMessageSet($_userSystemId, $_groupId, $_langISO, $_standard, $_chatInviteManual, $_chatInviteAuto, $_welcomeMessage, $_webSitePushManual, $_webSitePushAuto, $_chatTranscriptMail, $_ticketMail) { $result = queryDB(true, "SELECT MAX(`id`) AS `pcount` FROM `" . DB_PREFIX . DATABASE_PREDEFINED . "`;"); if ($row = DBManager::FetchArray($result)) { $pdm = new PredefinedMessage($row["pcount"] + 1, $_userSystemId, $_groupId, $_langISO, $_chatInviteManual, $_chatInviteAuto, $_welcomeMessage, $_webSitePushManual, $_webSitePushAuto, '', '', '1', $_standard ? '1' : '0', '1', '1', $_chatTranscriptMail, $_ticketMail, '', '', ''); $pdm->Save(DB_PREFIX); return $pdm; } return false; }
function ShowGroupQueueInformation($_visitor, $_shown) { $pdm = PredefinedMessage::GetByLanguage(Server::$Groups[$this->DesiredChatGroup]->PredefinedMessages, $_visitor != null ? $_visitor->Language : ""); if ($pdm != null && !empty($pdm->QueueMessage) && time() - $this->FirstActive > $pdm->QueueMessageTime && !$_shown) { $message = Server::$Groups[$this->DesiredChatGroup]->TextReplace($pdm->QueueMessage, $_visitor->Language); $message = $_visitor->TextReplace($message); $message = $this->TextReplace($message); $message = Configuration::Replace($message); $this->QueueMessageShown = true; return $message; } return ""; }