/** * @param PageBuilder $pageBuilder * @return MessageListTable */ function MessageListTable(&$pagebuilder) { $this->_pagebuilder =& $pagebuilder; $this->_proc =& $pagebuilder->_proc; $this->sortField = Get::val('s_fld', 0); $this->sortOrder = Get::val('s_ord', 0); $this->page = $this->_proc->sArray[PAGE]; $this->_proc->account->DefaultOrder = $this->sortField + $this->sortOrder; $this->folders =& $this->_proc->GetFolders(); if (isset($this->_proc->sArray[SEARCH_ARRAY][S_TEXT]) && strlen($this->_proc->sArray[SEARCH_ARRAY][S_TEXT]) > 0) { if ($this->_proc->sArray[SEARCH_ARRAY][S_FOLDER] > -2) { $this->folder =& $this->folders->GetFolderById((int) $this->_proc->sArray[FOLDER_ID]); $this->_proc->processor->GetFolderInfo($this->folder); $this->folders =& new FolderCollection(); $this->folders->Add($this->folder); } else { $this->folder = null; } $field = $this->_proc->sArray[SEARCH_ARRAY][S_MODE] == 'onlyheaders'; $condition = ConvertUtils::ConvertEncoding($this->_proc->sArray[SEARCH_ARRAY][S_TEXT], $this->_proc->account->GetUserCharset(), $this->_proc->account->DbCharset); $this->messCount = (int) $this->_proc->processor->SearchMessagesCount($condition, $this->folders, $field); $this->messageCollection =& $this->_proc->processor->SearchMessages($this->page, $condition, $this->folders, $field, $this->messCount); } else { $cfolder =& $this->_proc->GetCurrentFolder(); if ($cfolder) { $this->folder =& $cfolder; $this->messCount = (int) $this->folder->MessageCount; if ($this->_proc->account->MailsPerPage * ($this->page - 1) >= $this->messCount) { $this->page = (int) ceil($this->messCount / $this->_proc->account->MailsPerPage); } $this->page = $this->page < 1 ? $this->page = 1 : $this->page; $this->messageCollection =& $this->_proc->processor->GetMessageHeaders($this->page, $this->folder); } else { $this->folder = null; $this->messCount = 0; $this->page = 1; $this->messageCollection =& new WebMailMessageCollection(); } } if ($this->folder && $this->folders) { $this->folders->InitToFolder($this->folder); } if ($this->messageCollection === null) { $this->folder = null; $this->messCount = 0; $this->page = 1; $this->messageCollection =& new WebMailMessageCollection(); SetOnlineError(PROC_CANT_GET_MSG_LIST); } $jsTempString = $this->_proc->currentFolder && $this->_proc->currentFolder->Type == FOLDERTYPE_Drafts ? 'BaseForm.Form.action = "' . BASEFILE . '?' . SCREEN . '=' . SCREEN_NEWOREDIT . '";' : 'BaseForm.Form.action = "' . BASEFILE . '?' . SCREEN . '=' . SCREEN_FULLSCREEN . '";'; $flagjs = ' var line = InboxLines.GetLinesById(id); if (line.Flagged) { InboxLines.SetParams([id], "Flagged", false, false); } else { InboxLines.SetParams([id], "Flagged", true, false); } DoFlagOneMessage(line); '; if ($this->_proc->account->MailProtocol != MAILPROTOCOL_IMAP4 && $this->_proc->currentFolder && $this->_proc->currentFolder->SyncType == FOLDERSYNC_DirectMode) { $flagjs = ''; } $this->_pagebuilder->AddJSText(' function CheckThisLine(e, trobj) { var id = trobj.id; e = e ? e : window.event; if (e.ctrlKey) { InboxLines.CheckCtrlLine(id); } else if (e.shiftKey) { InboxLines.CheckShiftLine(id); } else { if (Browser.Mozilla) {var elem = e.target;} else {var elem = e.srcElement;} if (!elem || id == "" || elem.id == "none") { return false; } var loverTag = elem.tagName.toLowerCase(); if (loverTag == "a") { LoadMessageFull(id); } else if (loverTag == "input") { InboxLines.CheckCBox(id); } else if (loverTag == "img") { ' . $flagjs . ' } else if (isPreviewPane) { InboxLines.CheckLine(id); LoadMessage(id); } } } function CheckThisLineDb(e, trobj) { var id = trobj.id; e = e ? e : window.event; if (Browser.Mozilla) { var elem = e.target; } else { var elem = e.srcElement; } if (!elem || id == "" || elem.id == "none" || elem.tagName.toLowerCase() == "input") { return false; } LoadMessageFull(id); } function LoadMessageFull(lineid) { var parseObj = ParseLineId(lineid); var obj = InboxLines.GetLinesById(lineid); ' . $jsTempString . ' BaseForm.Form.target = "_self"; BaseForm.MessId.value = obj.MsgId; BaseForm.MessUid.value = obj.MsgUid; BaseForm.FolderId.value = obj.MsgFolderId; BaseForm.FolderName.value = obj.MsgFolderFullName; BaseForm.Charset.value = parseObj.charset; BaseForm.Plain.value = "-1"; BaseForm.Form.submit(); } function LoadMessage(lineid) { if (tempReq != lineid){ InfoPanel._isError = false; InfoPanel.SetInfo(Lang.Loading); InfoPanel.Show(); tempReq = lineid; var parseObj = ParseLineId(lineid); var obj = InboxLines.GetLinesById(lineid); BaseForm.MessId.value = obj.MsgId; BaseForm.MessUid.value = obj.MsgUid; BaseForm.FolderId.value = obj.MsgFolderId; BaseForm.FolderName.value = obj.MsgFolderFullName; BaseForm.Charset.value = parseObj.charset; BaseForm.Plain.value = "-1"; BaseForm.Form.submit(); } } function DoForwardButton() { var lineobjs = InboxLines.GetCheckedLinesObj(); if (lineobjs && lineobjs.length == 1) { var obj = lineobjs[0]; var parseObj = ParseLineId(obj.Id); BaseForm.Form.action = "' . BASEFILE . '?' . SCREEN . '=' . SCREEN_NEWOREDIT . '"; BaseForm.Form.target = "_self"; BaseForm.MessId.value = obj.MsgId; BaseForm.MessUid.value = obj.MsgUid; BaseForm.FolderId.value = obj.MsgFolderId; BaseForm.FolderName.value = obj.MsgFolderFullName; BaseForm.Charset.value = parseObj.charset; BaseForm.Plain.value = "-1"; BaseForm.Type.value = "forward"; BaseForm.Form.submit(); } } function DoReplyButton() { var lineobjs = InboxLines.GetCheckedLinesObj(); if (lineobjs && lineobjs.length == 1) { var obj = lineobjs[0]; var parseObj = ParseLineId(obj.Id); BaseForm.Form.action = "' . BASEFILE . '?' . SCREEN . '=' . SCREEN_NEWOREDIT . '"; BaseForm.Form.target = "_self"; BaseForm.MessId.value = obj.MsgId; BaseForm.MessUid.value = obj.MsgUid; BaseForm.FolderId.value = obj.MsgFolderId; BaseForm.FolderName.value = obj.MsgFolderFullName; BaseForm.Charset.value = parseObj.charset; BaseForm.Plain.value = "-1"; BaseForm.Type.value = "reply"; BaseForm.Form.submit(); } } function DoReplyAllButton() { var lineobjs = InboxLines.GetCheckedLinesObj(); if (lineobjs && lineobjs.length == 1) { var obj = lineobjs[0]; var parseObj = ParseLineId(obj.Id); BaseForm.Form.action = "' . BASEFILE . '?' . SCREEN . '=' . SCREEN_NEWOREDIT . '"; BaseForm.Form.target = "_self"; BaseForm.MessId.value = obj.MsgId; BaseForm.MessUid.value = obj.MsgUid; BaseForm.FolderId.value = obj.MsgFolderId; BaseForm.FolderName.value = obj.MsgFolderFullName; BaseForm.Charset.value = parseObj.charset; BaseForm.Plain.value = "-1"; BaseForm.Type.value = "replytoall"; BaseForm.Form.submit(); } } function ChangeCharset(newCharset) { var idline = BaseForm.MessId.value + sep + BaseForm.MessUid.value + sep + BaseForm.FolderId.value + sep + BaseForm.Charset.value + sep; var newidline = BaseForm.MessId.value + sep + BaseForm.MessUid.value + sep + BaseForm.FolderId.value + sep + newCharset + sep; BaseForm.Charset.value = newCharset; for (var i=0; i<InboxLines.length; i++) { if (InboxLines.lines[i].Id == idline) { InboxLines.lines[i].Id = newidline; InboxLines.lines[i]._tr.id = newidline; } } } function ParseLineId(lineid) { var IdArray = lineid.split(sep); if (IdArray.length > 3) { var objcharset = (IdArray[3]) ? IdArray[3] : -1; return {id: IdArray[0], uid: IdArray[1], folder_id: IdArray[2], charset: objcharset} } return null; } '); $this->_pagebuilder->AddInitText(' PageSwitcher.Show(' . $this->page . ', ' . $this->_proc->account->MailsPerPage . ', ' . $this->messCount . ', "document.location.replace(\'?s_ord=' . $this->sortOrder . '&s_fld=' . $this->sortField . '&page=", "\');"); tempReq = ""; function CBaseForm() { this.Form = document.getElementById("messform"); this.MessId = document.getElementById("m_id"); this.MessUid = document.getElementById("m_uid"); this.FolderId = document.getElementById("f_id"); this.FolderName = document.getElementById("f_name"); this.Charset = document.getElementById("charset"); this.Plain = document.getElementById("plain"); this.Type = document.getElementById("mtype"); } BaseForm = new CBaseForm(); '); }
/** * @param PageBuilder $pagebuilder * @return ContactsList */ function ContactsList(&$pagebuilder) { if (!defined('WM_ROOTPATH')) { define('WM_ROOTPATH', dirname(__FILE__) . '/../'); } require_once WM_ROOTPATH . 'class_contacts.php'; $this->_pagebuilder =& $pagebuilder; $this->_proc =& $pagebuilder->_proc; $this->_pagebuilder->AddJSFile('./classic/base.cpageswitcher.js'); $this->_pagebuilder->AddJSText(' var selection; function MailGroup(id) { var form = CreateChildWithAttrs(document.body, "form", [["method", "POST"]]); form.action = "' . BASEFILE . '?' . SCREEN . '=' . SCREEN_NEWOREDIT . '"; CreateChildWithAttrs(form, "input", [["type", "hidden"], ["name", "groupid"], ["value", id]]); form.submit(); } function DoDeleteButton() { var i, hideinput, count; var obj = GetSelectedData(); count = obj.contacts.length + obj.groups.length; if (count && count > 0) { if (!confirm(Lang.ConfirmAreYouSure)) { return false; } var form = CreateChildWithAttrs(document.body, "form", [["action", "' . ACTIONFILE . '?action=delete&req=contacts"], ["method", "POST"]]); count = obj.groups.length; for(i = 0; i < count; i++) { hideinput = CreateChildWithAttrs(form, "input", [["type", "hidden"]]); hideinput.name = "groups[" + obj.groups[i] + "]"; } count = obj.contacts.length; for(i = 0; i < count; i++) { hideinput = CreateChildWithAttrs(form, "input", [["type", "hidden"]]); hideinput.name = "contacts[" + obj.contacts[i] + "]"; } form.submit(); } } function AddContactsToGroup(groupid, groupname) { var obj = GetSelectedData(); count = obj.contacts.length; if (count && count > 0) { var form = CreateChild(document.body, "form"); form.action = "' . ACTIONFILE . '?action=move&req=contacts"; form.method = "POST"; hideinput = CreateChildWithAttrs(form, "input", [["type", "hidden"]]); hideinput.name = "groupId"; hideinput.value = groupid; hideinput2 = CreateChildWithAttrs(form, "input", [["type", "hidden"]]); hideinput2.name = "groupName"; hideinput2.value = groupname; for(i = 0; i < count; i++) { hideinput = CreateChildWithAttrs(form, "input", [["type", "hidden"]]); hideinput.name = "contacts[" + obj.contacts[i] + "]"; } form.submit(); } } function DoNewMessageButton(contactId) { if (contactId) { var cid = ParseCId(contactId); if (cid && cid.type == "c") { var form = CreateChild(document.body, "form"); form.action = "' . BASEFILE . '?' . SCREEN . '=' . SCREEN_NEWOREDIT . '"; form.method = "POST"; hideinput = CreateChildWithAttrs(form, "input", [["type", "hidden"]]); hideinput.name = "contacts[" + cid.cid + "]"; form.submit(); } return true; } else { var obj = GetSelectedData(true); count = obj.contacts.length; if (count && count > 0) { var form = CreateChild(document.body, "form"); form.action = "' . BASEFILE . '?' . SCREEN . '=' . SCREEN_NEWOREDIT . '"; form.method = "POST"; for(i = 0; i < count; i++) { hideinput = CreateChildWithAttrs(form, "input", [["type", "hidden"]]); hideinput.name = "contacts[" + obj.contacts[i] + "]"; } form.submit(); } else { document.location = "' . BASEFILE . '?' . SCREEN . '=' . SCREEN_NEWOREDIT . '"; } } } function GetSelectedData(param) { if (!param) { param = false; } var groups = Array(); var contacts = Array(); var ch_array = selection.GetCheckedLines(); if (!ch_array) return false; var count = ch_array.length; if (count < 1 && !param) { alert(Lang.AlertNoContactsGroupsSelected); } for (var i = 0; i < count; i++) { var record = ParseCId(ch_array[i]); if (record && record.type == "g") { groups.push(record.cid); } else { contacts.push(record.cid); } } return {groups: groups, contacts: contacts} } '); $pageNumber = isset($this->_proc->sArray[CONTACT_PAGE]) ? $this->_proc->sArray[CONTACT_PAGE] : 1; $sortField = isset($this->_proc->sArray[CONTACT_FLD]) ? $this->_proc->sArray[CONTACT_FLD] : 1; $sortOrder = isset($this->_proc->sArray[CONTACT_ORD]) ? $this->_proc->sArray[CONTACT_ORD] : 1; $backOrder = (int) (!(bool) $sortOrder); if (isset($this->_proc->sArray[SEARCH_ARRAY][S_TEXT]) && strlen($this->_proc->sArray[SEARCH_ARRAY][S_TEXT]) > 0) { $GLOBALS['contactCount'] = $this->_proc->db->SelectAddressContactsAndGroupsCount(0, $this->_proc->account->IdUser, $this->_proc->sArray[SEARCH_ARRAY][S_TEXT], $this->_proc->sArray[CONTACT_ID]); $contacts =& $this->_proc->db->SearchContactsAndGroups($pageNumber, $this->_proc->sArray[SEARCH_ARRAY][S_TEXT], $this->_proc->sArray[CONTACT_ID], $sortField, $sortOrder, 0); if ($contacts == null) { SetOnlineError(getGlobalError()); } } else { $GLOBALS['contactCount'] = $this->_proc->db->SelectAddressContactsAndGroupsCount(0, $this->_proc->account->IdUser); $contacts =& $this->_proc->db->LoadContactsAndGroups($pageNumber, $sortField, $sortOrder); if ($contacts == null) { SetOnlineError(getGlobalError()); } } if (!$contacts || $contacts->Count() < 1) { if ($pageNumber != 1) { $pageNumber = floor(($GLOBALS['contactCount'][0] + $GLOBALS['contactCount'][1]) / $this->_proc->account->ContactsPerPage); $pageNumber = $pageNumber < 1 ? 1 : $pageNumber; $contacts = $this->_proc->db->LoadContactsAndGroups($pageNumber, $sortField, $sortOrder); } } $this->_pagebuilder->AddInitText(' PageSwitcher = new CPageSwitcher("' . $this->_pagebuilder->SkinName() . '"); PageSwitcher.Build(); PageSwitcher.Show(' . $pageNumber . ', ' . $this->_proc->account->ContactsPerPage . ', ' . ($GLOBALS['contactCount'][0] + $GLOBALS['contactCount'][1]) . ', "document.location = \'?' . CONTACT_PAGE . '=", "\';"); CContactsList = new CContactsList(); '); $imgArray = array(' ', '', ''); $imgArray[$sortField] = $sortOrder == 0 ? ' <img src="./skins/' . $this->_pagebuilder->SkinName() . '/menu/order_arrow_down.gif">' : ' <img src="./skins/' . $this->_pagebuilder->SkinName() . '/menu/order_arrow_up.gif">'; $this->text = ' <div id="contacts" class="wm_contacts_list"> <div class = "wm_contact_list_div" id="contact_list_div"> <div class="wm_inbox_headers" id="contact_list_headers"> <div style="left: 0px; width: 22px;" ><input type="checkbox" id="allcheck"></div> <div style="left: 23px; width: 1px;" class="wm_inbox_headers_separate_noresize"></div> <div class="wm_control" style="left: 25px; width: 22px;" onclick="document.location=\'' . BASEFILE . '?' . CONTACT_ORD . '=' . $backOrder . '&' . CONTACT_FLD . '=0\'" > ' . $imgArray[0] . ' </div> <div style="left: 48px; width: 1px;" class="wm_inbox_headers_separate_noresize"></div> <div style="left: 50px; width: 138px;" class="wm_inbox_headers_from_subject wm_control" onclick="document.location=\'' . BASEFILE . '?' . CONTACT_ORD . '=' . $backOrder . '&' . CONTACT_FLD . '=1\'" > ' . JS_LANG_Name . ' ' . $imgArray[1] . ' </div> <div style="left: 188px; width: 1px;" class="wm_inbox_headers_separate_noresize"></div> <div style="left: 190px; width: 138px;" class="wm_inbox_headers_from_subject wm_control" onclick="document.location=\'' . BASEFILE . '?' . CONTACT_ORD . '=' . $backOrder . '&' . CONTACT_FLD . '=2\'" > ' . JS_LANG_Email . ' ' . $imgArray[2] . ' </div> </div> <div class="wm_inbox_lines"> <table id="list" style="width: 100%; text-align: center;">'; if ($contacts != null && $contacts->Count() > 0) { foreach (array_keys($contacts->Instance()) as $key) { $contact =& $contacts->Get($key); $temp = $contact->IsGroup ? '<img src="skins/' . $this->_pagebuilder->SkinName() . '/contacts/group.gif" />' : ' '; $recordType = $contact->IsGroup ? 'g' : 'c'; if (isset($this->_proc->sArray[SEARCH_ARRAY][S_TEXT]) && strlen($this->_proc->sArray[SEARCH_ARRAY][S_TEXT]) > 0) { $cname = preg_replace('/' . preg_quote($this->_proc->sArray[SEARCH_ARRAY][S_TEXT]) . '/i', '<font>$0</font>', ConvertUtils::WMHtmlSpecialChars($contact->Name)); $cemail = preg_replace('/' . preg_quote($this->_proc->sArray[SEARCH_ARRAY][S_TEXT]) . '/i', '<font>$0</font>', ConvertUtils::WMHtmlSpecialChars($contact->Email)); } else { $cname = ConvertUtils::WMHtmlSpecialChars($contact->Name); $cemail = ConvertUtils::WMHtmlSpecialChars($contact->Email); } $this->text .= '<tr class="wm_inbox_read_item" id="' . $recordType . '_' . $contact->Id . '">'; $this->text .= '<td style="width: 22px; text-align: center;" id="none"><input type="checkbox"></td><td style="width: 24px; text-align: center;">' . $temp . '</td>'; $this->text .= '<td class="wm_inbox_from_subject" style="width: 140px;"><nobr>' . $cname . '</nobr></td>'; $this->text .= '<td class="wm_inbox_from_subject" style="width: 330px;"><nobr>' . $cemail . '</nobr></td></tr>'; } } else { $this->text .= '<div class="wm_inbox_info_message" id="list">' . InfoNoContactsGroups . '<br /><div class="wm_view_message_info">' . InfoNewContactsGroups . '</div></div>'; } $this->text .= '</table></div> </div> </div>'; }