1: <?php
2: /**
3: * Copyright 2002-2014 Horde LLC (http://www.horde.org/)
4: *
5: * See the enclosed file COPYING for license information (GPL). If you
6: * did not receive this file, see http://www.horde.org/licenses/gpl.
7: *
8: * @category Horde
9: * @copyright 2002-2014 Horde LLC
10: * @license http://www.horde.org/licenses/gpl GPL
11: * @package IMP
12: */
13:
14: /**
15: * Quota driver for IMAP servers.
16: *
17: * @author Mike Cochrane <mike@graftonhall.co.nz>
18: * @category Horde
19: * @copyright 2002-2014 Horde LLC
20: * @license http://www.horde.org/licenses/gpl GPL
21: * @package IMP
22: */
23: class IMP_Quota_Imap extends IMP_Quota
24: {
25: /**
26: * Constructor.
27: *
28: * @param array $params Parameters:
29: * - imap_ob: (Horde_Imap_Client_Base) IMAP client object [REQUIRED].
30: */
31: public function __construct(array $params = array())
32: {
33: if (!isset($params['imap_ob'])) {
34: throw new InvalidArgumentException('Missing imap_ob parameter');
35: }
36:
37: parent::__construct($params);
38: }
39:
40: /**
41: */
42: public function getQuota($mailbox = null)
43: {
44: try {
45: $quota = $this->_params['imap_ob']->getQuotaRoot(is_null($mailbox) ? 'INBOX' : $mailbox);
46: } catch (IMP_Imap_Exception $e) {
47: throw new IMP_Exception(_("Unable to retrieve quota"));
48: }
49:
50: $quota_val = reset($quota);
51:
52: return isset($quota_val['storage'])
53: ? array(
54: 'limit' => $quota_val['storage']['limit'] * 1024,
55: 'usage' => $quota_val['storage']['usage'] * 1024
56: )
57: : array(
58: 'limit' => 0,
59: 'usage' => 0
60: );
61: }
62:
63: }
64: