/**
     * @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;
		}
				');
        }
    }
Example #2
0
			</td>
		</tr>
		<tr>
			<td id="td_attachments">
		<?php 
            $JSfilenameTrim = '';
            if ($message->msg->Attachments != null && $message->msg->Attachments->Count() > 0) {
                echo '<div id="attachments" class="wm_message_attachments">';
                $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 = $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['attachtempdir']);
                        $fs->SaveAttach($attachment, $attfolder, $tempname);
                        $ContentType = ConvertUtils::GetContentTypeFromFileName($filename);
                        $JSfilenameTrim .= '
					att = document.getElementById("at_' . $key . '");
					if (att.innerHTML.length > 16) 
							att.innerHTML = att.innerHTML.substring(0, 15) + \'&#8230;\';
					';
                        echo '
					<div style="float: left;"><a href="attach.php?tn=' . $tempname . '&filename=' . urlencode($filename) . '">
							<img src="./images/icons/' . GetAttachImg($filename) . '" title="Click to download ' . $filename . ' (' . $filesize . ')" /></a><br />
							<span id="at_' . $key . '" title="Click to download ' . $filename . ' (' . $filesize . ')">' . $filename . '</span><br />';
                        if (strpos($ContentType, 'image') !== false) {
                            echo '<a href="#" onclick="PrevImg(\'view_image.php?tn=' . $tempname . '\')">View</a>';
    /**
     * @return string
     */
    function MessageListTr()
    {
        $out = '';
        if (!$this->messageCollection) {
            return '';
        }
        $c = $this->messageCollection->Count();
        $stylewidth = array(array('', ' style="width: 21px; text-align: center;"'), array('', ' style="width: 20px;"'), array('', ' style="width: 20px;"'), array('', ' style="width: 150px;"'), array('', ' style="width: 140px;"'), array('', ' style="width: 48px;"'), array('', ' style="width: 148px;"'));
        $atemp_1 = $atemp_2 = '';
        if ($this->_proc->account->ViewMode == VIEW_MODE_WITHOUT_PREVIEW_PANE || $this->_proc->account->ViewMode == VIEW_MODE_WITHOUT_PREVIEW_PANE_NO_IMG) {
            $atemp_1 = '<a href="#">';
            $atemp_2 = '</a>';
        }
        for ($i = 0; $i < $c; $i++) {
            $msg =& $this->messageCollection->Get($i);
            if (!$msg) {
                continue;
            }
            $isRead = ($msg->Flags & MESSAGEFLAGS_Seen) == MESSAGEFLAGS_Seen ? 'true' : 'false';
            $flaggedImg = '';
            $handclass = $this->_proc->account->MailProtocol != MAILPROTOCOL_IMAP4 && $this->_proc->currentFolder && $this->_proc->currentFolder->SyncType == FOLDERSYNC_DirectMode ? '' : 'wm_control';
            if (($msg->Flags & MESSAGEFLAGS_Flagged) == MESSAGEFLAGS_Flagged) {
                $isFlagged = 'true';
                $flaggedImg = '<img class="' . $handclass . '" src="skins/' . $this->_pagebuilder->SkinName() . '/menu/flag.gif" />';
            } else {
                $isFlagged = 'false';
                $flaggedImg = '<img class="' . $handclass . '" src="skins/' . $this->_pagebuilder->SkinName() . '/menu/unflag.gif" />';
            }
            if ($msg->IdFolder == -1 && $this->folder && $this->folder->SyncType == FOLDERSYNC_DirectMode) {
                $msg->IdFolder = $this->folder->IdDb;
            }
            $isForwarded = ($msg->Flags & MESSAGEFLAGS_Forwarded) == MESSAGEFLAGS_Forwarded ? 'true' : 'false';
            $isDeleted = ($msg->Flags & MESSAGEFLAGS_Deleted) == MESSAGEFLAGS_Deleted ? 'true' : 'false';
            $isGrey = ($msg->Flags & MESSAGEFLAGS_Grayed) == MESSAGEFLAGS_Grayed ? 'true' : 'false';
            $isReplied = 'false';
            $date =& $msg->GetDate();
            $date->FormatString = $this->_proc->account->DefaultDateFormat;
            $date->TimeFormat = $this->_proc->account->DefaultTimeFormat;
            $sep = '-----';
            $char = $msg->Charset > -1 ? ConvertUtils::GetCodePageName($msg->Charset) : -1;
            $idString = $msg->IdMsg . $sep . $msg->Uid . $sep . $msg->IdFolder . $sep . $char . $sep;
            $folderName = $this->folder ? $this->folder->FullName : '';
            $this->_pagebuilder->AddInitText('messObj = {Read: ' . $isRead . ', Replied: ' . $isReplied . ', Forwarded: ' . $isForwarded . ', Flagged: ' . $isFlagged . ', Deleted: ' . $isDeleted . ', Gray: ' . $isGrey . ', Id: ' . (int) $msg->IdMsg . ', Uid: "' . ConvertUtils::ClearJavaScriptString($msg->Uid, '"') . '", FolderId: ' . $msg->IdFolder . ', FolderFullName: "' . ConvertUtils::ClearJavaScriptString($folderName, '"') . '", FromAddr: "", Subject: ""}');
            $this->_pagebuilder->AddInitText('InboxLines.AddLine(new CSelectionPart(document.getElementById("' . ConvertUtils::ClearJavaScriptString($idString, '"') . '"), "' . $this->_pagebuilder->SkinName() . '" , messObj));');
            $from = ConvertUtils::WMHtmlSpecialChars($msg->GetFromAsStringForSend());
            $to = ConvertUtils::WMHtmlSpecialChars($msg->GetAllRecipientsEmailsAsString(true));
            $subject = ConvertUtils::WMHtmlSpecialChars($msg->GetSubject(true));
            if (isset($this->_proc->sArray[SEARCH_ARRAY][S_TEXT]) && strlen($this->_proc->sArray[SEARCH_ARRAY][S_TEXT]) > 0) {
                $from = preg_replace('/' . preg_quote($this->_proc->sArray[SEARCH_ARRAY][S_TEXT]) . '/i', '<font>$0</font>', $from);
                $to = preg_replace('/' . preg_quote($this->_proc->sArray[SEARCH_ARRAY][S_TEXT]) . '/i', '<font>$0</font>', $to);
                $subject = preg_replace('/' . preg_quote($this->_proc->sArray[SEARCH_ARRAY][S_TEXT]) . '/i', '<font>$0</font>', $subject);
            }
            $subjectId = $i == 0 ? 'id="subject"' : '';
            $out .= '
			<tr onclick="CheckThisLine(event, this);" ondblclick="CheckThisLineDb(event, this);" id="' . ConvertUtils::AttributeQuote($idString) . '">
			<td' . $stylewidth[0][(int) ($i == 0)] . ' id="none"><input type="checkbox" /></td>
			<td' . $stylewidth[1][(int) ($i == 0)] . '>';
            $out .= (int) $msg->HasAttachments() == 1 ? '<img src="skins/' . $this->_pagebuilder->SkinName() . '/menu/attachment.gif" />' : '';
            $out .= '</td><td' . $stylewidth[2][(int) ($i == 0)] . '>' . $flaggedImg;
            $tempFromTo = $this->folder && $this->folder->ToFolder ? $to : $from;
            $out .= '</td><td' . $stylewidth[3][(int) ($i == 0)] . ' class="wm_inbox_from_subject"><nobr>' . $atemp_1 . $tempFromTo . $atemp_2 . '</nobr></td>
			<td' . $stylewidth[4][(int) ($i == 0)] . '><nobr>' . $date->GetFormattedDate($this->_proc->account->GetDefaultTimeOffset()) . '</nobr></td><td' . $stylewidth[5][(int) ($i == 0)] . '><nobr>' . GetFriendlySize($msg->Size) . '</nobr></td>
			<td' . $stylewidth[6][(int) ($i == 0)] . ' class="wm_inbox_from_subject" ' . $subjectId . '><nobr>' . $atemp_1 . $subject . $atemp_2 . '</nobr></td>
			</tr>';
        }
        if (isset($this->_proc->sArray[SEARCH_ARRAY]) && isset($this->_proc->sArray[SEARCH_ARRAY][S_TEXT]) && strlen($this->_proc->sArray[SEARCH_ARRAY][S_TEXT]) > 0 && $c == 0) {
            $out = '<tr><td colspan="6" style="width: 404px;"></td>';
            $out .= '<td style="width: 150px;" id="subject"></td></tr>
				<tr><td colspan="7"><div class="wm_inbox_info_message">' . InfoNoMessagesFound . '</div></td></tr>
				';
        } else {
            if ($c == 0) {
                $out = '<tr><td colspan="6" style="width: 404px;"></td>';
                $out .= '<td style="width: 150px;" id="subject"></td></tr>
				<tr><td colspan="7"><div class="wm_inbox_info_message">' . JS_LANG_InfoEmptyFolder . '</div></td></tr>
				';
            }
        }
        return $out;
    }
<b>Enable logging</b> - enables detailed logging helpful for troubleshooting.
</div><br />
	</td></tr>
	<tr>
		<td></td>
		<td>&nbsp;Path for log&nbsp;&nbsp;<input type="text" name="txtPathForLog" onchange="change();" value="<?php 
echo ConvertUtils::AttributeQuote(INI_DIR . '/' . LOG_PATH . '/' . LOG_FILENAME);
?>
" class="wm_input" readonly="readonly" style="width: 330px">
		<br /><br />
<div class="wm_safety_info">
<b>Path for log</b> - path to the log file (cannot be changed).<br />The buttons below allow viewing and clearing the log file.
</div>
		<br />
			<input type="button" onclick="PopUpWindow('?mode=showlog&t=0');" value="View entire log (<?php 
echo file_exists(INI_DIR . '/' . LOG_PATH . '/' . LOG_FILENAME) ? GetFriendlySize(filesize(INI_DIR . '/' . LOG_PATH . '/' . LOG_FILENAME)) : '0KB';
?>
)" class="wm_button" style="font-size: 11px; width: 150px" />
			<input type="button" onclick="PopUpWindow('?mode=showlog&t=1');" value="View last 50KB of log" class="wm_button" style="font-size: 11px; width: 150px" />
			<input type="button" onclick="document.location.replace('?mode=clearlog');" value=" Clear log " class="wm_button" style="font-size: 11px;" />
		</td>
	</tr>
	<tr>
		<td colspan="3" align="center">
			<br /><div id="messDiv" class="messdiv" <?php 
echo strlen($divMessage) > 0 ? 'style="border: 1px solid Silver;"' : '';
?>
>
			<?php 
echo strlen($divMessage) > 0 ? $divMessage : '&nbsp;';
?>
    /**
     * @param FolderCollection $folders
     * @param int $messagesCount
     * @param int $messagesSize
     * @param Account $account
     * @return string
     */
    function CreateHtmlFolderTree(&$folders, &$messagesCount, &$messagesSize, &$account)
    {
        $out = array('', '');
        for ($i = 0, $count = $folders->Count(); $i < $count; $i++) {
            $folder =& $folders->Get($i);
            if ($i > 0) {
                $pr_folder =& $folders->Get($i - 1);
            }
            if ($i < $count - 1) {
                $nx_folder =& $folders->Get($i + 1);
            }
            $messagesCount += $folder->MessageCount;
            $messagesSize += $folder->Size;
            $foldername = '';
            if (ConvertUtils::IsLatin($folder->Name)) {
                $foldername = ConvertUtils::ConvertEncoding($folder->Name, CPAGE_UTF7_Imap, $this->setaccount->_pagebuilder->_proc->account->GetUserCharset());
            } else {
                $foldername = ConvertUtils::ConvertEncoding($folder->Name, $this->setaccount->_pagebuilder->_proc->account->DefaultIncCharset, $this->setaccount->_pagebuilder->_proc->account->GetUserCharset());
            }
            $folderUrl = 'skins/' . $this->setaccount->_pagebuilder->SkinName() . '/folders/' . GetFolderImg($folder->Type, MAILPROTOCOL_POP3);
            $hasChild = $folder->SubFolders != null;
            $hasMessages = $folder->MessageCount > 0;
            $disab = $hasChild || $hasMessages ? 'disabled="disabled" ' : '';
            $disab = $account->MailProtocol == MAILPROTOCOL_POP3 ? '' : $disab;
            $checkbox = $folder->Type == FOLDERTYPE_Custom ? '<input type="checkbox" id="ch_0" name="folders[' . ConvertUtils::AttributeQuote($folder->IdDb) . ']" value="' . ConvertUtils::AttributeQuote($folder->FullName) . '" class="wm_checkbox" ' . $disab . '/>' : '';
            $uphref = $i < 1 ? '<img src="skins/' . $this->setaccount->_pagebuilder->SkinName() . '/folders/up_inactive.gif" />' : '<a onclick="return DoAlert();" href="' . ACTIONFILE . '?action=update&req=folderorder&cf_id=' . $folder->IdDb . '&rf_id=' . $pr_folder->IdDb . '"><img
					src="skins/' . $this->setaccount->_pagebuilder->SkinName() . '/folders/up.gif" /></a>';
            $downhref = $i > $count - 2 ? '<img src="skins/' . $this->setaccount->_pagebuilder->SkinName() . '/folders/down_inactive.gif" />' : '<a onclick="return DoAlert();" href="' . ACTIONFILE . '?action=update&req=folderorder&cf_id=' . $folder->IdDb . '&rf_id=' . $nx_folder->IdDb . '"><img
					src="skins/' . $this->setaccount->_pagebuilder->SkinName() . '/folders/down.gif" /></a>';
            $eyeimg = $folder->Hide ? 'hide.gif' : 'show.gif';
            switch ($folder->Type) {
                default:
                case FOLDERTYPE_Custom:
                    $foldername = ConvertUtils::WMHtmlSpecialChars($foldername);
                    break;
                case FOLDERTYPE_Inbox:
                    $foldername = FolderInbox;
                    break;
                case FOLDERTYPE_Drafts:
                    $foldername = FolderDrafts;
                    break;
                case FOLDERTYPE_SentItems:
                    $foldername = FolderSentItems;
                    break;
                case FOLDERTYPE_Trash:
                    $foldername = FolderTrash;
                    break;
            }
            $nameSting = $folder->Type == FOLDERTYPE_Custom ? '<form action="' . ACTIONFILE . '?action=rename&req=folder" id="folder_form_' . $folder->IdDb . '" method="POST">
					<img src="' . $folderUrl . '" />
					<a href="#" onclick="EditFolder(' . $folder->IdDb . ');" id="folder_a_' . $folder->IdDb . '">' . $foldername . '</a>
					<input type="text" class="wm_hide" name="folderid" value="' . $folder->IdDb . '">
					<input type="text" class="wm_hide" name="fname" maxLength="30" id="folder_i_' . $folder->IdDb . '" value="' . ConvertUtils::AttributeQuote($foldername) . '"/></form>' : '<img src="' . ConvertUtils::AttributeQuote($folderUrl) . '" /> ' . $foldername;
            $imap4SyncTd = $this->setaccount->_editAccount->MailProtocol == MAILPROTOCOL_IMAP4 ? '
						<td><form id="syncform_' . $folder->IdDb . '" action="' . ACTIONFILE . '?action=update&req=foldersync" method="POST">
							<input type="hidden" name="folderid" value="' . $folder->IdDb . '">
							<select onchange="document.getElementById(\'syncform_' . $folder->IdDb . '\').submit();" name="synctype">
								<option value="' . FOLDERSYNC_DontSync . '" ' . ($folder->SyncType == FOLDERSYNC_DontSync ? 'selected="selected"' : '') . '>' . JS_LANG_SyncTypeNo . '</option>
								<option value="' . FOLDERSYNC_NewHeadersOnly . '" ' . ($folder->SyncType == FOLDERSYNC_NewHeadersOnly ? 'selected="selected"' : '') . '>' . JS_LANG_SyncTypeNewHeaders . '</option>
								<option value="' . FOLDERSYNC_AllHeadersOnly . '" ' . ($folder->SyncType == FOLDERSYNC_AllHeadersOnly ? 'selected="selected"' : '') . '>' . JS_LANG_SyncTypeAllHeaders . '</option>
								<option value="' . FOLDERSYNC_NewEntireMessages . '" ' . ($folder->SyncType == FOLDERSYNC_NewEntireMessages ? 'selected="selected"' : '') . '>' . JS_LANG_SyncTypeNewMessages . '</option>
								<option value="' . FOLDERSYNC_AllEntireMessages . '" ' . ($folder->SyncType == FOLDERSYNC_AllEntireMessages ? 'selected="selected"' : '') . '>' . JS_LANG_SyncTypeAllMessages . '</option>
								<option value="' . FOLDERSYNC_DirectMode . '" ' . ($folder->SyncType == FOLDERSYNC_DirectMode ? 'selected="selected"' : '') . '>' . JS_LANG_SyncTypeDirectMode . '</option>
							</select></form>
						</td>
							' : '<td class="wm_hide"></td>';
            $out[0] .= '
						<tr>
							<td>' . $checkbox . '</td>
							<td class="wm_settings_mf_folder">
							<div style="padding-left: ' . $folder->Level * 8 . 'px;">
							' . $nameSting . '
							</div></td>
							<td>' . $folder->MessageCount . '</td>
							<td>' . GetFriendlySize($folder->Size) . '</td>
							' . $imap4SyncTd . '
							<td><a href="#" onclick="if (!DoAlert()) return false; document.location=\'' . ACTIONFILE . '?action=update&req=folderhide&folderid=' . $folder->IdDb . '\'"><img class="wm_settings_mf_show_hide" src="skins/' . $this->setaccount->_pagebuilder->SkinName() . '/folders/' . $eyeimg . '"></a>
							</td>
							<td class="wm_settings_mf_up_down">
								' . $uphref . $downhref . '
							</td>
						</tr>			
				';
            $out[1] .= '<option value="' . $folder->IdDb . '">' . str_repeat('&nbsp;', $folder->Level * 3) . $foldername . '</option>' . "\r\n";
            if ($folder->SubFolders != null && $folder->SubFolders->Count() > 0) {
                $temp = $this->CreateHtmlFolderTree($folder->SubFolders, $messagesCount, $messagesSize, $account);
                $out[0] .= $temp[0];
                $out[1] .= $temp[1];
            }
        }
        return $out;
    }
        if ($settings->EnableMailboxSizeLimit) {
            if ($accountArray['MailboxLimit']) {
                $alttext = 'Account is using  ' . round($accountArray['MailboxSize'] / $accountArray['MailboxLimit'] * 100) . '% (' . GetFriendlySize($accountArray['MailboxSize']) . ') of user ' . GetFriendlySize($accountArray['MailboxLimit']);
                $used_acc = round($accountArray['MailboxSize'] / $accountArray['MailboxLimit'] * 100);
                $used_acc = $used_acc >= 100 ? 100 : $used_acc;
                $used_all = round($accountArray['UserMailboxSize'] / $accountArray['MailboxLimit'] * 100);
                $used_all = $used_all >= 100 ? 100 : $used_all;
                $used_all = $used_all - $used_acc;
                $used_all_clr = '#B7CEDE;';
                $used_acc_clr = '#7E9BAF;';
                echo '<td align="center">
				<div class="wm_progressbar" style="border: solid 1px #7E9BAF;" title="' . ConvertUtils::AttributeQuote($alttext) . '"><div class="wm_progressbar_used" style="background: ' . $used_acc_clr . ' width: ' . $used_acc . 'px;"></div>
				<div class="wm_progressbar_used" style="background: ' . $used_all_clr . ' width: ' . $used_all . 'px;"></div>
				</div></td>';
            } else {
                $alttext = 'User is using  100% (' . GetFriendlySize($accountArray['MailboxSize']) . ') of his(her) ' . GetFriendlySize($accountArray['MailboxLimit']);
                echo '<td align="center"><div class="wm_progressbar" style="border: solid 1px #7E9BAF;" title="' . ConvertUtils::AttributeQuote($alttext) . '"><div class="wm_progressbar_used" style="background: #7E9BAF; width: 100px;"></div></div></td>';
            }
        } else {
            echo '<td align="right">' . round($accountArray['MailboxSize'] / 1024) . '</td>';
        }
        echo '<td align="center">&nbsp;&nbsp;<a href="?mode=wm_edit&uid=' . $accountArray['Id'] . '">Edit</a>&nbsp;&nbsp;<a href="?mode=wm_delete&uid=' . $accountArray['Id'] . '" onclick="return confirm(\'Are you sure?\');">Delete</a></td>';
        echo '</tr>' . "\r\n";
    }
    if ($c == 0) {
        echo '<tr><td align="center" height="30">No Records</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>';
    }
} else {
    echo '<tr><td align="center" height="30">Bad connect</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>';
}
?>