[imp] Total size mailbox

Hobbs, Richard hobbs at mongeese.co.uk
Fri Aug 15 08:03:42 PDT 2003


Hello,

OK... i enabled the quota stuff, but i'm getting an error on each page...

Warning: imap_close(): supplied argument is not a valid imap resource in
/hsphere/local/home/fishspon/webmail.mongeese.co.uk/horde/imp/config/conf.php on
line 399

Here's what i have in conf.php:

======================================================================

// If this is set to a function name, that function will be used
// to show the user's quota usage on the mailbox page.
// See the 'imp_show_quota' function below for an example.
$conf['hooks']['quota'] = 'imp_show_quota';

/* Gets the quota usage from the imap server. $imap_admin &
 * $imap_passwd must be set to fit your own settings. This works
 * with the Cyrus imap server and the Courier imap server > 1.3.12. 
 * Note the necessary changes for the Courier server in the comments.
 */
if (!function_exists('imp_show_quota')) {
   function imp_show_quota ($imp) {
        $quota_html = '';
        $imap_admin = 'admin';
        $imap_passwd = 'password';   
        // Use the following two lines instead for Courier.
        // $imap_admin = $imp['user'];
        // $imap_passwd = Secret::read(Secret::getKey('imp'), $imp['pass']);

        $stream = @imap_open(IMP::serverString(), $imap_admin, $imap_passwd,
OP_HALFOPEN);
        $quota = @imap_get_quota($stream, 'user.' . $imp['user']);
        // Use the following line instead for Courier.
        // $quota = @imap_get_quota($stream, 'ROOT');
        imap_close($stream);

        if (is_array($quota) && $quota['limit'] != 0) {
            $taken   = $quota['usage'] / 1024.0;
            $total   = $quota['limit'] / 1024.0;
            $percent = $taken * 100 / $total;
            if ($percent >= 90) {
                $class = 'quotaalert';
            } elseif ($percent >= 75) {
                $class = 'quotawarn';
            } else {
                $class = 'control';
            }

            $quota_html = '<table width="100%" border="0" cellpadding="0"
cellspacing="0"><tr><td class="item">'
                          . '<table border="0" cellspacing="2" cellpadding="2"
width="100%"><tr><td align="center" class="' . $class . '">'
                          . sprintf("%.2fMB / %.2fMB  (%.2f%%)", $taken, $total,
$percent)
                          . '</td></tr></table></td></tr></table>';
        }
        return $quota_html;
    }
}

======================================================================

Any ideas??

Thanks,
Hobbs.


Quoting "Hobbs, Richard" <hobbs at mongeese.co.uk>:

> Hello,
> 
> I read the docs and i've found the settings, but i can't figure something
> out...
> 
> it says:
> 
> > // If this is set to a function name, that function will be used
> > // to show the user's quota usage on the mailbox page.
> > // See the 'imp_show_quota' function below for an example.
> > $conf['hooks']['quota'] = '';
> 
> Does this need to be the command that's actually sent to the IMAP server
> then??
> 
> > /* Gets the quota usage from the imap server. $imap_admin &
> >  * $imap_passwd must be set to fit your own settings. This works
> >  * with the Cyrus imap server and the Courier imap server > 1.3.12.
> >  * Note the necessary changes for the Courier server in the comments.
> >  */
> > // if (!function_exists('imp_show_quota')) {
> > //    function imp_show_quota ($imp) {
> > //         $quota_html = '';
> >> <<<<< snip >>>>>
> 
> if the "imp_show_quota" function exists... i assume this will exist as soon
> as i
> fill in the first one, right??
> 
> i never grasped this whole coding thing unfortunately...
> 
> thanks for ur help ppl :-)
> 
> Hobbs.
> 
> 
> Quoting Jan Schneider <jan at horde.org>:
> 
> > Zitat von "Hobbs, Richard" <hobbs at mongeese.co.uk>:
> > 
> > > Hello,
> > >
> > > Is it a module to install?
> > 
> > No.
> > 
> > >  |
> > >  |- if so... what's it called?
> > >  |
> > >  |- if not... how do i enable it?
> > 
> > Read the docs and config files.
> > 
> > Jan.
> > 
> > --
> > http://www.horde.org - The Horde Project
> > http://www.ammma.de - discover your knowledge
> > http://www.tip4all.de - Deine private Tippgemeinschaft
> > 
> 
> 
> -- 
>   _-'`-_-'`-_-'`-_-'`-_-'`-_-'`-_-'`-_-'`-_-'`-_-'`-_-'`-_-'`-_-'`-_
>   |                                                                |
>   | Richard Hobbs    hobbs at mongeese.co.uk    http://mongeese.co.uk |
>   |                                         http://unixforum.co.uk |
>   |----------------------------------------------------------------|
>   | Registered Linux User: 313906          (http://counter.li.org) |
>   |----------------------------------------------------------------|
>   | "There's only one way of life, and that's your own"            |
>   |                                                  The Levellers |
>   '`-_-'`-_-'`-_-'`-_-'`-_-'`-_-'`-_-'`-_-'`-_-'`-_-'`-_-'`-_-'`-_-'
> 
> ______________________________________________________________________
> Send all your jokes to : jokes at fishsponge.co.uk !!
> To subscribe, email    : jokes-subscribe at fishsponge.co.uk
> 
> -- 
> IMP mailing list
> Frequently Asked Questions: http://horde.org/faq/
> To unsubscribe, mail: imp-unsubscribe at lists.horde.org
> 


-- 
  _-'`-_-'`-_-'`-_-'`-_-'`-_-'`-_-'`-_-'`-_-'`-_-'`-_-'`-_-'`-_-'`-_
  |                                                                |
  | Richard Hobbs    hobbs at mongeese.co.uk    http://mongeese.co.uk |
  |                                         http://unixforum.co.uk |
  |----------------------------------------------------------------|
  | Registered Linux User: 313906          (http://counter.li.org) |
  |----------------------------------------------------------------|
  | "There's only one way of life, and that's your own"            |
  |                                                  The Levellers |
  '`-_-'`-_-'`-_-'`-_-'`-_-'`-_-'`-_-'`-_-'`-_-'`-_-'`-_-'`-_-'`-_-'

______________________________________________________________________
Send all your jokes to : jokes at fishsponge.co.uk !!
To subscribe, email    : jokes-subscribe at fishsponge.co.uk


More information about the imp mailing list