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: * Implementation of IMP_Quota API for a generic hook function. This
16: * requires the quota hook to be set in config/hooks.php.
17: *
18: * You must configure this driver in imp/config/backends.php. The driver
19: * supports the following parameters:
20: * - params: (array) Parameters to pass to the quota function.
21: *
22: * @author Michael Redinger <Michael.Redinger@uibk.ac.at>
23: * @category Horde
24: * @copyright 2002-2014 Horde LLC
25: * @license http://www.horde.org/licenses/gpl GPL
26: * @package IMP
27: */
28: class IMP_Quota_Hook extends IMP_Quota
29: {
30: /**
31: */
32: public function getQuota($mailbox = null)
33: {
34: try {
35: $quota = $GLOBALS['injector']->getInstance('Horde_Core_Hooks')->callHook(
36: 'quota',
37: 'imp',
38: array($this->_params)
39: );
40: } catch (Horde_Exception_HookNotSet $e) {
41: throw new IMP_Exception($e->getMessage());
42: }
43:
44: if (count($quota) != 2) {
45: Horde::log('Incorrect number of return values from quota hook.', 'ERR');
46: throw new IMP_Exception(_("Unable to retrieve quota"));
47: }
48:
49: return array(
50: 'limit' => $quota[1],
51: 'usage' => $quota[0]
52: );
53: }
54:
55: }
56: