* 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
*
* ((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 ***
$quota = $this->_getQuota();
if (!is_null($quota)) {
- $result['quota'] = $quota;
+ $result->quota = $quota;
}
return $result;
*/
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'])
+ );
}
}
*/
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);
* 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:
+ * <pre>
+ * '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.
+ * </pre>
*
* Copyright 2002-2010 The Horde Project (http://www.horde.org/)
*
<?php
/**
* Implementation of IMP_Quota API for a generic hook function. This
- * requires hook_get_quota to be set in config/hooks.php . The
- * function takes an array as argument and returns an array where the
- * first item is the disk space used in bytes and the second the
- * maximum diskspace in bytes. See there for an example.
+ * requires the quota hook to be set in config/hooks.php.
*
- * You must configure this driver in horde/imp/config/servers.php. The
- * driver supports the following parameters:
- * 'params' => 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:
+ * <pre>
+ * 'params' - (array) Parameters to pass to the quota function.
+ * </pre>
*
* Copyright 2002-2010 The Horde Project (http://www.horde.org/)
*
/**
* 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
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
+ );
}
}
+++ /dev/null
-<?php
-/**
- * Implementation of the Quota API for servers where IMAP Quota is not
- * supported, but it appears in the servers messages log for the IMAP
- * server.
- *
- * Requires the following parameter settings in imp/servers.php:
- * <pre>
- * '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.
- * </pre>
- *
- * 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 <email@teletechnics.co.nz>
- * @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);
- }
-
-}
* 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:
* <pre>
- * '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/'
* </pre>
*
+ * 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
$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)) {
/**
* 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:
* <pre>
- * 'app_location' -- TODO
+ * 'app_location' - (string) Location of the application.
* </pre>
*
* Copyright 2002-2010 The Horde Project (http://www.horde.org/)
* 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:
* <pre>
- * '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.
* </pre>
*
*****************************************************************************
* 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:
* <pre>
- * 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.
* </pre>
*
- * Example how to reuse Horde's global SQL configuration:
- * <code>
- * '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 = ?'
- * )
- * )
- * ),
- * </code>
+ * 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 <haden@homelan.lt>
* Copyright 2006-2010 The Horde Project (http://www.horde.org/)
$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));
<?php endforeach; ?>
<?php if ($show_quota): ?>
<li id="quota">
- <span class="used"><span class="iconImg"></span></span>
+ <span class="used"><?php echo Horde::img('quotauncover.gif', '', '', $registry->get('webroot', 'imp') . '/themes/graphics') ?></span>
</li>
<?php endif; ?>
</ul>
</div>
<?php elseif ($show_quota): ?>
<div id="quota">
- <span class="used"><span class="iconImg"></span></span>
+ <span class="used"><?php echo Horde::img('quotauncover.gif', '', '', $registry->get('webroot', 'imp') . '/themes/graphics') ?></span>
</div>
<?php endif; ?>
</div>
border: 1px #000 solid;
margin-right: 2px;
}
-/* TODO? */
#quota .used img {
display: inline;
float: none;
border-left: 1px #000 solid;
height: 14px;
}
+.tabset li#quota {
+ border-top: 0;
+}
#logo {
display: none;
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");
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;