[Svn] r2172 - in trunk/roundcubemail: . program/lib

trac at roundcube.net trac at roundcube.net
Thu Dec 18 13:00:06 CET 2008


Author: alec
Date: 2008-12-18 06:00:06 -0600 (Thu, 18 Dec 2008)
New Revision: 2172

Modified:
   trunk/roundcubemail/CHANGELOG
   trunk/roundcubemail/program/lib/imap.inc
Log:
- Support multiple quota values in QUOTAROOT resonse (#1485626)


Modified: trunk/roundcubemail/CHANGELOG
===================================================================
--- trunk/roundcubemail/CHANGELOG	2008-12-18 10:20:02 UTC (rev 2171)
+++ trunk/roundcubemail/CHANGELOG	2008-12-18 12:00:06 UTC (rev 2172)
@@ -4,6 +4,7 @@
 2008/12/18 (alec)
 ----------
 - Fix STARTTLS before AUTH in SMTP connection (#1484883)
+- Support multiple quota values in QUOTAROOT resonse (#1485626)
 
 2008/12/16 (thomasb)
 ----------

Modified: trunk/roundcubemail/program/lib/imap.inc
===================================================================
--- trunk/roundcubemail/program/lib/imap.inc	2008-12-18 10:20:02 UTC (rev 2171)
+++ trunk/roundcubemail/program/lib/imap.inc	2008-12-18 12:00:06 UTC (rev 2172)
@@ -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 @@
  * 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'];
 		}
 	}

_______________________________________________
http://lists.roundcube.net/mailman/listinfo/svn



More information about the Svn mailing list