コード例 #1
0
ファイル: manager.php プロジェクト: pkdevboxy/webmail-lite
 /**
  * Obtains information about particular folders.
  * 
  * @param CAccount $oAccount Account object.
  * @param array $aFolderFullNamesRaw Array containing a list of folder names to obtain information for.
  * @param string $sInboxUidnext = ''. UIDNEXT value for Inbox folder.
  * @param array $oNewInboxData = null. Extended statistics, works for Inbox only.
  *
  * @return array Array containing elements like those returned by **getFolderInformation** method. 
  */
 public function getFolderListInformation($oAccount, $aFolderFullNamesRaw, $sInboxUidnext = '', $oNewInboxData = null)
 {
     if (!is_array($aFolderFullNamesRaw) || 0 === count($aFolderFullNamesRaw)) {
         throw new CApiInvalidArgumentException();
     }
     $oImapClient =& $this->_getImapClient($oAccount);
     $aResult = array();
     if (2 < count($aFolderFullNamesRaw) && $oImapClient->IsSupported('LIST-STATUS')) {
         $aFolders = $oImapClient->FolderStatusList();
         if (is_array($aFolders)) {
             foreach ($aFolders as $oImapFolder) {
                 $oFolder = CApiMailFolder::createInstance($oImapFolder, true);
                 if ($oFolder) {
                     $mStatus = $oFolder->getStatus();
                     if (is_array($mStatus) && isset($mStatus['MESSAGES'], $mStatus['UNSEEN'], $mStatus['UIDNEXT'])) {
                         $aResult[$oFolder->getRawFullName()] = array((int) $mStatus['MESSAGES'], (int) $mStatus['UNSEEN'], (string) $mStatus['UIDNEXT'], \api_Utils::GenerateFolderHash($oFolder->getRawFullName(), $mStatus['MESSAGES'], $mStatus['UNSEEN'], $mStatus['UIDNEXT']));
                     }
                 }
                 unset($oFolder);
             }
         }
     } else {
         foreach ($aFolderFullNamesRaw as $sFolderFullNameRaw) {
             $sFolderFullNameRaw = (string) $sFolderFullNameRaw;
             try {
                 $aResult[$sFolderFullNameRaw] = $this->_getFolderInformation($oImapClient, $sFolderFullNameRaw);
             } catch (\Exception $oException) {
             }
         }
     }
     if (0 < strlen($sInboxUidnext) && isset($aResult['INBOX'], $aResult['INBOX'][2], $oNewInboxData) && $aResult['INBOX'][2] !== $sInboxUidnext) {
         $oNewInboxData->SetData($this->getNewMessagesInformation($oAccount, 'INBOX', $sInboxUidnext, $aResult['INBOX'][2]));
     }
     return $aResult;
 }
コード例 #2
0
 /**
  * @param CApiMailFolder $oMailFolder
  * @return bool
  */
 public function AddWithPositionSearch($oMailFolder)
 {
     $oItemFolder = null;
     $bIsAdded = false;
     $aList =& $this->GetAsArray();
     foreach ($aList as $oItemFolder) {
         if ($oMailFolder instanceof CApiMailFolder && 0 === strpos($oMailFolder->FullNameRaw(), $oItemFolder->FullNameRaw() . $oItemFolder->Delimiter())) {
             if ($oItemFolder->SubFolders(true)->AddWithPositionSearch($oMailFolder)) {
                 $bIsAdded = true;
             }
             break;
         }
     }
     if (!$bIsAdded && $oMailFolder instanceof CApiMailFolder) {
         $bIsAdded = true;
         $this->Add($oMailFolder);
     }
     return $bIsAdded;
 }