summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2008-12-18 12:00:06 +0000
committeralecpl <alec@alec.pl>2008-12-18 12:00:06 +0000
commit78928070c513c03dc4242c6965c9c31a993697df (patch)
treeca8607ae41a7fbf6ce90cdce5c59f2c7e958670b
parent7d2afc9d4ab880587a1f662121bd249a0b9ad5b1 (diff)
- Support multiple quota values in QUOTAROOT resonse (#1485626)
-rw-r--r--CHANGELOG1
-rw-r--r--program/lib/imap.inc31
2 files changed, 22 insertions, 10 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 8e550514a..d15f6c951 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,6 +4,7 @@ CHANGELOG RoundCube Webmail
2008/12/18 (alec)
----------
- Fix STARTTLS before AUTH in SMTP connection (#1484883)
+- Support multiple quota values in QUOTAROOT resonse (#1485626)
2008/12/16 (thomasb)
----------
diff --git a/program/lib/imap.inc b/program/lib/imap.inc
index 87773d37d..329db0534 100644
--- a/program/lib/imap.inc
+++ b/program/lib/imap.inc
@@ -75,6 +75,7 @@
- optimize iil_C_FetchHeaders() to use only one FETCH command
- added 4th argument to iil_Connect()
- allow setting rootdir and delimiter before connect
+ - support multiquota result
********************************************************/
@@ -2656,31 +2657,41 @@ function iil_C_GetQuota(&$conn) {
* GETQUOTAROOT "INBOX"
* QUOTAROOT INBOX user/rchijiiwa1
* QUOTA user/rchijiiwa1 (STORAGE 654 9765)
- b OK Completed
+ * OK Completed
*/
$fp = $conn->fp;
$result = false;
- $quota_line = '';
+ $quota_lines = array();
- //get line containing quota info
+ // get line(s) containing quota info
if (iil_PutLine($fp, 'QUOT1 GETQUOTAROOT "INBOX"')) {
do {
$line=chop(iil_ReadLine($fp, 5000));
if (iil_StartsWith($line, '* QUOTA ')) {
- $quota_line = $line;
+ $quota_lines[] = $line;
}
} while (!iil_StartsWith($line, 'QUOT1', true));
}
- //return false if not found, parse if found
- if (!empty($quota_line)) {
+ // return false if not found, parse if found
+ $min_free = PHP_INT_MAX;
+ foreach ($quota_lines as $key => $quota_line) {
$quota_line = eregi_replace('[()]', '', $quota_line);
$parts = explode(' ', $quota_line);
$storage_part = array_search('STORAGE', $parts);
- if ($storage_part > 0) {
- $result['used'] = intval($parts[$storage_part+1]);
- $result['total'] = intval($parts[$storage_part+2]);
- $result['percent'] = min(100, round(($result['used']/max(1,$result['total']))*100));
+
+ if (!$storage_part) continue;
+
+ $used = intval($parts[$storage_part+1]);
+ $total = intval($parts[$storage_part+2]);
+ $free = $total - $used;
+
+ // return lowest available space from all quotas
+ if ($free < $min_free) {
+ $min_free = $free;
+ $result['used'] = $used;
+ $result['total'] = $total;
+ $result['percent'] = min(100, round(($used/max(1,$total))*100));
$result['free'] = 100 - $result['percent'];
}
}