1: <?php
2: /**
3: * Implementation of IMP_Quota API for a generic hook function. This
4: * requires the quota hook to be set in config/hooks.php.
5: *
6: * You must configure this driver in imp/config/backends.php. The driver
7: * supports the following parameters:
8: * <pre>
9: * 'params' - (array) Parameters to pass to the quota function.
10: * </pre>
11: *
12: * Copyright 2002-2012 Horde LLC (http://www.horde.org/)
13: *
14: * See the enclosed file COPYING for license information (GPL). If you
15: * did not receive this file, see http://www.horde.org/licenses/gpl.
16: *
17: * @author Michael Redinger <Michael.Redinger@uibk.ac.at>
18: * @category Horde
19: * @license http://www.horde.org/licenses/gpl GPL
20: * @package IMP
21: */
22: class IMP_Quota_Hook extends IMP_Quota_Base
23: {
24: /**
25: * Get quota information (used/allocated), in bytes.
26: *
27: * @return array An array with the following keys:
28: * 'limit' = Maximum quota allowed
29: * 'usage' = Currently used portion of quota (in bytes)
30: * @throws IMP_Exception
31: */
32: public function getQuota()
33: {
34: try {
35: $quota = Horde::callHook('quota', array($this->_params), 'imp');
36: } catch (Horde_Exception_HookNotSet $e) {
37: throw new IMP_Exception($e->getMessage());
38: }
39:
40: if (count($quota) != 2) {
41: Horde::logMessage('Incorrect number of return values from quota hook.', 'ERR');
42: throw new IMP_Exception(_("Unable to retrieve quota"));
43: }
44:
45: return array(
46: 'limit' => $quota[1],
47: 'usage' => $quota[0]
48: );
49: }
50:
51: }
52: