getSpecialMailboxes() public method

Return the list of special mailboxes.
public getSpecialMailboxes ( ) : array
return array
示例#1
0
文件: Driver.php 项目: Gomez/horde
 /**
  * Return a folder object representing an email folder. Attempt to detect
  * special folders appropriately.
  *
  * @param string $sid   The server name.
  * @param array $fl     The complete folder list.
  * @param array $f      An array describing the folder.
  *
  * @return Horde_ActiveSync_Message_Folder
  */
 protected function _getMailFolder($sid, array $fl, array $f)
 {
     $folder = new Horde_ActiveSync_Message_Folder();
     $folder->_serverid = $sid;
     $folder->parentid = '0';
     $folder->displayname = $f['label'];
     // Check for nested folders. $fl will NEVER contain containers so we
     // can assume that any entry in $fl is an actual mailbox. EAS does
     // not support containers so we only do this if the parent is an
     // actual mailbox.
     if ($f['level'] != 0) {
         $parts = explode($f['d'], $sid);
         $displayname = array_pop($parts);
         if (!empty($fl[implode($f['d'], $parts)])) {
             $folder->parentid = $this->_getFolderUidForBackendId(implode($f['d'], $parts), Horde_ActiveSync::FOLDER_TYPE_USER_MAIL);
             $folder->_parentid = implode($f['d'], $parts);
             $folder->displayname = $displayname;
         }
     }
     if (strcasecmp($sid, 'INBOX') === 0) {
         $folder->type = Horde_ActiveSync::FOLDER_TYPE_INBOX;
         $folder->serverid = $this->_getFolderUidForBackendId($sid, $folder->type);
         return $folder;
     }
     try {
         $specialFolders = $this->_imap->getSpecialMailboxes();
     } catch (Horde_ActiveSync_Exception $e) {
         $this->_logger->err(sprintf("[%s] Problem retrieving special folders: %s", $this->_pid, $e->getMessage()));
         throw $e;
     }
     // Check for known, supported special folders.
     foreach ($specialFolders as $key => $value) {
         if (!is_array($value)) {
             $value = array($value);
         }
         foreach ($value as $mailbox) {
             if (!is_null($mailbox)) {
                 switch ($key) {
                     case self::SPECIAL_SENT:
                         if ($sid == $mailbox->value) {
                             $folder->type = Horde_ActiveSync::FOLDER_TYPE_SENTMAIL;
                             $folder->serverid = $this->_getFolderUidForBackendId($sid, $folder->type);
                             return $folder;
                         }
                         break;
                     case self::SPECIAL_TRASH:
                         if ($sid == $mailbox->value) {
                             $folder->type = Horde_ActiveSync::FOLDER_TYPE_WASTEBASKET;
                             $folder->serverid = $this->_getFolderUidForBackendId($sid, $folder->type);
                             return $folder;
                         }
                         break;
                     case self::SPECIAL_DRAFTS:
                         if ($sid == $mailbox->value) {
                             $folder->type = Horde_ActiveSync::FOLDER_TYPE_DRAFTS;
                             $folder->serverid = $this->_getFolderUidForBackendId($sid, $folder->type);
                             return $folder;
                         }
                         break;
                 }
             }
         }
     }
     // Not a known folder, set it to user mail.
     $folder->type = Horde_ActiveSync::FOLDER_TYPE_USER_MAIL;
     $folder->serverid = $this->_getFolderUidForBackendId($sid, $folder->type);
     return $folder;
 }