[dev] [PATCH] Adding quota info to IMP summary block

Etienne Goyer etienne.goyer at linuxquebec.com
Fri Sep 26 08:30:19 PDT 2003


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	Fri Sep 26 11:25:55 2003
@@ -66,14 +66,43 @@
                         $url = Horde::addParameter($url, 'mailbox', $folder);
                         $html .= '<tr class="text" onmouseover="javascript:style.backgroundColor=\'' . $css['.text-hi']['background-color'] . '\'; style.cursor=\'pointer\';" onmouseout="javascript:style.backgroundColor=\'' . $css['.text']['background-color'] . '\'" onclick="self.location=\'' . $url . '\'"><td>';
                         if (!empty($sts->unseen)) {
-                            $html .= '<b>';
+                            $html .= '<b>&nbsp;&nbsp;&nbsp;';
                         }
                         $html .= Horde::link($url, IMP::displayFolder($folder)) . IMP::displayFolder($folder) . '</a>';
                         if (!empty($sts->unseen)) {
-                            $html .= '</b>';
+                            $html .= '</b>&nbsp;&nbsp;&nbsp;';
+                        }
+                        $html .= '</td><td>' . !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><td>&nbsp;&nbsp;&nbsp;</td><td>';
-                        $html .= !empty($sts->unseen) ? '<b>' . $sts->unseen . '</b>' : '0';
                         $html .= '</td></tr>';
                     }
                 }


More information about the dev mailing list