From: Michael M Slusarz Date: Thu, 4 Feb 2010 07:24:35 +0000 (-0700) Subject: Quota fixes/doc improvements X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=9b5a6d62145bb417f2b2f40bb8302b1cdf20756e;p=horde.git Quota fixes/doc improvements --- diff --git a/imp/config/servers.php.dist b/imp/config/servers.php.dist index eb0069003..8aeabdfa0 100644 --- a/imp/config/servers.php.dist +++ b/imp/config/servers.php.dist @@ -66,51 +66,6 @@ * This value overrides any existing * $conf['mailer']['params']['port'] value at runtime. * - * quota: (array) Use this if you want to display a user's quota status on - * various IMP pages. Set 'driver' equal to the mailserver and 'params' - * equal to any extra parameters needed by the driver (see the - * comments located at the top of imp/lib/Quota/[quotadriver].php - * for the parameters needed for each driver). Set - * 'hide_when_unlimited' to true if you want to hide quota output - * when the server reports an unlimited quota. - * - * Set this to an empty value to disable quota (the DEFAULT). - * - * The optional 'unit' parameter indicates what storage unit the quota - * messages hould be displayed in. It can be one of three possible - * values: 'GB', 'MB' (DEFAULT), or 'KB'. - * - * The optional 'format' parameter is supported by all drivers and - * specifies the formats of the quota messages in the user - * interface. The parameter must be specified as a hash with the four - * possible elements 'long', 'short', 'nolimit_long', and - * 'nolimit_short' with according versions of the quota message. The - * strings will be passed through sprintf(). - * These are the built-in default values, though they may appear - * differently in some translations ([UNIT] will be replaced with the - * value of the 'unit' parameter): - * 'long' - Quota status: %.2f [UNIT] / %.2f [UNIT] (%.2f%%) - * 'nolimit_long' - Quota status: %.2f [UNIT] / NO LIMIT - * 'short' - %.0f%% of %.0f [UNIT] - * 'nolimit_short' - %.0f [UNIT] - * - * Currently available drivers: - * 'command' - Use the UNIX quota command to handle quotas. - * 'hook' - Use the quota hook to handle quotas (see - * imp/config/hooks.php). - * 'imap' - Use the IMAP QUOTA extension to handle quotas. - * You must be connecting to a IMAP server capable of the - * QUOTAROOT command to use this driver. This is the - * RECOMMENDED way of handling quotas if the IMAP server - * supports it. - * 'logfile' - Allow quotas on servers where IMAP Quota commands are - * not supported, but quota info appears in the servers - * messages log for the IMAP server. - * 'maildir' - Use Maildir++ quota files to handle quotas. - * 'mdaemon' - Use Mdaemon servers to handle quotas. - * 'mercury32' - Use Mercury/32 servers to handle quotas. - * 'sql' - Use arbitrary SQL queries to handle quotas. - * * admin: (array) Use this if you want to enable mailbox management for * administrators via Horde's user administration interface. The * mailbox management gets enabled if you let IMP handle the Horde @@ -172,6 +127,116 @@ * * ((Horde_Auth::getAuth() == 'foo') ? '/tmp/imaplog' : false) * + * quota: (array) Use this if you want to display a user's quota status on + * various IMP pages. Set to an empty value to disable quota status + * (DEFAULT). + * + * The entry is configured as follows: + * + * 'quota' => array( + * /* Driver name: see below */ + * 'driver' => [string] (REQUIRED), + + * 'params' => array( + * /* True if you want to hide quota output when the server + * * reports an unlimited quota. */ + * 'hide_when_unlimited' => true | false, + * + * /* What storage unit the quota messages should be + * * displayed in. */ + * 'unit' => 'GB' | 'MB' (DEFAULT) | 'KB', + * + * /* Output format: see below. */ + * 'format' => array(), + * + * /* Additional driver parameters: see below. */ + * ) + * ) + * + * 'driver'/'params' can be the following: + * + * DRIVER: 'command' + * Use the UNIX quota command to handle quotas. + * PARAMS: 'quota_path' - [string] Path to the quota binary + * (REQUIRED) + * 'grep_path' - [string] Path to the grep binary (REQUIRED) + * 'partition' - [string] If all user mailboxes are on a + * single partition, the partition label. By + * default, quota will determine quota + * information using the user's home directory + * value. + * + * DRIVER: 'hook' + * Use the quota hook to handle quotas (see + * imp/config/hooks.php). + * PARAMS: 'params' - [array] Parameters to pass to the quota + * hook function. + * + * DRIVER: 'imap' + * Use the IMAP QUOTA extension to handle quotas. + * You must be connecting to a IMAP server capable of the + * QUOTAROOT command to use this driver. This is the + * RECOMMENDED way of handling quotas if the IMAP server + * supports it. + * PARAMS: NONE + * + * DRIVER: 'maildir' + * Use Maildir++ quota files to handle quotas. + * PARAMS: 'path' - [string] The path to the user's Maildir + * directory. You may use the two-character + * sequence "~U" to represent the user's account + * name, and the actual username will be + * substituted in that location. E.g., + * '/home/~U/Maildir/' or '/var/mail/~U/Maildir/'. + * + * DRIVER: 'mdaemon' + * Use Mdaemon servers to handle quotas. + * PARAMS: 'app_location' - [string] Location of the application. + * + * DRIVER: 'mercury32' + * Use Mercury/32 servers to handle quotas. + * PARAMS: 'mail_user_folder' - [string] The path to folder mail + * mercury. + * + * DRIVER: 'sql' + * Use arbitrary SQL queries to handle quotas. + * PARAMS: 'query_quota' - (string) SQL query which returns single + * row/column with user quota (in bytes). %u is replaced + * with current user name, %U with the user name without the + * domain part, %d with the domain. + * 'query_used' - (string) SQL query which returns single + * row/column with user used space (in bytes). Placeholders + * are the same like in query_quota. + * + * Additionally, the driver takes SQL connection parameters + * 'phptype', 'hostspec',' 'username', 'password', and + * 'database'. See horde/config/conf.php for further + * information on these parameters. If using the Horde DB, + * these parameters can be found in the + * $GLOBALS['conf']['sql'] variable and may be merged into + * the parameter configuration like this: + * + * 'params' => array_merge( + * $GLOBALS['conf']['sql'], + * array( + * 'query_quota' => [...], + * 'query_used' => [...], + * ) + * ) + * + * The optional 'format' parameter is supported by all drivers and + * specifies the formats of the quota messages in the user + * interface. The parameter must be specified as a hash with the four + * possible elements 'long', 'short', 'nolimit_long', and + * 'nolimit_short'. The strings will be passed through sprintf(). + * These are the built-in default values, though they may appear + * differently in some translations ([UNIT] will be replaced with the + * value of the 'unit' parameter): + * 'long' - Quota status: %.2f [UNIT] / %.2f [UNIT] (%.2f%%) + * 'nolimit_long' - Quota status: %.2f [UNIT] / NO LIMIT + * 'short' - %.0f%% of %.0f [UNIT] + * 'nolimit_short' - %.0f [UNIT] + * * * *** The following options should NOT be set unless you REALLY know what *** * *** you are doing! FOR MOST PEOPLE, AUTO-DETECTION OF THESE PARAMETERS *** diff --git a/imp/lib/Ajax/Application.php b/imp/lib/Ajax/Application.php index 43d1e8d82..472c8586b 100644 --- a/imp/lib/Ajax/Application.php +++ b/imp/lib/Ajax/Application.php @@ -331,7 +331,7 @@ class IMP_Ajax_Application extends Horde_Ajax_Application_Base $quota = $this->_getQuota(); if (!is_null($quota)) { - $result['quota'] = $quota; + $result->quota = $quota; } return $result; @@ -1820,11 +1820,14 @@ class IMP_Ajax_Application extends Horde_Ajax_Application_Base */ protected function _getQuota() { - if (isset($_SESSION['imp']['quota']) && - is_array($_SESSION['imp']['quota'])) { + if (isset($_SESSION['imp']['imap']['quota']) && + is_array($_SESSION['imp']['imap']['quota'])) { $quotadata = IMP::quotaData(false); if (!empty($quotadata)) { - return array('p' => round($quotadata['percent']), 'm' => $quotadata['message']); + return array( + 'm' => $quotadata['message'], + 'p' => round($quotadata['percent']) + ); } } diff --git a/imp/lib/IMP.php b/imp/lib/IMP.php index 48ef92efd..734f493d9 100644 --- a/imp/lib/IMP.php +++ b/imp/lib/IMP.php @@ -578,19 +578,23 @@ class IMP */ static public function quotaData($long = true) { - if (!isset($_SESSION['imp']['quota']) || - !is_array($_SESSION['imp']['quota'])) { + if (!isset($_SESSION['imp']['imap']['quota']) || + !is_array($_SESSION['imp']['imap']['quota'])) { return false; } try { - $quotaDriver = IMP_Quota::singleton($_SESSION['imp']['quota']['driver'], $_SESSION['imp']['quota']['params']); + $quotaDriver = IMP_Quota::singleton($_SESSION['imp']['imap']['quota']['driver'], isset($_SESSION['imp']['imap']['quota']['params']) ? $_SESSION['imp']['imap']['quota']['params'] : array()); $quota = $quotaDriver->getQuota(); } catch (Horde_Exception $e) { Horde::logMessage($e, __FILE__, __LINE__, PEAR_LOG_ERR); return false; } + if (empty($quota)) { + return false; + } + $strings = $quotaDriver->getMessages(); list($calc, $unit) = $quotaDriver->getUnit(); $ret = array('percent' => 0); diff --git a/imp/lib/Quota/Command.php b/imp/lib/Quota/Command.php index aa8183f7f..fec3d7183 100644 --- a/imp/lib/Quota/Command.php +++ b/imp/lib/Quota/Command.php @@ -7,13 +7,15 @@ * authentication and file servers (e.g. via NIS/NFS). And last, it (as * written) requires the POSIX PHP extensions. * - * You must configure this driver in horde/imp/config/servers.php. The - * driver supports the following parameters: - * 'quota_path' => Path to the quota binary - REQUIRED - * 'grep_path' => Path to the grep binary - REQUIRED - * 'partition' => If all user mailboxes are on a single partition, the - * partition label. By default, quota will determine - * quota information using the user's home directory value. + * You must configure this driver in imp/config/servers.php. The driver + * supports the following parameters: + *
+ * 'grep_path' - (string) [REQUIRD] Path to the grep binary.
+ * 'partition' - (string) If all user mailboxes are on a single partition, the
+ *               partition label.  By default, quota will determine quota
+ *               information using the user's home directory value.
+ * 'quota_path' - (string) [REQUIRED] Path to the quota binary.
+ * 
* * Copyright 2002-2010 The Horde Project (http://www.horde.org/) * diff --git a/imp/lib/Quota/Hook.php b/imp/lib/Quota/Hook.php index 526018ebf..e1976f777 100644 --- a/imp/lib/Quota/Hook.php +++ b/imp/lib/Quota/Hook.php @@ -1,14 +1,13 @@ Array of parameters to pass to the quota function. + * You must configure this driver in imp/config/servers.php. The driver + * supports the following parameters: + *
+ * 'params' - (array) Parameters to pass to the quota function.
+ * 
* * Copyright 2002-2010 The Horde Project (http://www.horde.org/) * diff --git a/imp/lib/Quota/Imap.php b/imp/lib/Quota/Imap.php index cfedb0e8e..ad5c1571f 100644 --- a/imp/lib/Quota/Imap.php +++ b/imp/lib/Quota/Imap.php @@ -2,6 +2,9 @@ /** * Implementation of the IMP_Quota API for IMAP servers. * + * You must configure this driver in imp/config/servers.php. The driver does + * not require any parameters. + * * Copyright 2002-2010 The Horde Project (http://www.horde.org/) * * See the enclosed file COPYING for license information (GPL). If you @@ -28,8 +31,15 @@ class IMP_Quota_Imap extends IMP_Quota throw new Horde_Exception(_("Unable to retrieve quota"), 'horde.error'); } + if (empty($quota)) { + return array(); + } + $quota_val = reset($quota); - return array('usage' => $quota['storage']['usage'] * 1024, 'limit' => $quota['storage']['limit'] * 1024); + return array( + 'usage' => $quota_val['storage']['usage'] * 1024, + 'limit' => $quota_val['storage']['limit'] * 1024 + ); } } diff --git a/imp/lib/Quota/Logfile.php b/imp/lib/Quota/Logfile.php deleted file mode 100644 index 0afd2cafc..000000000 --- a/imp/lib/Quota/Logfile.php +++ /dev/null @@ -1,87 +0,0 @@ - - * 'quota' => array( - * 'driver' => 'logfile', - * 'params' => array( - * 'logfile' => '/path/to/log/file', - * 'taillines' => 10, - * 'FTPmail' => 'FTP', - * 'beginocc' => 'usage = ', - * 'midocc' => ' of ', - * 'endocc' => ' bytes' - * ) - * ); - * - * logfile - The path/to/filename of the log file to use. - * taillines - The number of lines to look at in the tail of the logfile. - * FTPmail - If you want to show what FTP space is available (IMAP folder) - * or what mail space is available (INBOX). - * Defines the search string to username: - * FTPmail to identify the line with QUOTA info. - * beginocc - String that designates the characters before the usage - * number. - * midocc - String between usage and total storage space. - * endocc - String after the storage number. - * - * - * See the enclosed file COPYING for license information (GPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. - * - * @author Tim Gorter - * @package IMP - */ -class IMP_Quota_Logfile extends IMP_Quota -{ - /** - * Constructor - * - * @param array $params Hash containing connection parameters. - */ - protected function __construct($params = array()) - { - parent::__construct(array_merge(array( - 'logfile' => '', - 'taillines' => 10, - 'FTPmail' => 'FTP', - 'beginocc' => 'usage = ', - 'midocc' => ' of ', - 'endocc' => ' bytes' - ), $params)); - } - - /** - * Get quota information (used/allocated), in bytes. - * - * @return array An array with the following keys: - * 'limit' = Maximum quota allowed - * 'usage' = Currently used portion of quota (in bytes) - * @throws Horde_Exception - */ - public function getQuota() - { - if (!is_file($this->_params['logfile'])) { - throw new Horde_Exception(_("Unable to retrieve quota"), 'horde.error'); - } - - $full = file($this->_params['logfile']); - for (; $this->_params['taillines'] > 0; --$this->_params['taillines']) { - $tail[] = $full[count($full) - $this->_params['taillines']]; - } - - $uname = $_SESSION['imp']['user']; - $FTPmail = $this->_params['FTPmail']; - $virtline = preg_grep("[$uname: $FTPmail]", $tail); - $virtline = array_values($virtline); - $usage = substr($virtline[0], strpos($virtline[0], $this->_params['beginocc']) + strlen($this->_params['beginocc']), strpos($virtline[0], $this->_params['midocc'])); - $storage = substr($virtline[0], strpos($virtline[0], $this->_params['midocc']) + strlen($this->_params['midocc']), strpos($virtline[0], $this->_params['endocc'])); - - return array('usage' => $usage, 'limit' => $storage); - } - -} diff --git a/imp/lib/Quota/Maildir.php b/imp/lib/Quota/Maildir.php index 9a88930d8..990317df0 100644 --- a/imp/lib/Quota/Maildir.php +++ b/imp/lib/Quota/Maildir.php @@ -5,22 +5,17 @@ * expanded to be configurable to support storage or message limits in the * configuration array. * - * Requires the following parameter settings in imp/servers.php: + * You must configure this driver in imp/config/servers.php. The driver + * supports the following parameters: *
- * 'quota' => array(
- *     'driver' => 'maildir',
- *     'params' => array(
- *         'path' => '/path/to/users/Maildir'
- *         // TODO: Add config param for storage vs message quota
- *     )
- * );
- *
- * path - The path to the user's Maildir directory. You may use the
+ * path - (string) The path to the user's Maildir directory. You may use the
  *        two-character sequence "~U" to represent the user's account name,
  *        and the actual username will be substituted in that location.
  *        E.g., '/home/~U/Maildir/' or '/var/mail/~U/Maildir/'
  * 
* + * TODO: Add config param for storage vs message quota + * * Copyright 2007-2010 The Horde Project (http://www.horde.org/) * * See the enclosed file COPYING for license information (GPL). If you @@ -57,8 +52,7 @@ class IMP_Quota_Maildir extends IMP_Quota $full = $this->_params['path'] . '/maildirsize'; // Substitute the username in the string if needed. - $uname = $_SESSION['imp']['user']; - $full = str_replace('~U', $uname, $full); + $full = str_replace('~U', $GLOBALS['imp_imap']->ob()->getParam('username'), $full); // Read in the quota file and parse it, if possible. if (!is_file($full)) { diff --git a/imp/lib/Quota/Mdaemon.php b/imp/lib/Quota/Mdaemon.php index de53b4ef5..30c9dd5f2 100644 --- a/imp/lib/Quota/Mdaemon.php +++ b/imp/lib/Quota/Mdaemon.php @@ -2,9 +2,10 @@ /** * Implementation of the Quota API for MDaemon servers. * - * Parameters required: + * You must configure this driver in imp/config/servers.php. The driver + * supports the following parameters: *
- * 'app_location'  --  TODO
+ * 'app_location' - (string) Location of the application.
  * 
* * Copyright 2002-2010 The Horde Project (http://www.horde.org/) diff --git a/imp/lib/Quota/Mercury32.php b/imp/lib/Quota/Mercury32.php index 73d6a9dd1..4a4cc99a2 100644 --- a/imp/lib/Quota/Mercury32.php +++ b/imp/lib/Quota/Mercury32.php @@ -3,16 +3,10 @@ * Implementation of the Quota API for Mercury/32 IMAP servers. * For reading Quota, read size folder user. * - * Requires the following parameter settings in imp/servers.php: + * You must configure this driver in imp/config/servers.php. The driver + * supports the following parameters: *
- * 'quota' => array(
- *     'driver' => 'mercury32',
- *     'params' => array(
- *         'mail_user_folder' => 'c:/mercry/mail'
- *     )
- * );
- *
- * 'mail_user_folder' --  The path to folder mail mercury
+ * 'mail_user_folder' - (string) The path to folder mail mercury.
  * 
* ***************************************************************************** diff --git a/imp/lib/Quota/Sql.php b/imp/lib/Quota/Sql.php index 90d62aa10..95a326eac 100644 --- a/imp/lib/Quota/Sql.php +++ b/imp/lib/Quota/Sql.php @@ -3,34 +3,21 @@ * Implementation of the Quota API for servers keeping quota information in a * custom SQL database. * - * Driver must be configured in imp/config/servers.php. Parameters supported: + * You must configure this driver in imp/config/servers.php. The driver + * supports the following parameters: *
- * phptype     -- Database type to connect to
- * hostspec    -- Database host
- * username    -- User name for DB connection
- * password    -- Password for DB connection
- * database    -- Database name
- * query_quota -- SQL query which returns single row/column with user quota
- *                (in bytes). %u is replaced with current user name, %U with
- *                the user name without the domain part, %d with the domain.
- * query_used  -- SQL query which returns single row/column with user used
- *                space (in bytes). Placeholders are the same like in
- *                query_quota.
+ * query_quota - (string) SQL query which returns single row/column with user
+ *               quota (in bytes). %u is replaced with current user name, %U
+ *               with the user name without the domain part, %d with the
+ *               domain.
+ * query_used - (string) SQL query which returns single row/column with user
+ *              used space (in bytes). Placeholders are the same like in
+ *              query_quota.
  * 
* - * Example how to reuse Horde's global SQL configuration: - * - * 'quota' => array( - * 'driver' => 'sql', - * 'params' => array_merge( - * $GLOBALS['conf']['sql'], - * array( - * 'query_quota' => 'SELECT quota FROM quotas WHERE user = ?', - * 'query_used' => 'SELECT used FROM quotas WHERE user = ?' - * ) - * ) - * ), - * + * Additionally, the driver takes SQL connection parameters 'phptype', + * 'hostspec',' 'username', 'password', and 'database'. See + * horde/config/conf.php for further information on these parameters * * Copyright 2006-2007 Tomas Simonaitis * Copyright 2006-2010 The Horde Project (http://www.horde.org/) diff --git a/imp/templates/index/index-dimp.inc b/imp/templates/index/index-dimp.inc index bd2aceb22..f1415ae95 100644 --- a/imp/templates/index/index-dimp.inc +++ b/imp/templates/index/index-dimp.inc @@ -15,7 +15,7 @@ $has_blacklist = $registry->hasMethod('mail/blacklistFrom'); $has_whitelist = $registry->hasMethod('mail/whitelistFrom'); // Quota information -$show_quota = (isset($_SESSION['imp']['quota']) && is_array($_SESSION['imp']['quota'])); +$show_quota = (isset($_SESSION['imp']['imap']['quota']) && is_array($_SESSION['imp']['imap']['quota'])); // Get the list of available IMAP flags $flag_list = $injector->getInstance('IMP_Imap_Flags')->getList(array('imap' => true)); @@ -137,14 +137,14 @@ function _simpleButton($id, $text, $image, $nodisplay = false)
  • - + get('webroot', 'imp') . '/themes/graphics') ?>
  • - + get('webroot', 'imp') . '/themes/graphics') ?>
    diff --git a/imp/themes/screen-dimp.css b/imp/themes/screen-dimp.css index f73452e85..ed9d9f9ed 100644 --- a/imp/themes/screen-dimp.css +++ b/imp/themes/screen-dimp.css @@ -47,7 +47,6 @@ input { border: 1px #000 solid; margin-right: 2px; } -/* TODO? */ #quota .used img { display: inline; float: none; @@ -55,6 +54,9 @@ input { border-left: 1px #000 solid; height: 14px; } +.tabset li#quota { + border-top: 0; +} #logo { display: none; @@ -341,11 +343,12 @@ div.vpRowVert.flagUnseen { padding-left: 10px; } #sidebar span.iconSpan { + background-position: left center; + background-repeat: no-repeat; display: inline; float: left; - width: 20px; height: 100%; - background-repeat: no-repeat; + width: 20px; } #ctx_folder_sub span.contextImg, #ctx_folder_unsub span.contextImg, #ctx_folderopts_sub span.contextImg, #ctx_folderopts_unsub span.contextImg { background-image: url("graphics/folders/folder.png"); @@ -1021,11 +1024,6 @@ div.msgSubject span.treeImg { margin-left: 4px; margin-right: 0; } -#quota span.iconImg { - background-image: url("graphics/quotauncover.gif"); - width: 0; - margin-right: 0; -} #th_expand span.iconImg, #partlist_col, #msgloglist_col { background-image: url("graphics/arrow_collapsed.png"); cursor: pointer;