/** * @param string $messageIndex * @param bool $indexAsUid * @param Folder $folder * @return WebMailMessage */ function &LoadMessage($messageIndex, $indexAsUid, &$folder, $_preData = null) { $messageIndexArray = array($messageIndex); if ($this->_settings->StoreMailsInDb) { if (null === $_preData) { $_preData = $this->PreLoadMessagesFromDB($messageIndexArray, $indexAsUid, $folder); } $_msgArray = array_keys($_preData); $message = null; //read messages from db if (!$this->_dbConnection->Execute($this->_commandCreator->LoadMessagesFromDB($_msgArray, $this->Account))) { return $message; } $row = $this->_dbConnection->GetNextRecord(); if ($row && isset($_preData[$row->id_msg])) { $message = new WebMailMessage(); $message->LoadMessageFromRawBody($row->msg); $message->IdMsg = $row->id_msg; $message->IdFolder = $folder->IdDb; $message->Uid = $_preData[$row->id_msg][0]; $message->DbPriority = $_preData[$row->id_msg][1]; $message->Flags = $_preData[$row->id_msg][2]; $message->Size = strlen($row->msg); $message->Downloaded = true; } else { setGlobalError(PROC_MSG_HAS_DELETED); } $this->_dbConnection->FreeResult(); } else { $fs = new FileSystem(INI_DIR . '/mail', strtolower($this->Account->Email), $this->Account->Id); if (null === $_preData) { $_preData = $this->PreLoadMessagesFromDB($messageIndexArray, $indexAsUid, $folder); } foreach ($_preData as $_id_msg => $_varArray) { $message =& $fs->LoadMessage($_id_msg, $folder); if ($message != null && is_array($_varArray)) { $message->IdMsg = $_id_msg; $message->Uid = $_varArray[0]; $message->IdFolder = $folder->IdDb; $message->DbPriority = $_varArray[1]; $message->Flags = $_varArray[2]; $message->Size = $_varArray[4]; $message->Downloaded = true; } else { setGlobalError(PROC_MSG_HAS_DELETED); } break; } } return $message; }
/** * @param string $messageIndex * @param bool $indexAsUid * @param Folder $folder * @return WebMailMessage */ function &LoadMessage($messageIndex, $indexAsUid, &$folder) { $messageIndexArray = array($messageIndex); if ($this->_settings->StoreMailsInDb) { $message = null; //read messages from db if (!$this->_dbConnection->Execute($this->_commandCreator->LoadMessagesFromDB($messageIndexArray, $indexAsUid, $folder, $this->Account))) { return $message; } if ($row = $this->_dbConnection->GetNextRecord()) { $message =& new WebMailMessage(); $message->LoadMessageFromRawBody($row->msg, true); $message->IdMsg = $row->id_msg; $message->Uid = $row->uid; $message->DbPriority = $row->priority; $message->Flags = $row->flags; } else { setGlobalError(PROC_MSG_HAS_DELETED); } } else { $fs =& new FileSystem(INI_DIR . '/mail', $this->Account->Email, $this->Account->Id); //read messages from file system if (!$this->_dbConnection->Execute($this->_commandCreator->LoadMessagesFromFileSystem($messageIndexArray, $indexAsUid, $folder, $this->Account))) { return null; } if ($row = $this->_dbConnection->GetNextRecord()) { $message =& $fs->LoadMessage($row->id_msg, $folder); if ($message != null) { $message->IdMsg = $row->id_msg; $message->Uid = $row->uid; $message->DbPriority = $row->priority; $message->Flags = $row->flags; } else { setGlobalError(PROC_MSG_HAS_DELETED); } } } $this->_dbConnection->FreeResult(); return $message; }