mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Simplify IMAP QUOTA commands
This commit is contained in:
parent
1ef7ea3f27
commit
f588c91570
1 changed files with 9 additions and 10 deletions
|
|
@ -28,9 +28,7 @@ trait Quota
|
||||||
*/
|
*/
|
||||||
public function Quota(string $sRootName = '') : ?array
|
public function Quota(string $sRootName = '') : ?array
|
||||||
{
|
{
|
||||||
return $this->IsSupported('QUOTA')
|
return $this->getQuota(false, $sRootName);
|
||||||
? $this->getQuotaResult($this->SendRequestGetResponse("GETQUOTA {$this->EscapeFolderName($sRootName)}"))
|
|
||||||
: null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -41,18 +39,19 @@ trait Quota
|
||||||
*/
|
*/
|
||||||
public function QuotaRoot(string $sFolderName = 'INBOX') : ?array
|
public function QuotaRoot(string $sFolderName = 'INBOX') : ?array
|
||||||
{
|
{
|
||||||
return $this->IsSupported('QUOTA')
|
return $this->getQuota(true, $sFolderName);
|
||||||
? $this->getQuotaResult($this->SendRequestGetResponse("GETQUOTAROOT {$this->EscapeFolderName($sFolderName)}"))
|
|
||||||
: null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// * QUOTA "User quota" (STORAGE 1284645 2097152)\r\n
|
// * QUOTA "User quota" (STORAGE 1284645 2097152)\r\n
|
||||||
private function getQuotaResult(\MailSo\Imap\ResponseCollection $oResponseCollection) : array
|
private function getQuota(bool $root, string $sFolderName) : ?array
|
||||||
{
|
{
|
||||||
|
if (!$this->IsSupported('QUOTA')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
$oResponseCollection = $this->SendRequestGetResponse(($root?'GETQUOTAROOT':'GETQUOTA') . " {$this->EscapeFolderName($sFolderName)}");
|
||||||
$aReturn = array(0, 0);
|
$aReturn = array(0, 0);
|
||||||
foreach ($oResponseCollection as $oResponse) {
|
foreach ($this->yieldUntaggedResponses() as $oResponse) {
|
||||||
if (\MailSo\Imap\Enumerations\ResponseType::UNTAGGED === $oResponse->ResponseType
|
if ('QUOTA' === $oResponse->StatusOrIndex
|
||||||
&& 'QUOTA' === $oResponse->StatusOrIndex
|
|
||||||
&& isset($oResponse->ResponseList[3])
|
&& isset($oResponse->ResponseList[3])
|
||||||
&& \is_array($oResponse->ResponseList[3])
|
&& \is_array($oResponse->ResponseList[3])
|
||||||
&& 2 < \count($oResponse->ResponseList[3])
|
&& 2 < \count($oResponse->ResponseList[3])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue