* @package plugins * @subpackage ldapfolderinfo * @version $Id: quota_display.inc.php,v 1.2 2006/11/22 13:21:23 avel Exp $ */ /** * Display Quota usage in left frame */ function ldapfolderinfo_display_quota_usage_do() { global $data_dir, $username, $key, $imapServerAddress, $imapPort, $imap_general, $imap_stream, $imapConnection, $sqimap_capabilities, $UseSeparateImapConnection, $color; include( SM_PATH . 'plugins/ldapfolderinfo/config.php'); include_once( SM_PATH . 'plugins/ldapfolderinfo/include/quota.inc.php'); bindtextdomain ('ldapfolderinfo', SM_PATH . 'plugins/ldapfolderinfo/locale'); textdomain ('ldapfolderinfo'); // Detect if we have already connected to IMAP or not. // Also check if we are forced to use a separate IMAP connection if ((!isset($imap_stream) && !isset($imapConnection)) || $UseSeparateImapConnection) { $stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 10); $previously_connected = false; } elseif (isset($imapConnection)) { $stream = $imapConnection; $previously_connected = true; } else { $previously_connected = true; $stream = $imap_stream; } if(! sqimap_capability($stream, 'QUOTA', true)) { // No Quota Information; don't display anything. sqimap_logout($stream); return; } $quota_status = sqimap_get_quota_ldapfolderinfo($stream, 'INBOX', $taken, $total); if($quota_status == QUOTA_NOT_SET) { echo _("Quota not set."); } elseif($quota_status = QUOTA_DEFINED_IN_PARENT) { echo _("Quota is defined elsewhere"); } elseif ($quota_status = QUOTA_SET) { if($total != 0) { $percent = number_format(($taken/$total) * 100, 0); } else { $percent = 0; } $width = getPref($data_dir, $username, 'left_size')-40; $real_width = number_format(($taken/$total) * $width - 2*$edge_width, 0); $quota = number_format((($total *1024) - 1023) / 1000000, 1); if($percent>100) { echo "\n"; setPref($data_dir, $username, "move_to_trash", 0); } // if($percent >= $warn_percent) $fontcolorstring = " color=#FF0000"; echo ''; echo ''. '\n"; echo '
' . sprintf ( _("Usage: %s%% of %s MB"), $percent, $quota) . "\n" . "
'; echo ''; if($taken == 0 && $total == 0) { echo ''. _( ' . _("Locked"); } elseif ($taken > 0 && $total == 0) { echo ''. _( '. _("Locked") .' - '. _("Overquota"); } elseif ($taken > $total) { echo ''. _( ' . ''. _("Overquota") . ' ('.$percent.'%)'; } else { echo ''. ''. ''; if ($percent > 80) { echo '
'.
                _( '. ''. _("Critical!") .' '; } } echo '

'; } if (!$previously_connected) sqimap_logout($stream); bindtextdomain('squirrelmail', SM_PATH . 'locale'); textdomain('squirrelmail'); } /** * Display Quota usage with given parameters * * @param $taken str Where the quota data will be stored * @param $total str Where the quota data will be stored * @return string */ function display_quota_usage_per_folder($taken, $total) { global $data_dir, $username, $color; global $use_pixmap, $height, $left_image, $right_image, $middle_image, $width_test; if($taken== 0 && $total == 0) { echo 'Post Locked'; return; } elseif ($taken > 0 && $total == 0) { echo 'Post Locked (overquota)'; return; } elseif ($taken > $total) { $percent = number_format(($taken/$total) * 100, 0); echo 'Warning! ' . _("Overquota!") . ' ('.$percent.'%)'; return; } $percent = number_format(($taken/$total) * 100, 0); $width = getPref($data_dir, $username, 'left_size') + 10; $real_width = number_format(($taken/$total) * $width, 0); $quota = number_format((($total *1024) - 1023) / 1000000, 1); // if($percent >= $warn_percent) $fontcolorstring = " color=#FF0000"; echo ''; echo ''; echo '\n"; echo "
'; echo "
"; if ($percent > 80) { echo ' '. _( '; } echo "" . sprintf( _("Used %s%% quota of %s MB"), $percent, $quota) . "\n"; if ($percent > 80) { echo ""; } echo "
\n"; echo "

\n"; } ?>