\documentclass{article}
\usepackage{ulem}
\usepackage{graphicx}
\usepackage{hyperref}
\pagestyle{headings}
\begin{document}
To enable quota using unix 'quota' command.

Enable Quota on your server, assign the required quota to all users in /home folder.

Add the following lines in your horde/imp/config/servers.php as a part of  mail server configuration.

<pre><code class="language-php">
    'quota' => array(
    'driver' => 'command',
      'params' => array(
         'quota\_path' => '/usr/bin/quota',
          'grep\_path'  => '/bin/grep'
      )
  ),
</code></pre>
For newer 'quota' command follow the instructions given on this <a href="http://lists.horde.org/archives/dev/Week-of-Mon-20040126/012982.html">link</a>. I have tested that on RHEL 3, it works fine. I am not sure if further work has been done on new format 'quota' command, in case anyone knows of new improved version on the list archive, please update the link here.

Here is another lengthy hack that displays quota on a server not supporting quota, like dovecot or any mail server without using the built in quota feature(If you find this simpler).

Edit your /etc/sudoer, add the following lines. Replace apache with whatever your httpd/apache user is. RHEL/Fedora user is apache.

<pre><code class="language-bash">
apache  ALL = NOPASSWD: /usr/bin/du
apache ALL = NOPASSWD: /bin/ls
</code></pre>
create a folder 'quota' on your server '/' partition

<pre><code class="language-bash">
mkdir /quota
</code></pre>
to assign quota to any user

<pre><code class="language-bash">
echo "10000" > /quota/username
</code></pre>
Change permissions of /quota folder and all the files created in it to allow apache to read it.

This would give 10MB quota to a user. Give whatever you wish to assign.

Create the following file

/var/www/html/horde/quota.php

<pre><code class="language-php">
<?php
\{

    \$user=Auth::getAuth();
    \$usage = `sudo du -s /home/\$user/mail | cut -d "/" -f 1` + `sudo du -s /var/spool/mail/\$user | cut -d "/" -f 1` ;
    \$usedmb = round(\$usage / 1000);
    \$quota = `cat /quota/\$user`+ 1;
    \$quotamb = round(\$quota / 1000);
    \$percent = round(\$usage * 100 / \$quota);
        if (\$quota > 1) \{
             echo '<table width="100\%" border="0" cellpadding="0" cellspacing="0"><tr><td class=
"item"><table border="0" cellspacing="0" cellpadding="0" width="100\%"><tr>';
             echo '<td align="left" class="header">Login: ' .  \$user . '</td>';
             echo '<td align="right" class="header">';
             echo "Quota Used \$usedmb MB of \$quotamb MB (\$percent \%)";
             echo '</td></tr></table></td></tr></table>';
        \}

if (\$percent >= 100 \&\& \$quota > 2) \{
             echo '<script language="JavaScript" type="text/javascript"><!--
alert("QUOTA EXCEEDED, DELETE EMAILS TO CONTINUE THE USE OF EMAIL FACILITY")
// -->
</script>';\}
if (\$percent >= 80 \&\& \$quota > 2) \{
             echo '<script language="JavaScript" type="text/javascript"><!--
alert("You are nearing your mailbox quota limit, please delete \& purge
emails to avoid any inconvenience.")
// -->
</script>';\}
\}
</code></pre>
Change the above reflecting your mailserver's folder locations. Above is for dovecot on RHEL 3, with mails in /home/username/mail and /var/spool/mail/username.

Add this in horde/imp/templates/common-headers.inc (line 27, 28,29)

<pre><code class="language-php">
\$page\_title = \$GLOBALS['registry']->get('name');
if (!empty(\$title)) \$page\_title .= ' :: ' . \$title;
if (!empty(\$refresh\_time) \&\& !empty(\$refresh\_url)) \{
    echo "<meta http-equiv="refresh" content="\$refresh\_time;url=\$refresh\_url" />n";
\}
Horde::includeScriptFiles();
?>
<title><?php echo htmlspecialchars(\$page\_title) ?></title>

//--->Add the following here <----

<?php
include\_once HORDE\_BASE . '/quota.php';
?>

//---end---

<link href="<?php echo \$GLOBALS['registry']->getImageDir()?>/favicon.ico" rel="SHORTCUT ICON" />
<?php if (isset(\$mailbox\_url)): ?>
</code></pre>
Using du instead of using cyrus quota on large number of mailboxes is very inefficient, this hack has just advantages: it does not depend on OS/mail server quota. Usage of only mailboxes can be counted regardless of the partitions they are on. Quota assigned are for mailboxes only, they do not apply anywhere else.

\end{document}
