Changeset 2172 in subversion


Ignore:
Timestamp:
Dec 18, 2008 7:00:06 AM (4 years ago)
Author:
alec
Message:
  • Support multiple quota values in QUOTAROOT resonse (#1485626)
Location:
trunk/roundcubemail
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/CHANGELOG

    r2170 r2172  
    55---------- 
    66- Fix STARTTLS before AUTH in SMTP connection (#1484883) 
     7- Support multiple quota values in QUOTAROOT resonse (#1485626) 
    78 
    892008/12/16 (thomasb) 
  • trunk/roundcubemail/program/lib/imap.inc

    r2144 r2172  
    7676                - added 4th argument to iil_Connect() 
    7777                - allow setting rootdir and delimiter before connect 
     78                - support multiquota result 
    7879 
    7980********************************************************/ 
     
    26572658 * QUOTAROOT INBOX user/rchijiiwa1 
    26582659 * QUOTA user/rchijiiwa1 (STORAGE 654 9765) 
    2659  b OK Completed 
     2660 * OK Completed 
    26602661 */ 
    26612662        $fp         = $conn->fp; 
    26622663        $result     = false; 
    2663         $quota_line = ''; 
    2664          
    2665         //get line containing quota info 
     2664        $quota_lines = array(); 
     2665         
     2666        // get line(s) containing quota info 
    26662667        if (iil_PutLine($fp, 'QUOT1 GETQUOTAROOT "INBOX"')) { 
    26672668                do { 
    26682669                        $line=chop(iil_ReadLine($fp, 5000)); 
    26692670                        if (iil_StartsWith($line, '* QUOTA ')) { 
    2670                                 $quota_line = $line; 
     2671                                $quota_lines[] = $line; 
    26712672                        } 
    26722673                } while (!iil_StartsWith($line, 'QUOT1', true)); 
    26732674        } 
    26742675         
    2675         //return false if not found, parse if found 
    2676         if (!empty($quota_line)) { 
     2676        // return false if not found, parse if found 
     2677        $min_free = PHP_INT_MAX; 
     2678        foreach ($quota_lines as $key => $quota_line) { 
    26772679                $quota_line   = eregi_replace('[()]', '', $quota_line); 
    26782680                $parts        = explode(' ', $quota_line); 
    26792681                $storage_part = array_search('STORAGE', $parts); 
    2680                 if ($storage_part > 0) { 
    2681                         $result['used']    = intval($parts[$storage_part+1]); 
    2682                         $result['total']   = intval($parts[$storage_part+2]); 
    2683                         $result['percent'] = min(100, round(($result['used']/max(1,$result['total']))*100)); 
     2682                 
     2683                if (!$storage_part) continue; 
     2684         
     2685                $used   = intval($parts[$storage_part+1]); 
     2686                $total  = intval($parts[$storage_part+2]); 
     2687                $free   = $total - $used;  
     2688         
     2689                // return lowest available space from all quotas 
     2690                if ($free < $min_free) {  
     2691                        $min_free = $free;  
     2692                        $result['used']    = $used; 
     2693                        $result['total']   = $total; 
     2694                        $result['percent'] = min(100, round(($used/max(1,$total))*100)); 
    26842695                        $result['free']    = 100 - $result['percent']; 
    26852696                } 
Note: See TracChangeset for help on using the changeset viewer.