Ejemplo n.º 1
0
    /**
     * @param PageBuilder $pageBuilder
     * @return CenterPanel
     */
    function CenterPanel(&$pagebuilder)
    {
        $this->_pagebuilder =& $pagebuilder;
        $this->_proc =& $pagebuilder->_proc;
        $this->_pagebuilder->AddJSFile('./classic/base.inbox.js');
        $this->_pagebuilder->AddJSFile('./classic/base.cpageswitcher.js');
        $isPreview = $this->_proc->account->ViewMode == VIEW_MODE_PREVIEW_PANE || $this->_proc->account->ViewMode == VIEW_MODE_PREVIEW_PANE_NO_IMG ? 'true' : 'false';
        $AskForDel = array('', '');
        if ($this->_proc->currentFolder && $this->_proc->currentFolder->Type == FOLDERTYPE_Trash) {
            $AskForDel = array('if (confirm(\'' . ConvertUtils::ClearJavaScriptString(JS_LANG_ConfirmAreYouSure, '\'') . '\')) {', '}');
        }
        $flagjs = '
	function DoFlagOneMessage(lineobj)
	{
		if (!hiddeniframe) {
			hiddeniframe = CreateChildWithAttrs(document.body, "iframe", [["name", "hiddenframe"], ["class", "wm_hide"]]);
		}
		
		if (hiddenform) {
			hiddenform.action = (lineobj.Flagged) ?
				"' . ACTIONFILE . '?action=groupoperation&req=flag" :
				"' . ACTIONFILE . '?action=groupoperation&req=unflag";
			hiddenform.target = "hiddenframe";
		} else {
			hiddenform = (lineobj.Flagged) ?
				CreateChildWithAttrs(document.body, "form", [["action", "' . ACTIONFILE . '?action=groupoperation&req=flag"], ["target", "hiddenframe"], ["method", "POST"]]) :
				CreateChildWithAttrs(document.body, "form", [["action", "' . ACTIONFILE . '?action=groupoperation&req=unflag"], ["target", "hiddenframe"], ["method", "POST"]]);
		}

		CleanNode(hiddenform);
		CreateChildWithAttrs(hiddenform, "input", [
					["type", "hidden"],
					["name", "d_messages[" + lineobj.MsgFolderId + "][0]"],
					["value", lineobj.MsgFolderFullName]
					]);
		CreateChildWithAttrs(hiddenform, "input", [
					["type", "hidden"],
					["name", "d_messages[" + lineobj.MsgFolderId + "][1][" + lineobj.MsgId + "]"],
					["value", lineobj.MsgUid]
					]);

		hiddenform.submit();
	}
	
	function DoFlagMessages()
	{
		var idsArray = InboxLines.GetCheckedLines();
		InboxLines.SetParams(idsArray.IdArray, "Flagged", true, false);
		
		if (!hiddeniframe) {
			hiddeniframe = CreateChildWithAttrs(document.body, "iframe", [["name", "hiddenframe"], ["class", "wm_hide"]]);
		}
		
		if (hiddenform) {
			hiddenform.action = "' . ACTIONFILE . '?action=groupoperation&req=flag";
			hiddenform.target = "hiddenframe";
		} else {
			hiddenform = CreateChildWithAttrs(document.body, "form", [["action", "' . ACTIONFILE . '?action=groupoperation&req=flag"], ["target", "hiddenframe"], ["method", "POST"]]);
		}
		CleanNode(hiddenform);
		GroupOperation(hiddenform);	
	}
	
	function DoUnFlagMessages()
	{
		var idsArray = InboxLines.GetCheckedLines();
		InboxLines.SetParams(idsArray.IdArray, "Flagged", false, false);
		if (!hiddeniframe) {
			hiddeniframe = CreateChildWithAttrs(document.body, "iframe", [["name", "hiddenframe"], ["class", "wm_hide"]]);
		}
		
		if (hiddenform)	{
			hiddenform.action = "' . ACTIONFILE . '?action=groupoperation&req=unflag";
			hiddenform.target = "hiddenframe";
		} else {
			hiddenform = CreateChildWithAttrs(document.body, "form", [["action", "' . ACTIONFILE . '?action=groupoperation&req=unflag"], ["target", "hiddenframe"], ["method", "POST"]]);
		}
		CleanNode(hiddenform);
		GroupOperation(hiddenform);	
	}
';
        if ($this->_proc->account->MailProtocol != MAILPROTOCOL_IMAP4 && $this->_proc->currentFolder && $this->_proc->currentFolder->SyncType == FOLDERSYNC_DirectMode) {
            $flagjs = '
function DoFlagOneMessage(lineobj) {}
function DoFlagMessages() {}
function DoUnFlagMessages() {}
';
        }
        $this->_pagebuilder->AddJSText('	
	var MovableVerticalDiv, MovableHorizontalDiv;
	var MainContainer, FoldersPart, MessList, Iflame, InboxLines;
	var vResizer, hResizer;
	var vResizerCont;
	var isDisplayFolders = true;
	var sep = "-----";
	var CheckMailUrl = "check-mail.php";
	var EmptyHtmlUrl = "empty.html";
	var isPreviewPane = ' . $isPreview . ';
	var hiddenform, hiddeniframe; 
	
	function GroupOperation(form)
	{
		var messagesArray = InboxLines.GetCheckedLinesObj();
		for (var i = 0; i < messagesArray.length; i++) {
			CreateChildWithAttrs(form, "input", [
					["type", "hidden"],
					["name", "d_messages[" + messagesArray[i].MsgFolderId + "][0]"],
					["value", messagesArray[i].MsgFolderFullName]
					]);
			CreateChildWithAttrs(form, "input", [
					["type", "hidden"],
					["name", "d_messages[" + messagesArray[i].MsgFolderId + "][1][" + messagesArray[i].MsgId + "]"],
					["value", messagesArray[i].MsgUid]
					]);
		}
		
		if (messagesArray.length > 0) {
			form.submit();
		} else {
			alert(Lang.WarningMarkListItem);
		}
	}
	
	function DoNewMessageButton()
	{
		document.location = "' . BASEFILE . '?' . SCREEN . '=' . SCREEN_NEWOREDIT . '";
	}
	
	function MoveToFolder(idfolder)
	{
		if (hiddenform) {
			hiddenform.action = "' . ACTIONFILE . '?action=groupoperation&req=move_messages";
			hiddenform.target = "_self";
		} else {
			hiddenform = CreateChildWithAttrs(document.body, "form", [["action", "' . ACTIONFILE . '?action=groupoperation&req=move_messages"], ["method", "POST"]]);
		}
		
		CleanNode(hiddenform);
		CreateChildWithAttrs(hiddenform, "input", [["type", "hidden"], ["name", "tofolder"], ["value", idfolder]]);
		GroupOperation(hiddenform);
	}
	
	function DoDeleteButton()
	{
		' . $AskForDel[0] . '
			if (hiddenform)	{
				hiddenform.action = "' . ACTIONFILE . '?action=groupoperation&req=delete_messages";
				hiddenform.target = "_self";
			} else {
				hiddenform = CreateChildWithAttrs(document.body, "form", [["action", "' . ACTIONFILE . '?action=groupoperation&req=delete_messages"], ["method", "POST"]]);
			}
			CleanNode(hiddenform);
			GroupOperation(hiddenform);
		' . $AskForDel[1] . '
	}
	
	' . $flagjs . '

	function DoReadMessages()
	{
		var idsArray = InboxLines.GetCheckedLines();
		InboxLines.SetParams(idsArray.IdArray, "Read", true, false);
		if (!hiddeniframe) {
			hiddeniframe = CreateChildWithAttrs(document.body, "iframe", [["name", "hiddenframe"], ["class", "wm_hide"]]);
		}
		
		if (hiddenform) {
			hiddenform.action = "' . ACTIONFILE . '?action=groupoperation&req=read";
			hiddenform.target = "hiddenframe";
		} else {
			hiddenform = CreateChildWithAttrs(document.body, "form", [["action", "' . ACTIONFILE . '?action=groupoperation&req=read"], ["target", "hiddenframe"], ["method", "POST"]]);
		}
		CleanNode(hiddenform);
		GroupOperation(hiddenform);	
	}
	
	function DoUnReadMessages()
	{
		var idsArray = InboxLines.GetCheckedLines();
		InboxLines.SetParams(idsArray.IdArray, "Read", false, false);
		if (!hiddeniframe) {
			hiddeniframe = CreateChildWithAttrs(document.body, "iframe", [["name", "hiddenframe"], ["class", "wm_hide"]]);
		}
		
		if (hiddenform) {
			hiddenform.action = "' . ACTIONFILE . '?action=groupoperation&req=unread";
			hiddenform.target = "hiddenframe";
		} else {
			hiddenform = CreateChildWithAttrs(document.body, "form", [["action", "' . ACTIONFILE . '?action=groupoperation&req=unread"], ["target", "hiddenframe"], ["method", "POST"]]);
		}
		CleanNode(hiddenform);
		GroupOperation(hiddenform);	
	}
	
	function GetSelectMessages()
	{
		var obj = InboxLines.GetCheckedLinesObj();
		var messagesArray = Array();
		
		for (var i = 0; i < obj.IdArray.length; i++) {
			var temp = ParseLineId(obj.IdArray);
			if (temp) {
				messagesArray.push(temp);
			}
		}
		return messagesArray;
	}
	
	function ResizeElements(mode)
	{
		ResizeScreen(mode);
		if (!Browser.IE) {
			ResizeScreen(mode);
		}
	}

	function AddContact(contactString)
	{
		var obj = GetEmailParts(HtmlDecode(contactString));
		var hiddenform = CreateChildWithAttrs(document.body, "form", [["action", "' . BASEFILE . '?' . SCREEN . '=' . SCREEN_CONTACTS . '&' . CONTACT_MODE . '=' . C_NEW . '"], ["target", "_self"], ["method", "POST"]]);
		CreateChildWithAttrs(hiddenform, "input", [["type", "hidden"], ["name", "cdata"], ["value",  "1"]]);
		CreateChildWithAttrs(hiddenform, "input", [["type", "hidden"], ["name", "cemail"], ["value",  obj.Email]]);
		CreateChildWithAttrs(hiddenform, "input", [["type", "hidden"], ["name", "cfullname"], ["value",  obj.Name]]);
		hiddenform.submit();
	}
	
	function ResizeScreen(mode)
	{
		var isAuto = false;
		var height = GetHeight();
		var innerHeight = height - MainContainer.getExternalHeight();
		
		if (innerHeight < 300) {
			innerHeight = 300;
			isAuto = true;
		}
		
		if (isPreviewPane) {
			MainContainer.inner_height = innerHeight;
		}
			
		if (mode == "all") {
			MainContainer.hideContent();
		}
		
		if (mode != "width") {
			var listHeight = MovableHorizontalDiv._topPosition - Iframe.min_upper;
			MessList.height = listHeight;
			
			if (isPreviewPane) {
				var iframe_height = innerHeight - listHeight;
				if (iframe_height < Iframe.min_upper) {
					iframe_height = Iframe.min_upper;
				}

				MessList.resizeElementsHeight(listHeight);
				Iframe.resizeElementsHeight(iframe_height);
				FoldersPart.resizeElementsHeight(innerHeight);

			} else {
				//MessList.resizeElementsHeight(innerHeight);
			}
			MovableVerticalDiv.updateVerticalSize(MainContainer.inner_height);
		}
		
		var resizerWidth = vResizerCont.offsetWidth + 2;
		if (resizerWidth == 2) {
			resizerWidth = 6;
		}
		var width = GetWidth();
		if (mode != "height") {
			var fpWidth = FoldersPart.width;
			if (isDisplayFolders == true) {
				fpWidth = MovableVerticalDiv._leftPosition;
			}
			var ipWidth = width - fpWidth - resizerWidth;
			if (ipWidth < 550) {
				ipWidth = 550;
				fpWidth = width - ipWidth - resizerWidth;
				if (isDisplayFolders == true) {
					if (fpWidth < 80) {
						fpWidth = 80;
						isAuto = true;
					}
				} else {
					if (fpWidth < 18) {
						fpWidth = 18;
						isAuto = true;
					}
				}
			} else {
				fpWidth = width - ipWidth - resizerWidth;
			}
			FoldersPart.width = fpWidth;

			FoldersPart.resizeElementsWidth(fpWidth);
			MessList.resizeElementsWidth(ipWidth);
			Iframe.resizeElementsWidth(ipWidth);

			if (isPreviewPane) {
				MovableHorizontalDiv.updateHorizontalSize(ipWidth);
			}
		}
		
		if (mode == "all") {
			MainContainer.showContent();
		}
				
		PageSwitcher.Replace(MessList.parent_table);
		
		if (isPreviewPane) {
			Iframe.show();
		}
		
		SetBodyAutoOverflow(isAuto);
	} 

	function SetStateTextHandler(text) {
		if (CheckMail) CheckMail.SetText(text);
	}
	
	function SetCheckingFolderHandler(folder, count) {
		if (CheckMail) CheckMail.SetFolder(folder, count);
	}
	
	function SetRetrievingMessageHandler(number) {
		if (CheckMail) CheckMail.SetMsgNumber(number);
	}
	
	function SetDeletingMessageHandler(number) {
		if (CheckMail) CheckMail.DeleteMsg(number);
	}
	
	function EndCheckMailHandler(error)
	{
		if (CheckMail) CheckMail.End();
		if (error.length > 0) {
			if (error == "session_error") {
				document.location = "' . LOGINFILE . '?error=1";
			}
		}
	}

	function CheckEndCheckMailHandler() 
	{
		if (CheckMail && CheckMail.started) {
			CheckMail.End();
			InfoPanel._isError = true;
			InfoPanel.SetInfo(Lang.ErrorCheckMail);
			InfoPanel.Show();
		} else {
			document.location = "' . BASEFILE . '";
		}
	}
	');
        if ($this->_proc->account->MailProtocol == MAILPROTOCOL_IMAP4) {
            $this->_pagebuilder->AddJSText('
	
	function DoUnDeleteButton()
	{
		var idsArray = InboxLines.GetCheckedLines();
		InboxLines.SetParams(idsArray.IdArray, "Deleted", false, false);
		if (!hiddeniframe) {
			hiddeniframe = CreateChildWithAttrs(document.body, "iframe", [["name", "hiddenframe"], ["class", "wm_hide"]]);
		}
		
		if (hiddenform) {
			hiddenform.action = "' . ACTIONFILE . '?action=groupoperation&req=undelete_messages";
			hiddenform.target = "hiddenframe";
		} else {
			hiddenform = CreateChildWithAttrs(document.body, "form", [["action", "' . ACTIONFILE . '?action=groupoperation&req=undelete_messages"], ["target", "hiddenframe"], ["method", "POST"]]);
		}
		CleanNode(hiddenform);
		GroupOperation(hiddenform);
	}
	
	function DoReloadFolderButton()
	{
		document.location = "' . BASEFILE . '?reload=1";
	}
			');
        }
        $this->_pagebuilder->_top->AddOnResize('ResizeElements(\'all\');');
        $this->_pagebuilder->AddInitText('CheckMail = new CCheckMail();');
        $resizer_left = $this->_proc->account->VertResizer;
        $resizer_top = $this->_proc->account->HorizResizer;
        $this->_pagebuilder->AddInitText('
PageSwitcher = new CPageSwitcher("' . $this->_pagebuilder->SkinName() . '");
PageSwitcher.Build();

MainContainer = new CMainContainer();
FoldersPart = new CFoldersPart(isPreviewPane, "' . $this->_pagebuilder->SkinName() . '");

MessList = new CMessageList(isPreviewPane);
Iframe = new CMessageIframe(isPreviewPane);

InboxLines = new CSelection();

vResizer = document.getElementById("vert_resizer");
hResizer = document.getElementById("hor_resizer");
vResizerCont = document.getElementById("vresizer_part");

MovableVerticalDiv = new CVerticalResizer(
	vResizer, MainContainer.table, 2, 81, 551, ' . $resizer_left . ', \'ResizeElements("width")\', 0);

MovableHorizontalDiv = new CHorizontalResizer(
	hResizer, MainContainer.table, 2, Iframe.min_upper + 100, Iframe.min_lower, ' . $resizer_top . ', \'ResizeElements("height")\'); 
');
        $this->_folder_part =& new FolderList($pagebuilder);
        $this->_messages_part =& new MessageListTable($pagebuilder);
    }
Ejemplo n.º 2
0
    /**
     * @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;
		}
				');
        }
    }
Ejemplo n.º 3
0
    /**
     * @param PageBuilder $pagebuilder
     * @return ContactsList
     */
    function ContactsViewer(&$pagebuilder)
    {
        $this->_pagebuilder =& $pagebuilder;
        $this->_proc =& $pagebuilder->_proc;
        $this->_pagebuilder->AddInitText('
selection = new CContactsSelection();
selection.FillContacts();
');
        $this->text = '';
        switch (Get::val(CONTACT_MODE, C_NONE)) {
            case C_IMPORT:
                $this->_pagebuilder->AddJSText('

function ImportContactsHandler(code, count) {
	switch (code) {
		case 0:
			InfoPanel.SetInfo(Lang.ErrorImportContacts);
			InfoPanel.Class("wm_error_information");
			InfoPanel.Show();
			InfoPanel.Resize();
			break;
		case 1: 
			document.location = "' . BASEFILE . '";
			break;
		case 2:
			InfoPanel.SetInfo(Lang.ErrorNoContacts);
			InfoPanel.Class("wm_error_information");
			InfoPanel.Show();
			InfoPanel.Resize();
			break;
		case 3:
			InfoPanel.SetInfo(Lang.ErrorInvalidCSV);
			InfoPanel.Class("wm_error_information");
			InfoPanel.Show();
			InfoPanel.Resize();
			break;
	}
}

function submitForm()
{
	var app1 = document.getElementById("app1");
	var app2 = document.getElementById("app2");
	var fileField = document.getElementById("fileField");
	
	if (app1 && app2 && app1.checked == false && app2.checked == false) {
		alert(Lang.WarningImportFileType);
		return false;
	}
		
	if (fileField) {
		if (Trim(fileField.value).length < 1) {
			alert(Lang.WarningEmptyImportFile);
			return false;		
		} else {
			if (GetExtension(fileField.value) != "csv") {
				alert(Lang.WarningCsvExtention);
				return false;
			}			
		}
	}
	return true;
}
');
                $this->text .= '	
		<div class="wm_contacts_view_edit" id="contacts_viewer">			
			<div id="contacts_viewer_div">
				<table class="wm_contacts_card" id="wm_contacts_card">
					<tr>
						<td class="wm_contacts_card_top_left"><div class="wm_contacts_card_corner"></div></td>
						<td class="wm_contacts_card_top"></td>
						<td class="wm_contacts_card_top_right"><div class="wm_contacts_card_corner"></div></td>
					</tr>
					<tr>
						<td class="wm_contacts_card_left"></td>
						<td>';
                $this->text .= '<table class="wm_contacts_view">
								<tr>
									<td><b>' . JS_LANG_UseImportTo . '</b></td>
								</tr>
								<tr>
									<td>
										<input type="radio" class="wm_checkbox" name="app" id="app1" value="1" />
										<label for="app1">' . JS_LANG_Outlook1 . '</label><br />
										<input type="radio" class="wm_checkbox" name="app" id="app2" value="2" />
										<label for="app2">' . JS_LANG_Outlook2 . '</label><br />
									</td>
								</tr>
								<tr>
									<td>
										' . JS_LANG_SelectImportFile . ':
									</td>
								</tr>
								<tr>
									<td>
										<form target="importIframe" enctype="multipart/form-data" method="post" action="import.php" onsubmit="return submitForm()">
										<iframe class="wm_hide" name="importIframe" id="importIframe"></iframe>
										<input class="wm_file" type="file" name="fileupload" size="30" value="" id="fileField" />
									</td>
								</tr>
							</table>
							<table class="wm_contacts_view" style="width: 90%;">
								<tr>
									<td style="text-align: right; border-top: solid 1px #8D8C89;">
										<input type="submit" class="wm_button" value="' . ConvertUtils::AttributeQuote(JS_LANG_Import) . '" />
										</form>
									</td>
								</tr>
							</table>';
                $this->text .= '</td>
						<td class="wm_contacts_card_right"></td>
					</tr>
					<tr>
						<td class="wm_contacts_card_bottom_left"><div class="wm_contacts_card_corner"></div></td>
						<td class="wm_contacts_card_bottom"></td>
						<td class="wm_contacts_card_bottom_right"><div class="wm_contacts_card_corner"></div></td>
					</tr>
				</table>

			</div>
		</div>
	</div>';
                break;
            case G_NEW:
                $this->_pagebuilder->AddInitText('
OrgTab = document.getElementById("orgTab");
OrgTabImg = document.getElementById("orgTabImg");
OrgTable = document.getElementById("orgTable");
OrgCheckBox = document.getElementById("isorganization");
OrgDiv = document.getElementById("orgDiv");

ShowHideOrgDiv();
ShowHideOrgForm();
					');
                $this->_pagebuilder->AddJSText('
					var OrgTab, OrgTable, OrgCheckBox, OrgDiv;
					var isOrg = false;
					
					function ShowHideOrgDiv() 
					{
						if (!OrgDiv || !OrgCheckBox) {
							return false;
						}
						OrgDiv.className = (OrgCheckBox.checked == true) ? "" : "wm_hide";
						ResizeElements("all");
					}
					
					function dolocation(idurl)
					{
						var url = document.getElementById(idurl);
						if (url && url.value.length > 2) {
							OpenURL(url.value);
						}
					}
					
					function ShowHideOrgForm()
					{
						if (isOrg) {
							OrgTable.className = "wm_hide";
							OrgTabImg.src="skins/' . $this->_pagebuilder->SkinName() . '/menu/arrow_down.gif";
						} else {
							OrgTable.className = "wm_contacts_view";
							OrgTabImg.src="skins/' . $this->_pagebuilder->SkinName() . '/menu/arrow_up.gif";
						}
						
						isOrg = !isOrg;
						ResizeElements("all");
					}
					
					function submitForm()
					{
						var groupnameField = document.getElementById("groupname");
						if (groupnameField && Trim(groupnameField.value).length < 1) {
							alert(Lang.WarningGroupNotComplete);
							return false;		
						}	
						return true;
					}
					');
                $this->text .= '	
		<div class="wm_contacts_view_edit" id= "contacts_viewer">
			<div id="contacts_viewer_div">
				<table class="wm_contacts_card" id="wm_contacts_card">
					<tr>
						<td class="wm_contacts_card_top_left"><div class="wm_contacts_card_corner"></div></td>
						<td class="wm_contacts_card_top"></td>
						<td class="wm_contacts_card_top_right"><div class="wm_contacts_card_corner"></div></td>
					</tr>
					<tr>
						<td class="wm_contacts_card_left"></td>
						<td>';
                $this->text .= '
							<form action="' . ACTIONFILE . '?action=new&req=group" method="POST" onsubmit="return submitForm()">		
							<table class="wm_contacts_view">
								<tr>
									<td>' . JS_LANG_GroupName . ':</td>
									<td>
										<input type="text" name="groupname" id="groupname" class="wm_input wm_group_name_input" maxlength="85"	/>
									</td>
								</tr>
								<tr>
									<td colspan="2">
										<input type="checkbox" class="wm_checkbox" name="isorganization" id="isorganization" class="wm_input" onclick="ShowHideOrgDiv()"/>
										<label for="isorganization">' . TreatAsOrganization . '</label>
									</td>
								</tr>
							</table>

							<div id="orgDiv">
							<table class="wm_contacts_tab" style="margin-top: 20px;" id="orgTab">
								<tr onclick="ShowHideOrgForm()">
									<td>
										<span class="wm_contacts_tab_name">' . Organization . '</span>
										<span class="wm_contacts_tab_mode">
											<img id="orgTabImg" src="skins/' . $this->_pagebuilder->SkinName() . '/menu/arrow_up.gif"/>
										</span>
									</td>
								</tr>
							</table>
														
							<table class="wm_contacts_view" id="orgTable">
								<tr>
									<td class="wm_contacts_view_title" style="width: 20%;">' . JS_LANG_Email . ':</td>
									<td style="width: 80%;" colspan="4">
										<input class="wm_input" type="text" maxlength="255" size="45" name="gemail"/>
									</td>
								</tr>
								<tr>
									<td class="wm_contacts_view_title">' . JS_LANG_Company . ':</td>
									<td colspan="4">
										<input class="wm_input" type="text" maxlength="65" size="18" name="gcompany"/>
									</td>
								</tr>
								<tr>
									<td class="wm_contacts_view_title">' . JS_LANG_StreetAddress . ':</td>
									<td colspan="4">
										<textarea class="wm_input" rows="2" cols="35" name="gstreet"></textarea>
									</td>
								</tr>
								<tr>
									<td class="wm_contacts_view_title" style="width: 20%;">' . JS_LANG_City . ':</td>
									<td style="width: 30%;">
										<input class="wm_input" type="text" maxlength="65" size="18" name="gcity"/>
									</td>
									<td style="width: 5%;"></td>
									<td class="wm_contacts_view_title" style="width: 15%;">' . JS_LANG_Fax . ':</td>
									<td style="width: 30%;">
										<input class="wm_input" type="text" maxlength="50" size="18" name="gfax"/>
									</td>
								</tr>
								<tr>
									<td class="wm_contacts_view_title">' . JS_LANG_StateProvince . ':</td>
									<td>
										<input class="wm_input" type="text" maxlength="65" size="18" name="gstate"/>
									</td>
									<td></td>		
									<td class="wm_contacts_view_title">' . JS_LANG_Phone . ':</td>
									<td>
										<input class="wm_input" type="text" maxlength="50" size="18" name="gphone"/>
									</td>
								</tr>
								<tr>
									<td class="wm_contacts_view_title">' . JS_LANG_ZipCode . ':</td>
									<td>
										<input class="wm_input" type="text" maxlength="10" size="18" name="gzip"/>
									</td>
									<td></td>
									<td class="wm_contacts_view_title">' . JS_LANG_CountryRegion . ':</td>
									<td>
										<input class="wm_input" type="text" maxlength="65" size="18" name="gcountry"/>
									</td>
								</tr>
								<tr>
									<td class="wm_contacts_view_title">' . JS_LANG_WebPage . ':</td>
									<td colspan="4">
										<input class="wm_input" type="text" maxlength="255" size="45" name="gweb" id="gweb"/>
										<input class="wm_button" type="button" value="' . ConvertUtils::AttributeQuote(JS_LANG_Go) . '" onclick="dolocation(\'gweb\');"/>
									</td>
								</tr>
							</table>						
							</div>			
							
							<table class="wm_contacts_view wm_add_contacts">
								<tr>
									<td>
										' . JS_LANG_AddContacts . ':
									</td>
								</tr>
								<tr>
									<td class="wm_secondary_info">
										<textarea name="contactsEmails" rows="2" style="width: 100%; height: 70px;"></textarea>
										' . JS_LANG_CommentAddContacts . '
									</td>
								</tr>
							</table>
							<table class="wm_contacts_view" style="width: 90%;">
								<tr>
									<td class="wm_contacts_save_button">
										<input type="submit" class="wm_button" value="' . ConvertUtils::AttributeQuote(JS_LANG_CreateGroup) . '" />
									</td>
								</tr>
							</table>
							
							</form>
						';
                $this->text .= '</td>
						<td class="wm_contacts_card_right"></td>
					</tr>
					<tr>
						<td class="wm_contacts_card_bottom_left"><div class="wm_contacts_card_corner"></div></td>
						<td class="wm_contacts_card_bottom"></td>
						<td class="wm_contacts_card_bottom_right"><div class="wm_contacts_card_corner"></div></td>
					</tr>
				</table>

			</div>
		</div>
	</div>';
                break;
            case G_VIEW:
                $this->_pagebuilder->AddInitText('
OrgTab = document.getElementById("orgTab");
OrgTabImg = document.getElementById("orgTabImg");
OrgTable = document.getElementById("orgTable");
OrgCheckBox = document.getElementById("isorganization");
OrgDiv = document.getElementById("orgDiv");

ShowHideOrgDiv();
ShowHideOrgForm();
					');
                $this->_pagebuilder->AddJSText('
					var OrgTab, OrgTable, OrgCheckBox, OrgDiv;
					var isOrg = false;
					
					function ShowHideOrgDiv()
					{
						if (!OrgDiv || !OrgCheckBox) {
							return false;
						}
						OrgDiv.className = (OrgCheckBox.checked == true) ? "" : "wm_hide";
						ResizeElements("all");
					}
					
					function ShowHideOrgForm()
					{
						if (isOrg) {
							OrgTable.className = "wm_hide";
							OrgTabImg.src="skins/' . $this->_pagebuilder->SkinName() . '/menu/arrow_down.gif";
						} else {
							OrgTable.className = "wm_contacts_view";
							OrgTabImg.src="skins/' . $this->_pagebuilder->SkinName() . '/menu/arrow_up.gif";
						}
						
						isOrg = !isOrg;
						ResizeElements("all");
					}
					
					');
                $contact_id = Get::val(CONTACT_ID, -1);
                if ($contact_id > -1) {
                    $group =& $this->_proc->db->SelectGroupById($contact_id);
                    $groupname = $group->Name;
                    $contacts =& $this->_proc->db->SelectAddressGroupContacts($contact_id);
                    if ($group && $contacts) {
                        $this->_pagebuilder->AddJSText('
							
	function dolocation(idurl)
	{
		var url = document.getElementById(idurl);
		if (url && url.value.length > 2) {
			OpenURL(url.value);
		}
	}
					
	function RenameGroup()
	{
		var gcontrol = document.getElementById("control_1");
		var gspan = document.getElementById("span_gname");
		var ginput = document.getElementById("editor_1");
		
		gspan.className = "wm_hide";
		gcontrol.className = "wm_hide";
		ginput.value = gspan.innerHTML;
		ginput.className = "wm_input";
		
		ginput.onkeydown = function(ev)
		{
			if (isEnter(ev)) {
				var g_control = document.getElementById("control_1");
				var g_span = document.getElementById("span_gname");
				var g_input = document.getElementById("editor_1");
		
				g_span.innerHTML = ginput.value;
				g_input.className = "wm_hide";
				g_control.className = "";
				g_span.className = "";
				return false;
			}	
			
		}
		ginput.focus();
	}			
	
	function SelectAllInputs(obj)
	{
		var table = document.getElementById("contacts_in_group");
		if (table)
		{
			var inputs = table.getElementsByTagName("input");
			var i, c;
			for (i = 0, c = inputs.length; i < c; i++) {
				if (inputs[i].type == "checkbox" && !inputs[i].disabled) {
					inputs[i].checked = obj.checked;
				}
			}
		}
		return false;
	}
	
	function DeleteContactsFromGroup()
	{
		var inputs = document.getElementsByTagName("input");
		var i, c, t = 0;
		for (i = 0, c = inputs.length; i < c; i++) {
			if (inputs[i].type == "checkbox" && inputs[i].name == "cont_check[]") { 
				t++;
				if  (inputs[i].checked) {
					t--;
					var tr = document.getElementById("in_group_" + inputs[i].value);
					var imp = document.getElementById("inp_" + inputs[i].value);
					if (tr) tr.className = "wm_hide";
					if (imp) imp.value = "-1";
				}
			}
		}
		if (t == 0) {
			var table = document.getElementById("contacts_in_group");
			if (table) table.className = "wm_hide";
			var mail_group = document.getElementById("mail_group");
			if (mail_group) mail_group.className = "wm_hide";		
			
		}
	}
						');
                        $this->_pagebuilder->AddInitText('selection.CheckLine("g_' . $contact_id . '");');
                        $isOrg = $group->IsOrganization ? 'checked="checked"' : '';
                        $html_2 = '';
                        if ($contacts && $contacts->Count() > 0) {
                            $html_2 = '<table id="contacts_in_group" class="wm_inbox_lines" style="margin: 20px 20px 0px 20px; width: 300px;">
									<tr class="wm_inbox_read_item" id="in_group_0">
										<td>
											<input type="checkbox" class="wm_checkbox" onclick="SelectAllInputs(this);" id="CheckAll" name="CheckAll"/>
										</td>
										<td>			
											' . JS_LANG_Name . '
										</td>
										<td>
											' . JS_LANG_Email . '
										</td>
									</tr>';
                            foreach (array_keys($contacts->Instance()) as $key) {
                                $contact =& $contacts->Get($key);
                                $html_2 .= '
									<tr class="wm_inbox_read_item" id="in_group_' . $contact->Id . '">
										<td>
											<input type="checkbox" class="wm_checkbox" id="ch_' . $contact->Id . '" name="cont_check[]" value="' . $contact->Id . '" />
											<input type="hidden" id="inp_' . $contact->Id . '" value="' . $contact->Id . '" name="contactsIds[]" />
										</td>
										<td class="wm_inbox_from_subject">' . ConvertUtils::WMHtmlSpecialChars($contact->Name) . '</td>
										<td class="wm_inbox_from_subject">' . ConvertUtils::WMHtmlSpecialChars($contact->Email) . '</td>
									</tr>';
                            }
                            $html_2 .= '<tr id="mail_group">
													<td colspan="2">
														<a href="#" onclick="MailGroup(' . $contact_id . ')">' . JS_LANG_MailGroup . '</a>
													</td>
													<td style="text-align: right;">
														<a href="#" onclick="DeleteContactsFromGroup();">' . JS_LANG_RemoveFromGroup . '</a>
													</td>
												</tr>
											</table>';
                        }
                        $this->text .= '			
			<div class="wm_contacts_view_edit" id= "contacts_viewer">
				<div id="contacts_viewer_div">
					<form action="' . ACTIONFILE . '?action=update&req=group" method="POST">
					<table class="wm_contacts_card" id="wm_contacts_card">
						<tr>
							<td class="wm_contacts_card_top_left"><div class="wm_contacts_card_corner"></div></td>
							<td class="wm_contacts_card_top"></td>
							<td class="wm_contacts_card_top_right"><div class="wm_contacts_card_corner"></div></td>
						</tr>
						<tr>
							<td class="wm_contacts_card_left"></td>
							<td>';
                        $this->text .= '
								<table class="wm_contacts_view">
									<tr>
										<td>' . JS_LANG_GroupName . ':</td>
										<td class="wm_contacts_name">
											<input type="hidden" name="gid" value="' . $contact_id . '">
											<span id="span_gname">' . $groupname . '</span>
											<a id="control_1" href="#" onclick="return RenameGroup();">' . JS_LANG_Rename . '</a>
											<input style="width: 240px;" id="editor_1" type="text" value="' . ConvertUtils::AttributeQuote($groupname) . '" class="wm_hide" name="gname" />
										</td>
									</tr>
									<tr>
										<td colspan="2">
											<input type="checkbox" class="wm_checkbox" name="isorganization" id="isorganization" class="wm_input" onclick="ShowHideOrgDiv()" ' . $isOrg . '/>
											<label for="isorganization">' . TreatAsOrganization . '</label>
										</td>
									</tr>									
																
								</table>
								
								<div id="orgDiv">
								<table class="wm_contacts_tab" style="margin-top: 20px;" id="orgTab">
									<tr onclick="ShowHideOrgForm()">
										<td>
											<span class="wm_contacts_tab_name">' . Organization . '</span>
											<span class="wm_contacts_tab_mode">
												<img id="orgTabImg" src="skins/' . $this->_pagebuilder->SkinName() . '/menu/arrow_up.gif"/>
											</span>
										</td>
									</tr>
								</table>
															
								<table class="wm_contacts_view" id="orgTable">
									<tr>
										<td class="wm_contacts_view_title" style="width: 20%;">' . JS_LANG_Email . ':</td>
										<td style="width: 80%;" colspan="4">
											<input class="wm_input" type="text" maxlength="255" size="45" name="gemail" value="' . ConvertUtils::AttributeQuote($group->Email) . '"/>
										</td>
									</tr>
									<tr>
										<td class="wm_contacts_view_title">' . JS_LANG_Company . ':</td>
										<td colspan="4">
											<input class="wm_input" type="text" maxlength="65" size="18" name="gcompany" value="' . ConvertUtils::AttributeQuote($group->Company) . '"/>
										</td>
									</tr>
									<tr>
										<td class="wm_contacts_view_title">' . JS_LANG_StreetAddress . ':</td>
										<td colspan="4">
											<textarea class="wm_input" rows="2" cols="35" name="gstreet">' . ConvertUtils::WMHtmlSpecialChars($group->Street) . '</textarea>
										</td>
									</tr>
									<tr>
										<td class="wm_contacts_view_title" style="width: 20%;">' . JS_LANG_City . ':</td>
										<td style="width: 30%;">
											<input class="wm_input" type="text" maxlength="65" size="18" name="gcity" value="' . ConvertUtils::AttributeQuote($group->City) . '"/>
										</td>
										<td style="width: 5%;"></td>
										<td class="wm_contacts_view_title" style="width: 15%;">' . JS_LANG_Fax . ':</td>
										<td style="width: 30%;">
											<input class="wm_input" type="text" maxlength="50" size="18" name="gfax" value="' . ConvertUtils::AttributeQuote($group->Fax) . '"/>
										</td>
									</tr>
									<tr>
										<td class="wm_contacts_view_title">' . JS_LANG_StateProvince . ':</td>
										<td>
											<input class="wm_input" type="text" maxlength="65" size="18" name="gstate" value="' . ConvertUtils::AttributeQuote($group->State) . '"/>
										</td>
										<td></td>		
										<td class="wm_contacts_view_title">' . JS_LANG_Phone . ':</td>
										<td>
											<input class="wm_input" type="text" maxlength="50" size="18" name="gphone" value="' . ConvertUtils::AttributeQuote($group->Phone) . '"/>
										</td>
									</tr>
									<tr>
										<td class="wm_contacts_view_title">' . JS_LANG_ZipCode . ':</td>
										<td>
											<input class="wm_input" type="text" maxlength="10" size="18" name="gzip" value="' . ConvertUtils::AttributeQuote($group->Zip) . '"/>
										</td>
										<td></td>
										<td class="wm_contacts_view_title">' . JS_LANG_CountryRegion . ':</td>
										<td>
											<input class="wm_input" type="text" maxlength="65" size="18" name="gcountry" value="' . ConvertUtils::AttributeQuote($group->Country) . '"/>
										</td>
									</tr>
									<tr>
										<td class="wm_contacts_view_title">' . JS_LANG_WebPage . ':</td>
										<td colspan="4">
											<input class="wm_input" type="text" maxlength="255" size="45" name="gweb" id="gweb" value="' . ConvertUtils::AttributeQuote($group->Web) . '"/>
											<input class="wm_button" type="button" value="' . ConvertUtils::AttributeQuote(JS_LANG_Go) . '" onclick="dolocation(\'gweb\');"/>
										</td>
									</tr>
								</table>						
								</div>										
								
									' . $html_2 . '	

								<table class="wm_contacts_view wm_add_contacts" style="width: 300px;">
									<tr>
										<td>
											' . JS_LANG_AddContacts . ':
										</td>
									</tr>
									<tr>
										<td colspan="2" class="wm_secondary_info">
											<textarea rows="2" style="width: 100%; height: 70px;" name="emails"></textarea>
											' . JS_LANG_CommentAddContacts . '
										</td>
									</tr>
								</table>
								<table class="wm_contacts_view" style="width: 90%;">
									<tr>
										<td class="wm_contacts_save_button">
											<input type="submit" class="wm_button" value="' . ConvertUtils::AttributeQuote(JS_LANG_Save) . '" />
										</td>
									</tr>
								</table>
								
								
								</form>';
                        $this->text .= '
							</td>
							<td class="wm_contacts_card_right"></td>	
						</tr>
						<tr>
							<td class="wm_contacts_card_bottom_left"><div class="wm_contacts_card_corner"></div></td>
							<td class="wm_contacts_card_bottom"></td>
							<td class="wm_contacts_card_bottom_right"><div class="wm_contacts_card_corner"></div></td>
						</tr>
					</table>
	
				</div>
			</div>
		</div>';
                    } else {
                        $this->text = '<div class="wm_contacts_view_edit" id="contacts_viewer"><div id="contacts_viewer_div"></div></div>';
                    }
                }
                break;
            case C_VIEW:
                require_once WM_ROOTPATH . 'classic/base_contactedit.php';
                $contact_id = Get::val(CONTACT_ID, -1);
                $text = WriteContactEdit($this->_pagebuilder, $contact_id);
                if ($text) {
                    $this->_pagebuilder->AddJSFile('./classic/base.cnewcontactscreen.js');
                    $this->_pagebuilder->AddInitText('
						selection.CheckLine("c_' . $contact_id . '");
						
						newContact = new CNewContactScreenPart(0);
						newContact.InitEditContacts(isOpenContact);
						');
                    $this->_pagebuilder->AddJSText('

			function ChangeTabVisibility(tab_name)
			{
				var tab = document.getElementById(tab_name);
				if (!tab) {
					return false;
				}
				if(tab.className == "wm_contacts_view") {
					tab.className = "wm_hide";
					document.getElementById("button_" + tab_name).src = "skins/' . $this->_pagebuilder->SkinName() . '/menu/arrow_down.gif";
				}
				else
				{
					tab.className = "wm_contacts_view";
					document.getElementById("button_" + tab_name).src = "skins/' . $this->_pagebuilder->SkinName() . '/menu/arrow_up.gif";
				}
				ResizeElements("all");
			}
	');
                    $this->text .= '			
			<div class="wm_contacts_view_edit" id= "contacts_viewer">
				<div id="contacts_viewer_div">
					<table class="wm_contacts_card" id="wm_contacts_card">
						<tr>
							<td class="wm_contacts_card_top_left"><div class="wm_contacts_card_corner"></div></td>
							<td class="wm_contacts_card_top"></td>
							<td class="wm_contacts_card_top_right"><div class="wm_contacts_card_corner"></div></td>
						</tr>
						<tr>
							<td class="wm_contacts_card_left"></td>
							<td>';
                    $this->text .= $text;
                    $this->text .= '</td>
							<td class="wm_contacts_card_right"></td>
						</tr>
						<tr>
							<td class="wm_contacts_card_bottom_left"><div class="wm_contacts_card_corner"></div></td>
							<td class="wm_contacts_card_bottom"></td>
							<td class="wm_contacts_card_bottom_right"><div class="wm_contacts_card_corner"></div></td>
						</tr>
					</table>
	
				</div>
			</div>
		</div>';
                } else {
                    $this->text = '<div class="wm_contacts_view_edit" id="contacts_viewer"><div id="contacts_viewer_div"></div></div></div>';
                }
                break;
            case C_NEW:
                require_once WM_ROOTPATH . 'classic/base_contactedit.php';
                $this->_pagebuilder->AddJSFile('./classic/base.cnewcontactscreen.js');
                $this->_pagebuilder->AddInitText('
				newContact = new CNewContactScreenPart(1);
				newContact.InitEditContacts();
					');
                $this->_pagebuilder->AddJSText('

		function ChangeTabVisibility(tab_name)
		{
			var tab = document.getElementById(tab_name);
			if (!tab) {
				return false;
			}
			if(tab.className == "wm_contacts_view")
			{
				tab.className = "wm_hide";
				document.getElementById("button_" + tab_name).src = "skins/' . $this->_pagebuilder->SkinName() . '/menu/arrow_down.gif";
			}
			else
			{
				tab.className = \'wm_contacts_view\';
				document.getElementById("button_" + tab_name).src = "skins/' . $this->_pagebuilder->SkinName() . '/menu/arrow_up.gif";
			}
			ResizeElements("all");
		}
');
                $contact_id = -1;
                $this->text .= '			
			<div class="wm_contacts_view_edit" id="contacts_viewer">
				<div id="contacts_viewer_div">
					<table class="wm_contacts_card" id="wm_contacts_card">
						<tr>
							<td class="wm_contacts_card_top_left"><div class="wm_contacts_card_corner"></div></td>
							<td class="wm_contacts_card_top"></td>
							<td class="wm_contacts_card_top_right"><div class="wm_contacts_card_corner"></div></td>
						</tr>
						<tr>
							<td class="wm_contacts_card_left"></td>
							<td>';
                $this->text .= WriteContactEdit($this->_pagebuilder, $contact_id, true);
                $this->text .= '</td>
							<td class="wm_contacts_card_right"></td>
						</tr>
						<tr>
							<td class="wm_contacts_card_bottom_left"><div class="wm_contacts_card_corner"></div></td>
							<td class="wm_contacts_card_bottom"></td>
							<td class="wm_contacts_card_bottom_right"><div class="wm_contacts_card_corner"></div></td>
						</tr>
					</table>
				</div>
			</div>
		</div>';
                break;
            default:
            case C_NONE:
                $this->text = '<div class="wm_contacts_view_edit" id="contacts_viewer"><div id="contacts_viewer_div"></div></div></div>';
                break;
        }
    }