/** * @param WebMailMessageCollection $messageCollection * @param DbStorage $dbStorage * @param Folder $folder * @return bool */ function ApplyFilters(&$messageCollection, &$dbStorage, &$folder) { $filters =& $dbStorage->SelectFilters($this->Account->Id); $lastIdMsg = $dbStorage->SelectLastIdMsg(); $mailBoxesSize = $dbStorage->SelectMailboxesSize(); $result = true; foreach (array_keys($messageCollection->Instance()) as $key) { $message =& $messageCollection->Get($key); $needToSave = true; if ($this->_settings->EnableMailboxSizeLimit && $this->Account->MailboxLimit < $mailBoxesSize + $message->Size) { setGlobalError(ErrorGetMailLimit); return false; } $mailBoxesSize += $message->Size; $lastIdMsg += rand(1, 10); $message->IdMsg = $lastIdMsg; if ($folder->SyncType == FOLDERSYNC_NewEntireMessages || $folder->SyncType == FOLDERSYNC_AllEntireMessages) { $result &= $dbStorage->SaveMessage($message, $folder); } elseif ($folder->SyncType == FOLDERSYNC_NewHeadersOnly || $folder->SyncType == FOLDERSYNC_AllHeadersOnly) { $result &= $dbStorage->SaveMessageHeader($message, $folder, false); } } if ($folder->Type == FOLDERTYPE_Inbox && $result && isset($GLOBALS['useFilters'])) { $mailProcessor = new MailProcessor($this->Account); foreach (array_keys($filters->Instance()) as $key) { $filter =& $filters->Get($key); $action = $filter->GetActionToApply($message); $uidArray = array($message->Uid); $messageIdUidSet[$message->IdMsg] = $message->Uid; switch ($action) { case FILTERACTION_DeleteFromServerImmediately: $result &= $mailProcessor->DeleteMessages($messageIdUidSet, $folder); break; case FILTERACTION_MoveToFolder: $toFolder =& new Folder($filter->IdAcct, $filter->IdFolder, ''); $dbStorage->GetFolderInfo($toFolder); $result &= $mailProcessor->MoveMessages($messageIdUidSet, $folder, $toFolder); break; case FILTERACTION_MarkGrey: $result &= $mailProcessor->SetFlags($messageIdUidSet, $folder, MESSAGEFLAGS_Grayed, ACTION_Set); break; } } } return $result; }
/** * @access private * @param Array $messageIndexSet * @param bool $indexAsUid * @param Folder $folder * @return WebMailMessageCollection */ function &_loadMessageHeaders(&$messageIndexSet, $indexAsUid, $folder) { $messageCollection = new WebMailMessageCollection(); $uids =& $this->_getPop3Uids(); $size =& $this->_getPop3Sizes(); foreach ($messageIndexSet as $index) { $idx = $index; if ($indexAsUid) { $idx = $this->_getMessageIndexFromUid($uids, $index); } if ($idx < 0 || $idx > count($uids)) { continue; } $msgText = $this->_pop3Mail->get_top($idx); if (!$msgText) { continue; } $message = new WebMailMessage(); $message->LoadMessageFromRawBody($msgText); $message->IdMsg = $idx; $message->Uid = $uids[$idx]; $size =& $this->_getPop3Sizes(); $message->Size = $size[$idx]; if ($folder->SyncType == FOLDERSYNC_DirectMode) { $message->Flags |= MESSAGEFLAGS_Seen; } $messageCollection->Add($message); unset($message); } return $messageCollection; }
/** * @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; }
/** * @param int $pageNumber * @param string $condition * @param FolderCollection $folders * @param bool $inHeadersOnly * @return WebMailMessageCollection */ function &SearchMessages($pageNumber, $condition, &$folders, $inHeadersOnly) { $mailCollection = null; if ($this->_dbConnection->Execute($this->_commandCreator->SearchMessages($pageNumber, $condition, $folders->CreateFolderListFromTree(), $inHeadersOnly, $this->Account))) { $mailCollection = new WebMailMessageCollection(); while (false !== ($row = $this->_dbConnection->GetNextRecord())) { $msg =& $this->_rowToWebMailMessage($row); $mailCollection->Add($msg); unset($msg); } } return $mailCollection; }
/** * @param array $messageIdSet * @param Folder $folder * @return MessageCollection */ function GetMessages(&$messageIdUidSet, &$folder, $setRead = false) { $mailCollection = new WebMailMessageCollection(); $GLOBALS[MailDefaultCharset] = $this->_account->GetDefaultIncCharset(); $GLOBALS[MailOutputCharset] = $this->_account->GetUserCharset(); ConvertUtils::SetLimits(); $messageIdSet = array_keys($messageIdUidSet); $messageUidSet = array_values($messageIdUidSet); for ($i = 0, $c = count($messageIdUidSet); $i < $c; $i++) { $messageId =& $messageIdSet[$i]; $messageUid =& $messageUidSet[$i]; $mailMess = null; if ($folder->SyncType == FOLDERSYNC_DirectMode) { if ($this->MailStorage->Connect()) { $mailMess =& $this->MailStorage->LoadMessage($messageUid, true, $folder); } } elseif ($this->DbStorage->Connect()) { if ($this->DbStorage->GetMessageDownloadedFlag($messageId, $folder)) { $mailMess =& $this->DbStorage->LoadMessage($messageId, false, $folder); } elseif ($this->MailStorage->Connect()) { $mailMess =& $this->MailStorage->LoadMessage($messageUid, true, $folder); } } if ($setRead && $mailMess) { $mailMess->Flags = $mailMess->Flags | MESSAGEFLAGS_Seen; } if ($mailMess) { $mailMess->IdFolder = $folder->IdDb; } $mailCollection->Add($mailMess); unset($mailMess); } return $mailCollection; }
/** * @param WebMailMessageCollection $messages * @param Folder $folder * @return bool */ function SaveMessages(&$messages, &$folder) { $result = true; for ($i = 0; $i < $messages->Count(); $i++) { $result &= $this->SaveMessage($messages->Get($i), $folder); } return $result; }
/** * @param WebMailMessageCollection $messages * @param Folder $folder * @return bool */ function SaveMessages(&$messages, &$folder) { $result = true; for ($i = 0, $count = $messages->Count(); $i < $count; $i++) { $mess =& $messages->Get($i); if ($mess) { $result &= $this->SaveMessage($mess, $folder); } else { $result = false; } } return $result; }