function buildMessages($xml = "")
{
    global $RESPONSE, $INTERNAL, $GROUPS;
    $permission = $INTERNAL[CALLER_SYSTEM_ID]->GetPermission(PERMISSION_MESSAGES);
    if ($_POST[POST_INTERN_XMLCLIP_MESSAGES_END_TIME] == XML_CLIP_NULL) {
        $_POST[POST_INTERN_XMLCLIP_MESSAGES_END_TIME] = 0;
    }
    $result = queryDB(true, "SELECT * FROM `" . DB_PREFIX . DATABASE_TICKETS . "` INNER JOIN `" . DB_PREFIX . DATABASE_TICKET_MESSAGES . "` ON `" . DB_PREFIX . DATABASE_TICKETS . "`.`id`=`" . DB_PREFIX . DATABASE_TICKET_MESSAGES . "`.`ticket_id` WHERE time >" . mysql_real_escape_string($_POST[POST_INTERN_XMLCLIP_MESSAGES_END_TIME]) . " ORDER BY `time` ASC LIMIT " . mysql_real_escape_string(DATA_ITEM_LOADS) . ";");
    if ($result) {
        while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
            $ticket = new UserTicket($row);
            $xml .= $ticket->GetXML($GROUPS, in_array($ticket->Group, $INTERNAL[CALLER_SYSTEM_ID]->Groups) && $permission != PERMISSION_NONE || $permission == PERMISSION_FULL);
        }
    }
    $result = queryDB(true, "SELECT * FROM `" . DB_PREFIX . DATABASE_TICKET_EDITORS . "` WHERE time >" . mysql_real_escape_string($_POST[POST_INTERN_XMLCLIP_MESSAGES_END_TIME]) . " ORDER BY `time` ASC LIMIT " . mysql_real_escape_string(DATA_ITEM_LOADS) . ";");
    if ($result) {
        while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
            $ticket = new ClosedTicket($row["ticket_id"], $row);
            $xml .= $ticket->GetXML($row["time"], $row["status"]);
        }
    }
    $RESPONSE->Messages = $xml;
}
 function SaveTicket($_group, $_config)
 {
     $ticket = new UserTicket(getTicketId(), true);
     $ticket->IP = getIP();
     setCookieValue("form_111", AJAXDecode($_POST[POST_EXTERN_USER_NAME]));
     setCookieValue("form_112", AJAXDecode($_POST[POST_EXTERN_USER_EMAIL]));
     setCookieValue("form_113", AJAXDecode($_POST[POST_EXTERN_USER_COMPANY]));
     if (!isTicketFlood()) {
         $ticket->Fullname = AJAXDecode($_POST[POST_EXTERN_USER_NAME]);
         $ticket->UserId = AJAXDecode($_POST[POST_EXTERN_USER_USERID]);
         $ticket->Email = AJAXDecode($_POST[POST_EXTERN_USER_EMAIL]);
         $ticket->Group = $_group;
         $ticket->Company = AJAXDecode($_POST[POST_EXTERN_USER_COMPANY]);
         $ticket->Text = AJAXDecode($_POST[POST_EXTERN_USER_MAIL]);
         for ($i = 0; $i < 10; $i++) {
             if (isset($_POST["p_cf" . $i]) && isset($_config["gl_ci_list"][$i]) && !isset($_group->TicketInputsHidden[$i])) {
                 $ticket->Customs[$i] = base64UrlDecode($_POST["p_cf" . $i]);
             }
         }
         if (!(!empty($_config["gl_rm_om"]) && $_config["gl_rm_om_time"] == 0)) {
             $ticket->Save();
         }
         $this->AddFunctionCall("lz_chat_mail_callback(true);", false);
         return true;
     } else {
         $this->AddFunctionCall("lz_chat_mail_callback(false);", false);
     }
     return false;
 }
 public function __construct($vals = null)
 {
     if (!isset(self::$_TSPEC)) {
         self::$_TSPEC = array(1 => array('var' => 'islogin', 'type' => TType::BOOL), 2 => array('var' => 'ticket', 'type' => TType::STRING));
     }
     if (is_array($vals)) {
         if (isset($vals['islogin'])) {
             $this->islogin = $vals['islogin'];
         }
         if (isset($vals['ticket'])) {
             $this->ticket = $vals['ticket'];
         }
     }
 }