/** * Return the list of mail server folders. * * @return array An array of Horde_ActiveSync_Message_Folder objects. */ protected function _getMailFolders() { if (empty($this->_mailFolders)) { if (empty($this->_imap)) { $this->_mailFolders = array($this->_buildDummyFolder(self::SPECIAL_INBOX)); $this->_mailFolders[] = $this->_buildDummyFolder(self::SPECIAL_TRASH); $this->_mailFolders[] = $this->_buildDummyFolder(self::SPECIAL_SENT); $this->_mailFolders[] = $this->_buildDummyFolder(self::SPECIAL_DRAFTS); $this->_mailFolders[] = $this->_buildDummyFolder(self::SPECIAL_OUTBOX); } else { $this->_logger->info(sprintf("[%s] Polling Horde_Core_ActiveSync_Driver::_getMailFolders()", $this->_pid)); $folders = array(); try { $imap_folders = $this->_imap->getMailboxes(true); } catch (Horde_ActiveSync_Exception $e) { $this->_logger->err(sprintf("[%s] Problem loading mail folders from IMAP server: %s", $this->_pid, $e->getMessage())); throw $e; } // Build the folder tree, making sure the lower levels are // added first. $level = 0; $cnt = 0; while ($cnt < count($imap_folders)) { foreach ($imap_folders as $id => $folder) { if ($folder['level'] == $level) { try { $folders[] = $this->_getMailFolder((string) $id, $imap_folders, $folder); ++$cnt; } catch (Horde_ActiveSync_Exception $e) { $this->_logger->err(sprintf("[%s] Problem retrieving %s mail folder", $this->_pid, $id)); } } } ++$level; } // Fake Outbox for broken clients. $folders[] = $this->_buildDummyFolder(self::SPECIAL_OUTBOX); $this->_mailFolders = $folders; } } return $this->_mailFolders; }