/**
     * @param PageBuilder $pageBuilder
     * @return ContactsPanel
     */
    function CNewMessagePanel(&$pagebuilder)
    {
        $this->Type = Post::val('mtype', 'mes');
        $this->To = '';
        $this->_pagebuilder =& $pagebuilder;
        $this->_proc =& $pagebuilder->_proc;
        $this->From = $this->_getFromEmail();
        $this->_pagebuilder->_top->AddOnResize('ResizeElements(\'all\');');
        if ($this->_proc->account->AllowDhtmlEditor) {
            $editorResize = 'HTMLEditor.Resize(width - 1, height - 2);';
            $editorReplace = 'HTMLEditor.Replace();';
        } else {
            $editorResize = '
						plainEditor.style.height = (height - 1) + "px";
						plainEditor.style.width = (width - 2) + "px";
					';
            $editorReplace = '';
        }
        $this->inputs = '';
        $contacts = null;
        if (Post::has('contacts') && is_array(Post::val('contacts'))) {
            $contactsArray = array_keys(Post::val('contacts'));
            $contacts =& $this->_proc->db->LoadContactsById($contactsArray);
        }
        if (Post::has('groupid')) {
            $group =& $this->_proc->db->SelectGroupById(Post::val('groupid', -1));
            $contacts =& $this->_proc->db->SelectAddressGroupContacts(Post::val('groupid', -1));
        }
        if ($contacts) {
            foreach ($contacts->Instance() as $contact) {
                if (!$contact->Email) {
                    continue;
                }
                $this->To .= $contact->Name ? '"' . $contact->Name . '" <' . $contact->Email . '>, ' : $contact->Email . ',';
            }
            $this->To = trim(trim($this->To), ',');
        }
        if (Post::has('mailto')) {
            $this->To = Post::val('mailto', '');
        }
        if (Get::has('to')) {
            $this->To = (string) trim(Get::val('to', ''));
        }
        $message = null;
        $isHtml = $this->_proc->account->AllowDhtmlEditor;
        $this->attacmentsHtml = '';
        $this->_pagebuilder->AddJSText('
			
var bcc, bcc_mode, bcc_mode_switcher;

var plainCont = null;
var plainEditor = null;
var HTMLEditor = null;
var EditAreaUrl = "edit-area.php";
var prevWidth = 0;
var prevHeight = 0;
var rowIndex = 0;

function ResizeElements(mode) 
{
	var width = GetWidth();
	if (width < 684)
		width = 684;
	width = width - 40;
	var height = Math.ceil(width/3);
	
	if (prevWidth != width && prevHeight != height) {
		prevWidth = width;
		prevHeight = height;
		if (plainCont != null) {
			plainCont.style.height = height + "px";
			plainCont.style.width = width + "px";
			' . $editorResize . '
		}
	}
}

function WriteEmails(str, field)
{
	var mailInput;
	if (field == 2) {
		mailInput = document.getElementById("toCC");
	} else if (field == 3) {
		mailInput = document.getElementById("toBCC");
	} else {
		mailInput = document.getElementById("toemail");
	}
	if (mailInput) {
		mailInput.value = (mailInput.value == "") ? str : mailInput.value + ", " + str;
		mailInput.focus();
	}
}

function LoadAttachmentHandler(attachObj)
{
	var attachtable = document.getElementById("attachmentTable");
	if (attachObj)
	{
		var imageLink = GetFileParams(attachObj.FileName);
		var tr = attachtable.insertRow(rowIndex++);
		tr.id = "tr_" + attachObj.TempName;
		var td = tr.insertCell(0);
		td.className = "wm_attachment";
		var innerHtml = \'<img src="./images/icons/\' + imageLink.image + \'" />\';
		innerHtml += \'<input type="hidden" name="attachments[\' + attachObj.TempName + \']" value="\' + attachObj.FileName + \'">\';
		innerHtml += HtmlEncode(attachObj.FileName) + \' (\' + GetFriendlySize(attachObj.Size) + \') <a href="#" id="\' + attachObj.TempName + \'" onclick="return  DeleteAttach(this.id);">' . JS_LANG_Delete . '</a>\';
		td.innerHTML = innerHtml;
	}
}

function ChangeBCCMode()
{
	if (bcc_mode == "hide") {
		bcc_mode = "show";
		bcc.className = "";
		bcc_mode_switcher.innerHTML = Lang.HideBCC;
	} else {
		bcc_mode = "hide";
		bcc.className = "wm_hide";
		bcc_mode_switcher.innerHTML = Lang.ShowBCC;
	}
	' . $editorReplace . '
	return false;
}

function UpdateIdUid(id, uid)
{
	var idf = document.getElementById("m_id");
	var uidf = document.getElementById("m_uid");
	if (idf && uidf) {
		idf.value = id;
		uidf.value = uid;
	}
}

var Rep_m, Err_m;
var hiddensaveiframe;
var pop3Pr = ' . ($pagebuilder->_proc->account->MailProtocol == MAILPROTOCOL_POP3 ? 'true' : 'false') . ';
function DoSaveButton()
{
	if (pop3Pr)
	{ 
		if (!hiddensaveiframe) {
			hiddensaveiframe = CreateChildWithAttrs(document.body, "iframe", [["name", "hiddensaveiframe"], ["class", "wm_hide"]]);
		}
	}
	
	var form = document.getElementById("messageForm");
	form.action = "' . ACTIONFILE . '?action=save&req=message";
	form.target = (pop3Pr) ? "hiddensaveiframe" : "";

	if (submitSaveMessage()) {
		form.submit();
	}
}

function DoSendButton()
{
	var toemail = document.getElementById("toemail");
	var ccemail = document.getElementById("toCC");
	var bccemail = document.getElementById("toBCC");
	var subject = document.getElementById("subject");
	var mailIsCorrect = false;
	
	if ((toemail && toemail.value.length > 3) || (ccemail && ccemail.value.length > 3) || (bccemail && bccemail.value.length > 3)) { 
		mailIsCorrect = true;
	}
	
	if (mailIsCorrect) {
		if (subject && subject.value.length < 1 && !confirm(Lang.ConfirmEmptySubject)) {
			return false;
		}
		
		var form = document.getElementById("messageForm");
		form.action = "' . ACTIONFILE . '?action=send&req=message";
		form.target = "";
		if (submitSaveMessage()) {
			form.submit();
		}
	} else {
		alert(Lang.WarningToBlank);
	}
}

function DeleteAttach(idline)
{
	var trtable = document.getElementById("tr_" + idline);
	if (trtable)
	{
		trtable.className = "wm_hide";
		CleanNode(trtable);
	}
	return false;
}

function ShowPictures()
{
	var showPictureTable = document.getElementById("showpicturestable");

	if (HTMLEditor) {
		var temp = HTMLEditor.GetText().ReplaceStr("wmx_src", "src");
		temp = temp.ReplaceStr("wmx_background", "background");
		HTMLEditor.SetHtml(temp);
		if (showPictureTable) {
			showPictureTable.className = "wm_hide";
		}
		HTMLEditor.Replace();
	}
}

');
        $this->_pagebuilder->AddInitText('

bcc_mode = "hide";
bcc = document.getElementById("bcc");
bcc_mode_switcher = document.getElementById("bcc_mode_switcher");

plainEditor = document.getElementById("editor_area");
plainCont = document.getElementById("editor_cont");

Rep_m = new CReport("Rep_m");
Rep_m.Build();

Err_m = new CError("Err_m", "' . ConvertUtils::ClearJavaScriptString($this->_pagebuilder->SkinName(), '"') . '");
Err_m.Build();
');
        $m_id = -1;
        $m_uid = '';
        if (Post::has('m_id')) {
            $mes_id = Post::val('m_id');
            $mes_uid = Post::val('m_uid');
            $folder_id = Post::val('f_id');
            $folder_name = Post::val('f_name');
            $folder_name = 'defaultname';
            $mes_charset = Post::val('charset', -1);
            $message = new GetMessageBase($this->_proc->account, $mes_id, $mes_uid, $folder_id, $folder_name, $mes_charset);
            $m_id = (int) $mes_id;
            $m_uid = $mes_uid;
        }
        $this->inputs = '<input type="hidden" id="m_id" name="m_id" value="' . ConvertUtils::AttributeQuote($m_id) . '"><input type="hidden" id="m_uid" name="m_uid" value="' . ConvertUtils::AttributeQuote($m_uid) . '">';
        $withSignature = false;
        switch ($this->_proc->account->SignatureOptions) {
            case SIGNATURE_OPTION_AddToAll:
                $withSignature = true;
                break;
            case SIGNATURE_OPTION_AddToNewOnly:
                $withSignature = $this->Type == 'mes';
                break;
            default:
            case SIGNATURE_OPTION_DontAdd:
                $withSignature = false;
                break;
        }
        if ($message) {
            if ($this->Type != 'forward' && $this->Type != 'reply' && $this->Type != 'replytoall') {
                $withSignature = false;
            }
            $this->_pagebuilder->AddInitText('SetPriority(' . $message->msg->GetPriorityStatus() . ');');
            switch ($this->Type) {
                default:
                    $this->To = $message->PrintTo(true);
                    $this->CC = $message->PrintCC(true);
                    $this->BCC = '';
                    $this->Subject = $message->PrintSubject(true);
                    break;
                case 'forward':
                    $this->To = '';
                    $this->CC = '';
                    $this->BCC = '';
                    $this->Subject = JS_LANG_Fwd . ': ' . $message->PrintSubject(true);
                    break;
                case 'reply':
                    $replyto = trim($message->PrintReplyTo(true));
                    $this->To = strlen($replyto) > 0 ? $replyto : $message->PrintFrom(true);
                    $this->CC = '';
                    $this->BCC = '';
                    $this->Subject = JS_LANG_Re . ': ' . $message->PrintSubject(true);
                    break;
                case 'replytoall':
                    $emailCollection =& $message->msg->GetAllRecipients(false, true);
                    $temp = '';
                    if ($emailCollection) {
                        foreach ($emailCollection->Instance() as $value) {
                            $email =& $value;
                            if ($email->Email != $this->_proc->account->Email) {
                                $temp .= $email->Email . ', ';
                            }
                        }
                    }
                    $this->To = trim(trim($temp), ',');
                    $this->CC = '';
                    $this->BCC = '';
                    $this->Subject = JS_LANG_Re . ': ' . $message->PrintSubject(true);
                    break;
            }
            if ($this->_proc->account->AllowDhtmlEditor) {
                switch ($this->Type) {
                    case 'forward':
                    case 'reply':
                    case 'replytoall':
                        if ($message->account->ViewMode == VIEW_MODE_PREVIEW_PANE_NO_IMG || $message->account->ViewMode == VIEW_MODE_WITHOUT_PREVIEW_PANE_NO_IMG) {
                            $isHtml = true;
                            $this->Body = ConvertUtils::HtmlBodyWithoutImages($message->msg->GetRelpyAsHtml(true));
                            if (isset($GLOBALS[GL_WITHIMG]) && $GLOBALS[GL_WITHIMG]) {
                                $GLOBALS[GL_WITHIMG] = false;
                                $this->isSafety = false;
                            }
                        } else {
                            $isHtml = true;
                            $this->Body = ConvertUtils::HtmlBodyWithoutImages($message->msg->GetRelpyAsHtml(true));
                        }
                        break;
                    default:
                        if ($message->account->ViewMode == VIEW_MODE_PREVIEW_PANE_NO_IMG || $message->account->ViewMode == VIEW_MODE_WITHOUT_PREVIEW_PANE_NO_IMG) {
                            if ($message->msg->HasHtmlText()) {
                                $isHtml = true;
                                $this->Body = ConvertUtils::HtmlBodyWithoutImages($message->msg->GetCensoredHtmlWithImageLinks(true));
                                if (isset($GLOBALS[GL_WITHIMG]) && $GLOBALS[GL_WITHIMG]) {
                                    $GLOBALS[GL_WITHIMG] = false;
                                    $this->isSafety = false;
                                }
                            } elseif ($message->msg->HasPlainText()) {
                                $isHtml = false;
                                $this->Body = $message->msg->GetNotCensoredTextBody(true);
                            }
                        } else {
                            if ($message->msg->HasHtmlText()) {
                                $isHtml = true;
                                $this->Body = $message->msg->GetCensoredHtmlWithImageLinks(true);
                            } elseif ($message->msg->HasPlainText()) {
                                $isHtml = false;
                                $this->Body = $message->msg->GetNotCensoredTextBody(true);
                            }
                        }
                        break;
                }
            } else {
                $isHtml = false;
                switch ($this->Type) {
                    case 'forward':
                    case 'reply':
                    case 'replytoall':
                        $this->Body = $message->msg->GetRelpyAsPlain(true);
                        break;
                    default:
                        $this->Body = $message->msg->GetNotCensoredTextBody(true);
                        break;
                }
            }
            if ($message->HasAttachments() && $this->Type != 'reply' && $this->Type != 'replytoall') {
                $attachments =& $message->msg->Attachments;
                if ($attachments != null && $attachments->Count() > 0) {
                    foreach (array_keys($attachments->Instance()) as $key) {
                        $attachment =& $attachments->Get($key);
                        $tempname = $message->msg->IdMsg . '-' . $key . '_' . $attachment->GetTempName();
                        //$filename = ConvertUtils::ConvertEncoding($attachment->GetFilenameFromMime(), $GLOBALS[MailInputCharset], $message->account->GetUserCharset());
                        $filename = ConvertUtils::WMHtmlSpecialChars($attachment->GetFilenameFromMime());
                        $filesize = GetFriendlySize(strlen($attachment->MimePart->GetBinaryBody()));
                        $fs =& new FileSystem(INI_DIR . '/temp', $message->account->Email, $message->account->Id);
                        $attfolder =& new Folder($message->account->Id, -1, Session::val('attachtempdir', md5(session_id())));
                        $fs->SaveAttach($attachment, $attfolder, $tempname);
                        $this->attacmentsHtml .= '
<tr id="tr_' . ConvertUtils::AttributeQuote($tempname) . '"><td class="wm_attachment"><img src="./images/icons/' . GetAttachImg($filename) . '" />
<input type="hidden" name="attachments[' . ConvertUtils::AttributeQuote($tempname) . ']" value="' . ConvertUtils::AttributeQuote($filename) . '"> ' . $filename . '
 (' . $filesize . ') 						
<a href="#" id="' . ConvertUtils::AttributeQuote($tempname) . '" onClick="return  DeleteAttach(this.id);">' . JS_LANG_Delete . '</a></td></tr>';
                    }
                }
            }
        } else {
            $this->_pagebuilder->AddInitText('SetPriority(3);');
        }
        $signature = '';
        if ($withSignature) {
            if ($this->_proc->account->AllowDhtmlEditor) {
                $signature = $this->_proc->account->SignatureType == 0 ? nl2br($this->_proc->account->Signature) : $this->_proc->account->Signature;
                $signature = $isHtml ? $signature : strip_tags(nl2br($signature));
            } else {
                $signature = $this->_proc->account->SignatureType == 0 ? strip_tags($this->_proc->account->Signature) : strip_tags($this->_proc->account->Signature);
            }
        }
        $this->Body = $signature . $this->Body;
        if ($this->_proc->account->AllowDhtmlEditor) {
            $this->_pagebuilder->AddJSFile('class.html-editor.js');
            $setText = $isHtml ? 'HTMLEditor.SetHtml(mess);' : 'HTMLEditor.SetText(mess);';
            $this->_pagebuilder->AddJSText('
		function submitSaveMessage()
		{
			var hiddenkey = document.getElementById("ishtml");
			
			if (HTMLEditor._htmlMode) {
				plainEditor.value = HTMLEditor.GetText();
				hiddenkey.value = "1";
			} else {
				hiddenkey.value = "0";
			}
			if (bcc_mode == "hide")
			{
				document.getElementById("toBCC").value = "";
			}
			return true;
		}
		
		function EditAreaLoadHandler() { HTMLEditor.LoadEditArea();	}
		function CreateLinkHandler(url) { HTMLEditor.CreateLinkFromWindow(url); }
		function DesignModeOnHandler(rer) {
			HTMLEditor.Show();
			var mess = "' . ConvertUtils::ReBuildStringToJavaScript($this->Body, '"') . '";
			if (mess.length == 0) {
				mess = "<br />";
			}
			' . $setText . '
		}
				');
            $this->_pagebuilder->AddInitText('
		HTMLEditor = new CHtmlEditorField(true);
		HTMLEditor.SetPlainEditor(plainEditor, document.getElementById("mode_switcher"));
		HTMLEditor.Show();');
        } else {
            $this->_pagebuilder->AddJSText('
		function submitSaveMessage()
		{
			var hiddenkey = document.getElementById("ishtml");
			hiddenkey.value = "0";
			if (bcc_mode == "hide") {
				document.getElementById("toBCC").value = "";
			}
			return true;
		}
				');
        }
    }
 function GetMessageNode(&$_xmlRes, &$_message, &$_folder, &$_processor, &$_account, &$_settings, $_mode, $_charsetNum, $_isFromSave)
 {
     $_safety = true;
     $_messageNode = new XmlDomNode('message');
     $_msgId = $_message->IdMsg;
     $_msgUid = $_message->Uid;
     $_messageInfo = new CMessageInfo();
     $_messageInfo->SetInfo($_msgId, $_msgUid, $_folder->IdDb, $_folder->FullName);
     $_messageClassType = $_message->TextBodies->ClassType();
     $_messageNode->AppendAttribute('id', $_msgId);
     $_messageNode->AppendAttribute('size', $_message->GetMailSize());
     $_messageNode->AppendAttribute('html', (int) (($_messageClassType & 2) == 2));
     $_messageNode->AppendAttribute('plain', (int) (($_messageClassType & 1) == 1));
     $_messageNode->AppendAttribute('priority', $_message->GetPriorityStatus());
     $_messageNode->AppendAttribute('mode', $_mode);
     $_messageNode->AppendAttribute('charset', $_charsetNum);
     $_messageNode->AppendAttribute('has_charset', (int) $_message->HasCharset);
     $_messageNode->AppendAttribute('downloaded', (int) $_message->Downloaded);
     $_messageNode->AppendAttribute('sensivity', $_message->GetSensitivity());
     $maf =& MessageActionFilters::CreateInstance();
     $mafNoReply = $maf->GetNoReplyEmails();
     $mafNoReplyAll = $maf->GetNoReplyAllEmails();
     $mafNoForward = $maf->GetNoForwardEmails();
     $fromEmail = $_message->GetFrom();
     $fromEmail = $fromEmail->Email;
     $_textCharset = $_message->GetTextCharset();
     $_rtl = 0;
     if (null !== $_textCharset) {
         switch (ConvertUtils::GetCodePageNumber($_textCharset)) {
             case 1255:
             case 1256:
             case 28596:
             case 28598:
                 $_rtl = 1;
                 break;
         }
     }
     $_messageNode->AppendAttribute('rtl', $_rtl);
     $_messageNode->AppendChild(new XmlDomNode('uid', $_msgUid, true));
     $_folderNode = new XmlDomNode('folder', $_folder->FullName, true);
     $_folderNode->AppendAttribute('id', $_folder->IdDb);
     $_messageNode->AppendChild($_folderNode);
     $_signature_html = '';
     $_signature_plain = '';
     if ($_account->SignatureOptions == SIGNATURE_OPTION_AddToAll) {
         if ($_account->SignatureType == 1) {
             $_signature_html = '<br />' . $_account->Signature;
             require_once WM_ROOTPATH . 'libs/class_converthtml.php';
             $_pars = new convertHtml($_account->Signature, false);
             $_signature_plain = CRLF . $_pars->get_text();
         } else {
             $_signature_plain = CRLF . $_account->Signature;
             $_signature_html = '<br />' . nl2br($_account->Signature);
         }
         $_signature_plain = ConvertUtils::WMHtmlSpecialChars($_signature_plain);
     }
     $_accountOffset = $_settings->AllowUsersChangeTimeZone ? $_account->GetDefaultTimeOffset() : $_account->GetDefaultTimeOffset($_settings->DefaultTimeZone);
     if (($_mode & 1) == 1) {
         $_headersNode = new XmlDomNode('headers');
         $_fromNode = new XmlDomNode('from');
         $_id_addr = -1;
         $_from4search =& $_message->GetFrom();
         if ($_from4search && USE_DB) {
             $_id_addr = $_processor->DbStorage->GetContactIdByEmail($_from4search->Email, $_account->IdUser);
         }
         if ($_id_addr > 0) {
             $_fromNode->AppendAttribute('contact_id', $_id_addr);
             $_bigContactNode = CXmlProcessing::GetContactNodeFromAddressBookRecord($_account, $_settings, $_id_addr);
             if (null != $_bigContactNode) {
                 $_xmlRes->XmlRoot->AppendChild($_bigContactNode);
             }
         }
         $_fromNode->AppendChild(new XmlDomNode('short', WebMailMessage::ClearForSend(trim($_from4search->DisplayName)), true));
         $_fromNode->AppendChild(new XmlDomNode('full', $_from4search->ToDecodedString(), true));
         $_headersNode->AppendChild($_fromNode);
         $_headersNode->AppendChild(new XmlDomNode('to', $_message->GetToAsString(true), true));
         $_headersNode->AppendChild(new XmlDomNode('cc', $_message->GetCcAsString(true), true));
         $_headersNode->AppendChild(new XmlDomNode('bcc', $_message->GetBccAsString(true), true));
         $_headersNode->AppendChild(new XmlDomNode('reply_to', $_message->GetReplyToAsString(true), true));
         $_headersNode->AppendChild(new XmlDomNode('subject', $_message->GetSubject(true), true));
         $_mailConfirmation = $_message->GetReadMailConfirmationAsString();
         if (strlen($_mailConfirmation) > 0) {
             $_headersNode->AppendChild(new XmlDomNode('mailconfirmation', $_mailConfirmation, true));
         }
         $_date =& $_message->GetDate();
         $_date->FormatString = $_account->DefaultDateFormat;
         $_date->TimeFormat = $_account->DefaultTimeFormat;
         $_headersNode->AppendChild(new XmlDomNode('short_date', $_date->GetFormattedShortDate($_accountOffset), true));
         $_headersNode->AppendChild(new XmlDomNode('full_date', $_date->GetFormattedFullDate($_accountOffset), true));
         $_headersNode->AppendChild(new XmlDomNode('time', $_date->GetFormattedTime($_accountOffset), true));
         $_messageNode->AppendChild($_headersNode);
     }
     $html_part = '';
     if (($_mode & 2) == 2 && ($_messageClassType & 2) == 2) {
         $html_part = ConvertUtils::ReplaceJSMethod($_message->GetCensoredHtmlWithImageLinks(true, $_messageInfo));
         if (($_account->ViewMode == VIEW_MODE_PREVIEW_PANE_NO_IMG || $_account->ViewMode == VIEW_MODE_WITHOUT_PREVIEW_PANE_NO_IMG) && !$_isFromSave) {
             $html_part = ConvertUtils::HtmlBodyWithoutImages($html_part);
             if (isset($GLOBALS[GL_WITHIMG]) && $GLOBALS[GL_WITHIMG]) {
                 $GLOBALS[GL_WITHIMG] = false;
                 $_safety = false;
             }
         }
     }
     $modified_plain_text = '';
     if (($_mode & 4) == 4 || ($_mode & 2) == 2 && ($_messageClassType & 2) != 2) {
         $modified_plain_text = $_message->GetCensoredTextBody(true);
     }
     if (($_mode & 8) == 8) {
         if (($_account->ViewMode == VIEW_MODE_PREVIEW_PANE_NO_IMG || $_account->ViewMode == VIEW_MODE_WITHOUT_PREVIEW_PANE_NO_IMG) && !$_isFromSave) {
             $_messageNode->AppendChild(new XmlDomNode('reply_html', ConvertUtils::AddToLinkMailToCheck(ConvertUtils::HtmlBodyWithoutImages(ConvertUtils::ReplaceJSMethod($_signature_html . $_message->GetRelpyAsHtml(true, $_accountOffset, $_messageInfo)))), true, true));
             if (isset($GLOBALS[GL_WITHIMG]) && $GLOBALS[GL_WITHIMG]) {
                 $GLOBALS[GL_WITHIMG] = false;
                 $_safety = false;
             }
         } else {
             $_messageNode->AppendChild(new XmlDomNode('reply_html', ConvertUtils::AddToLinkMailToCheck(ConvertUtils::ReplaceJSMethod($_signature_html . $_message->GetRelpyAsHtml(true, $_accountOffset, $_messageInfo))), true, true));
         }
     }
     if (($_mode & 16) == 16) {
         $_messageNode->AppendChild(new XmlDomNode('reply_plain', ConvertUtils::AddToLinkMailToCheck($_signature_plain . $_message->GetRelpyAsPlain(true, $_accountOffset)), true, true));
     }
     if (($_mode & 32) == 32) {
         if (($_account->ViewMode == VIEW_MODE_PREVIEW_PANE_NO_IMG || $_account->ViewMode == VIEW_MODE_WITHOUT_PREVIEW_PANE_NO_IMG) && !$_isFromSave) {
             $_messageNode->AppendChild(new XmlDomNode('forward_html', ConvertUtils::AddToLinkMailToCheck(ConvertUtils::HtmlBodyWithoutImages(ConvertUtils::ReplaceJSMethod($_signature_html . $_message->GetRelpyAsHtml(true, $_accountOffset, $_messageInfo)))), true, true));
             if (isset($GLOBALS[GL_WITHIMG]) && $GLOBALS[GL_WITHIMG]) {
                 $GLOBALS[GL_WITHIMG] = false;
                 $_safety = false;
             }
         } else {
             $_messageNode->AppendChild(new XmlDomNode('forward_html', ConvertUtils::AddToLinkMailToCheck(ConvertUtils::ReplaceJSMethod($_signature_html . $_message->GetRelpyAsHtml(true, $_accountOffset, $_messageInfo))), true, true));
         }
     }
     if (($_mode & 64) == 64) {
         $_messageNode->AppendChild(new XmlDomNode('forward_plain', ConvertUtils::AddToLinkMailToCheck($_signature_plain . $_message->GetRelpyAsPlain(true, $_accountOffset)), true, true));
     }
     if (($_mode & 128) == 128) {
         $_messageNode->AppendChild(new XmlDomNode('full_headers', $_message->ClearForSend(ConvertUtils::ConvertEncoding($_message->OriginalHeaders, $GLOBALS[MailInputCharset], $_account->GetUserCharset())), true, true));
     }
     $_messageNode->AppendAttribute('safety', (int) $_safety);
     $_msqAttachLine = 'msg_id=' . $_msgId . '&msg_uid=' . urlencode($_msgUid) . '&folder_id=' . $_folder->IdDb . '&folder_fname=' . urlencode($_folder->FullName);
     $addAttachArray = array();
     if (($_mode & 256) == 256 || ($_mode & 8) == 8 || ($_mode & 16) == 16 || ($_mode & 32) == 32 || ($_mode & 64) == 64) {
         $_attachments =& $_message->Attachments;
         if ($_attachments && $_attachments->Count() > 0) {
             $tempFiles =& CTempFiles::CreateInstance($_account);
             $_attachmentsNode = new XmlDomNode('attachments');
             $_attachmentsKeys = array_keys($_attachments->Instance());
             foreach ($_attachmentsKeys as $_key) {
                 $attachArray = array();
                 $_attachment =& $_attachments->Get($_key);
                 $_tempname = $_message->IdMsg . '-' . $_key . '_' . ConvertUtils::ClearFileName($_attachment->GetTempName());
                 $_filename = ConvertUtils::ClearFileName(ConvertUtils::ClearUtf8($_attachment->GetFilenameFromMime(), $GLOBALS[MailInputCharset], $_account->GetUserCharset()));
                 $_size = 0;
                 $_isBodyStructureAttachment = false;
                 if ($_attachment->MimePart && $_attachment->MimePart->BodyStructureIndex !== null && $_attachment->MimePart->BodyStructureSize !== null) {
                     $_isBodyStructureAttachment = true;
                     $_size = $_attachment->MimePart->BodyStructureSize;
                 } else {
                     $_size = $tempFiles->SaveFile($_tempname, $_attachment->GetBinaryBody());
                     $_size = $_size < 0 ? 0 : $_size;
                 }
                 $attachArray['name'] = $_filename;
                 $attachArray['tempname'] = $_tempname;
                 $attachArray['size'] = $_size;
                 $_bodyStructureUrlAdd = '';
                 if ($_isBodyStructureAttachment) {
                     $_bodyStructureUrlAdd = 'bsi=' . urlencode($_attachment->MimePart->BodyStructureIndex);
                     if ($_attachment->MimePart->BodyStructureEncode !== null && strlen($_attachment->MimePart->BodyStructureEncode) > 0) {
                         $_bodyStructureUrlAdd .= '&bse=' . urlencode(ConvertUtils::GetBodyStructureEncodeType($_attachment->MimePart->BodyStructureEncode));
                     }
                 }
                 $_attachNode = new XmlDomNode('attachment');
                 $_attachNode->AppendAttribute('size', $_size);
                 $_attachNode->AppendAttribute('inline', $_attachment->IsInline ? '1' : '0');
                 $_attachNode->AppendChild(new XmlDomNode('filename', $_filename, true));
                 $viewUrl = substr(strtolower($_filename), -4) == '.eml' ? 'message-view.php?type=' . MESSAGE_VIEW_TYPE_ATTACH . '&tn=' . urlencode($_tempname) : 'view-image.php?img&tn=' . urlencode($_tempname) . '&filename=' . urlencode($_filename);
                 if ($_isBodyStructureAttachment) {
                     $viewUrl .= '&' . $_bodyStructureUrlAdd . '&' . $_msqAttachLine;
                 }
                 $_attachNode->AppendChild(new XmlDomNode('view', $viewUrl, true));
                 $linkUrl = 'attach.php?tn=' . urlencode($_tempname);
                 if ($_isBodyStructureAttachment) {
                     $linkUrl .= '&' . $_bodyStructureUrlAdd . '&' . $_msqAttachLine;
                 }
                 $downloadUrl = $linkUrl . '&filename=' . urlencode($_filename);
                 $attachArray['download'] = $downloadUrl;
                 $attachArray['link'] = $linkUrl;
                 $_attachNode->AppendChild(new XmlDomNode('download', $downloadUrl, true));
                 $_attachNode->AppendChild(new XmlDomNode('tempname', $_tempname, true));
                 $mime_type = ConvertUtils::GetContentTypeFromFileName($_filename);
                 $_attachNode->AppendChild(new XmlDomNode('mime_type', $mime_type, true));
                 $attachArray['mime_type'] = $mime_type;
                 $attachArray['download'] = $downloadUrl;
                 $addAttachArray[] = $attachArray;
                 $_attachmentsNode->AppendChild($_attachNode);
                 unset($_attachment, $_attachNode, $attachArray);
             }
             $_messageNode->AppendChild($_attachmentsNode);
         }
     }
     ChangeHtmlTextFromAttachment($html_part, $modified_plain_text, $addAttachArray);
     if (($_mode & 2) == 2 && ($_messageClassType & 2) == 2) {
         $_messageNode->AppendChild(new XmlDomNode('html_part', ConvertUtils::AddToLinkMailToCheck($html_part), true, true));
     }
     if (($_mode & 4) == 4 || ($_mode & 2) == 2 && ($_messageClassType & 2) != 2) {
         $_messageNode->AppendChild(new XmlDomNode('modified_plain_text', ConvertUtils::AddToLinkMailToCheck($modified_plain_text), true, true));
     }
     if (($_mode & 512) == 512) {
         $_messageNode->AppendChild(new XmlDomNode('unmodified_plain_text', $_message->GetNotCensoredTextBody(true), true, true));
     }
     $_messageNode->AppendChild(new XmlDomNode('save_link', 'attach.php?' . $_msqAttachLine, true));
     $_messageNode->AppendChild(new XmlDomNode('print_link', 'message-view.php?type=' . MESSAGE_VIEW_TYPE_PRINT . '&' . $_msqAttachLine . '&charset=' . $_charsetNum, true));
     $_messageNode->AppendAttribute('no_reply', count($mafNoReply) > 0 && in_array($fromEmail, $mafNoReply) ? '1' : '0');
     $_messageNode->AppendAttribute('no_reply_all', count($mafNoReplyAll) > 0 && in_array($fromEmail, $mafNoReplyAll) ? '1' : '0');
     $_messageNode->AppendAttribute('no_forward', count($mafNoForward) > 0 && in_array($fromEmail, $mafNoForward) ? '1' : '0');
     $_xmlRes->XmlRoot->AppendChild($_messageNode);
 }
 /**
  * @param bool $isEncode
  * @return string
  */
 function PrintHtmlBody($isEncode = true, $isFromSave = false)
 {
     if (($this->account->ViewMode == VIEW_MODE_PREVIEW_PANE_NO_IMG || $this->account->ViewMode == VIEW_MODE_WITHOUT_PREVIEW_PANE_NO_IMG) && !$isFromSave) {
         $newtext = ConvertUtils::HtmlBodyWithoutImages($this->msg->GetCensoredHtmlWithImageLinks($isEncode));
         if (isset($GLOBALS[GL_WITHIMG]) && $GLOBALS[GL_WITHIMG]) {
             $GLOBALS[GL_WITHIMG] = false;
             $this->isSafety = false;
         }
     } else {
         $newtext = $this->msg->GetCensoredHtmlWithImageLinks($isEncode);
     }
     return $newtext;
 }
Exemple #4
0
     if (($account->ViewMode == VIEW_MODE_PREVIEW_PANE_NO_IMG || $account->ViewMode == VIEW_MODE_WITHOUT_PREVIEW_PANE_NO_IMG) && !$isFromSave) {
         $messageNode->AppendChild(new XmlDomNode('reply_html', ConvertUtils::HtmlBodyWithoutImages(ConvertUtils::ReplaceJSMethod($signature_html . $message->GetRelpyAsHtml(true))), true, true));
         if (isset($GLOBALS[GL_WITHIMG]) && $GLOBALS[GL_WITHIMG]) {
             $GLOBALS[GL_WITHIMG] = false;
             $safety = false;
         }
     } else {
         $messageNode->AppendChild(new XmlDomNode('reply_html', ConvertUtils::ReplaceJSMethod($signature_html . $message->GetRelpyAsHtml(true)), true, true));
     }
 }
 if (($mode & 16) == 16) {
     $messageNode->AppendChild(new XmlDomNode('reply_plain', $signature_plain . $message->GetRelpyAsPlain(true), true, true));
 }
 if (($mode & 32) == 32) {
     if (($account->ViewMode == VIEW_MODE_PREVIEW_PANE_NO_IMG || $account->ViewMode == VIEW_MODE_WITHOUT_PREVIEW_PANE_NO_IMG) && !$isFromSave) {
         $messageNode->AppendChild(new XmlDomNode('forward_html', ConvertUtils::HtmlBodyWithoutImages(ConvertUtils::ReplaceJSMethod($signature_html . $message->GetRelpyAsHtml(true))), true, true));
         if (isset($GLOBALS[GL_WITHIMG]) && $GLOBALS[GL_WITHIMG]) {
             $GLOBALS[GL_WITHIMG] = false;
             $safety = false;
         }
     } else {
         $messageNode->AppendChild(new XmlDomNode('forward_html', ConvertUtils::ReplaceJSMethod($signature_html . $message->GetRelpyAsHtml(true)), true, true));
     }
 }
 if (($mode & 64) == 64) {
     $messageNode->AppendChild(new XmlDomNode('forward_plain', $signature_plain . $message->GetRelpyAsPlain(true), true, true));
 }
 if (($mode & 128) == 128) {
     $messageNode->AppendChild(new XmlDomNode('full_headers', $message->ClearForSend(ConvertUtils::ConvertEncoding($message->OriginalHeaders, $GLOBALS[MailInputCharset], $account->GetUserCharset())), true, true));
 }
 $messageNode->AppendAttribute('safety', (int) $safety);
Exemple #5
0
        if ($account->SignatureOptions == SIGNATURE_OPTION_AddToAll) {
            if ($account->SignatureType == 1) {
                $_signature_html = '<br />' . $account->Signature;
                require_once WM_ROOTPATH . 'libs/class_converthtml.php';
                $_pars = new convertHtml($account->Signature, false);
                $_signature_plain = CRLF . $_pars->get_text();
            } else {
                $_signature_plain = CRLF . $account->Signature;
                $_signature_html = '<br />' . nl2br($account->Signature);
            }
            $_signature_plain = ConvertUtils::WMHtmlSpecialChars($_signature_plain);
        }
        $replyAsHtml = $message->GetRelpyAsHtml(true, $accountOffset, $_messageInfo);
        if (($account->ViewMode == VIEW_MODE_PREVIEW_PANE_NO_IMG || $account->ViewMode == VIEW_MODE_WITHOUT_PREVIEW_PANE_NO_IMG) && !$_isFromSave) {
            echo '
	ViewMessage.ReplyHtml = \'' . ConvertUtils::ReBuildStringToJavaScript(ConvertUtils::AddToLinkMailToCheck(ConvertUtils::HtmlBodyWithoutImages(ConvertUtils::ReplaceJSMethod($_signature_html . $replyAsHtml))), '\'') . '\';';
        } else {
            echo '
	ViewMessage.ReplyHtml = \'' . ConvertUtils::ReBuildStringToJavaScript(ConvertUtils::AddToLinkMailToCheck(ConvertUtils::ReplaceJSMethod($_signature_html . $replyAsHtml)), '\'') . '\';';
        }
        echo '
	ViewMessage.ReplyPlain = \'' . ConvertUtils::ReBuildStringToJavaScript(ConvertUtils::AddToLinkMailToCheck($_signature_plain . $message->GetRelpyAsPlain(true, $accountOffset)), '\'') . '\';';
        echo '
	ViewMessage.IsReplyHtml = true;
	ViewMessage.IsReplyPlain = true;
	ViewMessage.IsForwardHtml = true;
	ViewMessage.IsForwardPlain = true;
	ViewMessage.ForwardHtml = ViewMessage.ReplyHtml;
	ViewMessage.ForwardPlain = ViewMessage.ReplyPlain;';
    }
    ?>