roundcubemail/program/lib/Roundcube/rcube_imap_generic.php
public function getQuota($mailbox = null)
    {
        if ($mailbox === null || $mailbox === '') {
            $mailbox = 'INBOX';
        }

        // a0001 GETQUOTAROOT INBOX
        // * QUOTAROOT INBOX user/sample
        // * QUOTA user/sample (STORAGE 654 9765)
        // a0001 OK Completed

        list($code, $response) = $this->execute('GETQUOTAROOT', array($this->escape($mailbox)), 0, '/^\* QUOTA /i');

        $result   = false;
        $min_free = PHP_INT_MAX;
        $all      = array();

        if ($code == self::ERROR_OK) {
            foreach (explode("\n", $response) as $line) {
                list(, , $quota_root) = $this->tokenizeResponse($line, 3);

                $quotas = $this->tokenizeResponse($line, 1);

                if (empty($quotas)) {
                    continue;
                }

                foreach (array_chunk($quotas, 3) as $quota) {
                    list($type, $used, $total) = $quota;
                    $type = strtolower($type);

                    if ($type && $total) {
                        $all[$quota_root][$type]['used']  = intval($used);
                        $all[$quota_root][$type]['total'] = intval($total);
                    }
                }

                if (empty($all[$quota_root]['storage'])) {
                    continue;
                }

                $used  = $all[$quota_root]['storage']['used'];
                $total = $all[$quota_root]['storage']['total'];
                $free  = $total - $used;

                // calculate lowest available space from all storage 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'];
                }
            }
        }

        if (!empty($result)) {
            $result['all'] = $all;
        }

        return $result;
    }
public function getQuota($mailbox = null)
    {
        if ($mailbox === null || $mailbox === '') {
            $mailbox = 'INBOX';
        }

        // a0001 GETQUOTAROOT INBOX
        // * QUOTAROOT INBOX user/sample
        // * QUOTA user/sample (STORAGE 654 9765)
        // a0001 OK Completed

        list($code, $response) = $this->execute('GETQUOTAROOT', array($this->escape($mailbox)), 0, '/^\* QUOTA /i');

        $result   = false;
        $min_free = PHP_INT_MAX;
        $all      = array();

        if ($code == self::ERROR_OK) {
            foreach (explode("\n", $response) as $line) {
                list(, , $quota_root) = $this->tokenizeResponse($line, 3);

                $quotas = $this->tokenizeResponse($line, 1);

                if (empty($quotas)) {
                    continue;
                }

                foreach (array_chunk($quotas, 3) as $quota) {
                    list($type, $used, $total) = $quota;
                    $type = strtolower($type);

                    if ($type && $total) {
                        $all[$quota_root][$type]['used']  = intval($used);
                        $all[$quota_root][$type]['total'] = intval($total);
                    }
                }

                if (empty($all[$quota_root]['storage'])) {
                    continue;
                }

                $used  = $all[$quota_root]['storage']['used'];
                $total = $all[$quota_root]['storage']['total'];
                $free  = $total - $used;

                // calculate lowest available space from all storage 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'];
                }
            }
        }

        if (!empty($result)) {
            $result['all'] = $all;
        }

        return $result;
    }
public function getQuota ( $ mailbox = null ) { if ( $ mailbox === null || $ mailbox === '' ) { $ mailbox = 'INBOX' ; } // a0001 GETQUOTAROOT INBOX // * QUOTAROOT INBOX user/sample // * QUOTA user/sample (STORAGE 654 9765) // a0001 OK Completed list ( $ code , $ response ) = $ this -> execute ( 'GETQUOTAROOT' , array ( $ this -> escape ( $ mailbox ) ) , 0 , '/^\* QUOTA /i' ) ; $ result = false ; $ min_free = PHP_INT_MAX ; $ all = array ( ) ; if ( $ code == self :: ERROR_OK ) { foreach ( explode ( "\n" , $ response ) as $ line ) { list ( , , $ quota_root ) = $ this -> tokenizeResponse ( $ line , 3 ) ; $ quotas = $ this -> tokenizeResponse ( $ line , 1 ) ; if ( empty ( $ quotas ) ) { continue ; } foreach ( array_chunk ( $ quotas , 3 ) as $ quota ) { list ( $ type , $ used , $ total ) = $ quota ; $ type = strtolower ( $ type ) ; if ( $ type && $ total ) { $ all [ $ quota_root ] [ $ type ] [ 'used' ] = intval ( $ used ) ; $ all [ $ quota_root ] [ $ type ] [ 'total' ] = intval ( $ total ) ; } } if ( empty ( $ all [ $ quota_root ] [ 'storage' ] ) ) { continue ; } $ used = $ all [ $ quota_root ] [ 'storage' ] [ 'used' ] ; $ total = $ all [ $ quota_root ] [ 'storage' ] [ 'total' ] ; $ free = $ total - $ used ; // calculate lowest available space from all storage 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' ] ; } } } if ( ! empty ( $ result ) ) { $ result [ 'all' ] = $ all ; } return $ result ; }
Returns QUOTA information

@param string $mailbox Mailbox name

@return array Quota information
Returns QUOTA information