Skip to content

Commit 2fe7249

Browse files
committed
Quota handling fixed
1 parent 192a5de commit 2fe7249

File tree

4 files changed

+64
-3
lines changed

4 files changed

+64
-3
lines changed

src/Client.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ public function getFolderPath(){
420420
*/
421421
public function getQuota() {
422422
$this->checkConnection();
423-
return $this->connection->requestAndResponse("GETQUOTA", ['"#user/'.$this->username.'"']);
423+
return $this->connection->getQuota($this->username);
424424
}
425425

426426
/**
@@ -433,7 +433,7 @@ public function getQuota() {
433433
*/
434434
public function getQuotaRoot($quota_root = 'INBOX') {
435435
$this->checkConnection();
436-
return $this->connection->requestAndResponse("QUOTA", [$quota_root]);
436+
return $this->connection->getQuotaRoot($quota_root);
437437
}
438438

439439
/**

src/Connection/Protocols/ImapProtocol.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,28 @@ public function noop() {
881881
return $this->requestAndResponse('NOOP');
882882
}
883883

884+
/**
885+
* Retrieve the quota level settings, and usage statics per mailbox
886+
* @param $username
887+
*
888+
* @return array
889+
* @throws RuntimeException
890+
*/
891+
public function getQuota($username) {
892+
return $this->requestAndResponse("GETQUOTA", ['"#user/'.$username.'"']);
893+
}
894+
895+
/**
896+
* Retrieve the quota settings per user
897+
* @param string $quota_root
898+
*
899+
* @return array
900+
* @throws RuntimeException
901+
*/
902+
public function getQuotaRoot($quota_root = 'INBOX') {
903+
return $this->requestAndResponse("QUOTA", [$quota_root]);
904+
}
905+
884906
/**
885907
* Send idle command
886908
* @throws RuntimeException

src/Connection/Protocols/LegacyProtocol.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,9 +488,29 @@ public function getProtocol() {
488488
return $this->protocol;
489489
}
490490

491+
/**
492+
* Retrieve the quota level settings, and usage statics per mailbox
493+
* @param $username
494+
*
495+
* @return array
496+
*/
497+
public function getQuota($username) {
498+
return \imap_get_quota($this->stream, 'user.'.$username);
499+
}
500+
501+
/**
502+
* Retrieve the quota settings per user
503+
* @param string $quota_root
504+
*
505+
* @return array
506+
*/
507+
public function getQuotaRoot($quota_root = 'INBOX') {
508+
return \imap_get_quotaroot($this->stream, $quota_root);
509+
}
510+
491511
/**
492512
* @param string $protocol
493-
* @return Pop3Protocol
513+
* @return LegacyProtocol
494514
*/
495515
public function setProtocol($protocol) {
496516
$this->protocol = $protocol;

src/Connection/Protocols/ProtocolInterface.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,25 @@ public function subscribeFolder($folder);
229229
*/
230230
public function expunge();
231231

232+
/**
233+
* Retrieve the quota level settings, and usage statics per mailbox
234+
* @param $username
235+
*
236+
* @return array
237+
* @throws RuntimeException
238+
*/
239+
public function getQuota($username);
240+
241+
/**
242+
* Retrieve the quota settings per user
243+
*
244+
* @param string $quota_root
245+
*
246+
* @return array
247+
* @throws ConnectionFailedException
248+
*/
249+
public function getQuotaRoot($quota_root = 'INBOX');
250+
232251
/**
233252
* Send noop command
234253
*

0 commit comments

Comments
 (0)