[dev] [PATCH] Adding quota info to IMP summary block
Etienne Goyer
etienne.goyer at linuxquebec.com
Wed Oct 1 06:31:34 PDT 2003
Here is included a newer patch that is a bit cleaner and fix formatting
issue with the first one. If this is uncommitable, please tell so I can
fix it (or drop the idea entirely).
Thanks !
On Fri, Sep 26, 2003 at 11:30:19AM -0400, Etienne Goyer wrote:
> As discussed earlier this week, here is a patch that add quota
> information to the summary block from IMP. Hopefully, this is clean
> enough to be applied. If not, please advise and I will rework it.
>
> Also, I posted a block that displayed the user email address as
> retrieved from the from_addr preference. Would it be interesting to add
> it, or it is too trivial to be incorporated ?
--
Etienne Goyer Linux Québec Technologies Inc.
http://www.LinuxQuebec.com etienne.goyer at linuxquebec.com
-------------- next part --------------
--- summary.php.orig Tue Sep 23 14:25:28 2003
+++ summary.php Wed Oct 1 09:24:37 2003
@@ -74,6 +74,36 @@
}
$html .= '</td><td> </td><td>';
$html .= !empty($sts->unseen) ? '<b>' . $sts->unseen . '</b>' : '0';
+ $html .= '</td><td align="right">';
+ // Quota info, if available
+ if (isset($_SESSION['imp'])) {
+ $imp = $_SESSION['imp'];
+ if (isset($imp['quota']) && is_array($imp['quota'])) {
+ require_once IMP_BASE . '/lib/Quota.php';
+ $quotaDriver = &IMP_Quota::singleton($imp['quota']['driver'], $imp['quota']['params']);
+ if ($quotaDriver !== false) {
+ $quota = $quotaDriver->getQuota();
+ if (!PEAR::isError($quota) and isset($quota['usage']) and isset($quota['limit'])) {
+ $message = '';
+ if ($quota['limit'] != 0) {
+ $quota['usage'] = $quota['usage'] / (1024 * 1024.0);
+ $quota['limit'] = $quota['limit'] / (1024 * 1024.0);
+ $percent = ($quota['usage'] * 100) / $quota['limit'];
+ if ($percent >= 90) {
+ $message .= '<font color="red">';
+ }
+ $message .= sprintf(_("Quota status: %.2fMB / %.2fMB (%.2f%%)"), $quota['usage'], $quota['limit'], $percent);
+ if ($percent >= 90) {
+ $message .= '</font>';
+ }
+ } else {
+ $message = sprintf(_("Quota status: NO LIMIT"));
+ }
+ $html .= $message;
+ }
+ }
+ }
+ }
$html .= '</td></tr>';
}
}
More information about the dev
mailing list