summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--program/include/rcube_imap.inc2
-rw-r--r--program/steps/mail/func.inc9
-rw-r--r--program/steps/mail/quotaimg.inc146
-rw-r--r--skins/default/mail.css3
-rw-r--r--skins/default/templates/mail.html2
5 files changed, 72 insertions, 90 deletions
diff --git a/program/include/rcube_imap.inc b/program/include/rcube_imap.inc
index 05de6773a..bcbea816e 100644
--- a/program/include/rcube_imap.inc
+++ b/program/include/rcube_imap.inc
@@ -1463,7 +1463,7 @@ class rcube_imap
function get_quota()
{
if ($this->get_capability('QUOTA'))
- return array('total' => 2048 * 1024, 'used' => 500 * 1024, 'percent' => 32); //iil_C_GetQuota($this->conn);
+ return iil_C_GetQuota($this->conn);
return FALSE;
}
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 986a4c955..0cd6652ad 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -633,10 +633,15 @@ function rcmail_quota_display($attrib)
// show quota as image (by Brett Patterson)
if ($attrib['display'] == 'image' && function_exists('imagegif'))
{
- $quota_text = sprintf('<img src="%s&amp;_action=quotaimg&amp;u=%s&amp;q=%d" alt="%s" width="102" height="15" />',
+ $attrib += array('width' => 100, 'height' => 14);
+ $quota_text = sprintf('<img src="%s&amp;_action=quotaimg&amp;u=%s&amp;q=%d&amp;w=%d&amp;h=%d" width="%d" height="%d" alt="%s" title="%s / %s" />',
$COMM_PATH,
$quota['used'], $quota['total'],
- $quota_text);
+ $attrib['width'], $attrib['height'],
+ $attrib['width'], $attrib['height'],
+ $quota_text,
+ show_bytes($quota["used"] * 1024),
+ show_bytes($quota["total"] * 1024));
}
}
else
diff --git a/program/steps/mail/quotaimg.inc b/program/steps/mail/quotaimg.inc
index 9cb228e87..643ae1c55 100644
--- a/program/steps/mail/quotaimg.inc
+++ b/program/steps/mail/quotaimg.inc
@@ -21,9 +21,10 @@
$used = ((isset($_GET['u']) && !empty($_GET['u'])) || $_GET['u']=='0')?(int)$_GET['u']:'??';
$quota = ((isset($_GET['q']) && !empty($_GET['q'])) || $_GET['q']=='0')?(int)$_GET['q']:'??';
+$width = empty($_GET['w']) ? 100 : (int)$_GET['w'];
+$height = empty($_GET['h']) ? 14 : (int)$_GET['h'];
-
-function genQuota($used, $total)
+function genQuota($used, $total, $width, $height)
{
/**
* Quota Display
@@ -52,30 +53,28 @@ function genQuota($used, $total)
**/
$unknown = false;
- $border = true;
+ $border = 0;
- $height = 15;
- $width = 102;
$font = 2;
- $padding = 1;
+ $padding = 0;
$limit['high'] = 70;
$limit['mid'] = 45;
$limit['low'] = 0;
// Fill Colors
- $color['fill']['high'] = '227, 23, 13'; // Near quota fill color
+ $color['fill']['high'] = '215, 13, 13'; // Near quota fill color
$color['fill']['mid'] = '126, 192, 238';// Mid-area of quota fill color
- $color['fill']['low'] = '50, 205, 50'; // Far from quota fill color
+ $color['fill']['low'] = '147, 225, 100'; // Far from quota fill color
// Background colors
- $color['bg']['OL'] = '238, 99, 99'; // Over limit bbackground
+ $color['bg']['OL'] = '215, 13, 13'; // Over limit bbackground
$color['bg']['Unknown'] = '238, 99, 99';// Unknown background
$color['bg']['quota'] = '255, 255, 255';// Normal quota background
// Misc. Colors
$color['border'] = '0, 0, 0';
- $color['text'] = '0, 0, 0';
+ $color['text'] = '102, 102, 102';
/****************************
@@ -91,106 +90,83 @@ function genQuota($used, $total)
$unknown = true;
}
+ $im = imagecreate($width, $height);
+
+ if($border)
+ {
+ list($r, $g, $b) = explode(',', $color['border']);
+ $borderc = imagecolorallocate($im, $r, $g, $b);
+ imageline($im, 0, 0, $width, 0, $borderc);
+ imageline($im, 0, $height-$border, 0, 0, $borderc);
+ imageline($im, $width-1, 0, $width-$border, $height, $borderc);
+ imageline($im, $width, $height-$border, 0, $height-$border, $borderc);
+ }
+
+ list($r, $g, $b) = explode(',', $color['text']);
+ $text = imagecolorallocate($im, $r, $g, $b);
+
if($unknown)
{
- $im = imagecreate($width, $height);
list($r, $g, $b) = explode(',', $color['bg']['Unknown']);
$background = imagecolorallocate($im, $r, $g, $b);
- list($r, $g, $b) = explode(',', $color['text']);
- $text = imagecolorallocate($im, $r, $g, $b);
-
- if($border)
- {
- list($r, $g, $b) = explode(',', $color['border']);
- $border = imagecolorallocate($im, $r, $g, $b);
- imageline($im, 0, 0, $width, 0, $border);
- imageline($im, 0, $height-1, 0, 0, $border);
- imageline($im, $width-1, 0, $width-1, $height, $border);
- imageline($im, $width, $height-1, 0, $height-1, $border);
- }
+ imagefilledrectangle($im, 0, 0, $width, $height, $background);
$string = 'Unknown';
-
- $mid = floor((100-(strlen($string)*imagefontwidth($font)))/2)+1;
-
+ $mid = floor(($width-(strlen($string)*imagefontwidth($font)))/2)+1;
imagestring($im, $font, $mid, $padding, $string, $text);
- header('Content-type: image/gif');
- imagegif($im);
- imagedestroy($im);
- exit;
}
-
- if($used > $total)
+ else if($used > $total)
{
- $im = imagecreate($width, $height);
list($r, $g, $b) = explode(',', $color['bg']['OL']);
$background = imagecolorallocate($im, $r, $g, $b);
- list($r, $g, $b) = explode(',', $color['text']);
- $text = imagecolorallocate($im, $r, $g, $b);
- list($r, $g, $b) = explode(',', $color['border']);
- $border = imagecolorallocate($im, $r, $g, $b);
-
- imageline($im, 0, 0, $width, 0, $border);
- imageline($im, 0, $height-1, 0, 0, $border);
- imageline($im, $width-1, 0, $width-1, $height, $border);
- imageline($im, $width, $height-1, 0, $height-1, $border);
+ imagefilledrectangle($im, 0, 0, $width, $height, $background);
$string = 'Over Limit';
-
- $mid = floor((100-(strlen($string)*imagefontwidth($font)))/2)+1;
-
+ $mid = floor(($width-(strlen($string)*imagefontwidth($font)))/2)+1;
imagestring($im, $font, $mid, $padding, $string, $text);
-
- header('Content-type: image/gif');
- imagegif($im);
- exit;
}
-
- $quota = ($used==0)?0:(round($used/$total, 2)*100);
-
- $im = imagecreate($width, $height);
- list($r, $g, $b) = explode(',', $color['bg']['quota']);
- $background = imagecolorallocate($im, $r, $b, $g);
- list($r, $g, $b) = explode(',', $color['border']);
- $border = imagecolorallocate($im, $r, $g, $b);
- list($r, $g, $b) = explode(',', $color['text']);
- $text = imagecolorallocate($im, $r, $g, $b);
- if($quota >= $limit['high'])
+ else
{
- list($r, $g, $b) = explode(',', $color['fill']['high']);
- $fill = imagecolorallocate($im, $r, $g, $b);
- }
- elseif($quota >= $limit['mid'])
- {
- list($r, $g, $b) = explode(',', $color['fill']['mid']);
- $fill = imagecolorallocate($im, $r, $g, $b);
- }
- else // if($quota >= $limit['low'])
- {
- list($r, $g, $b) = explode(',', $color['fill']['low']);
- $fill = imagecolorallocate($im, $r, $g, $b);
- }
+ list($r, $g, $b) = explode(',', $color['bg']['quota']);
+ $background = imagecolorallocate($im, $r, $b, $g);
+ imagefilledrectangle($im, 0, 0, $width, $height, $background);
+
+ $quota = ($used==0)?0:(round($used/$total, 2)*100);
+ if($quota >= $limit['high'])
+ {
+ list($r, $g, $b) = explode(',', $color['fill']['high']);
+ $fill = imagecolorallocate($im, $r, $g, $b);
+ }
+ elseif($quota >= $limit['mid'])
+ {
+ list($r, $g, $b) = explode(',', $color['fill']['mid']);
+ $fill = imagecolorallocate($im, $r, $g, $b);
+ }
+ else // if($quota >= $limit['low'])
+ {
+ list($r, $g, $b) = explode(',', $color['fill']['low']);
+ $fill = imagecolorallocate($im, $r, $g, $b);
+ }
- imagefilledrectangle($im, 1, 0, $quota, $height-2, $fill);
-
-
- imageline($im, 0, 0, $width-2, 0, $border);
- imageline($im, $width-2, 0, $width-2, $height, $border);
- imageline($im, $width-2, $height-1, 0, $height-1, $border);
- imageline($im, 0, $height, 0, 0, $border);
-
+ $quota_width = $quota / 100 * $width;
+ imagefilledrectangle($im, $border, 0, $quota, $height-2*$border, $fill);
- $string = $quota.'%';
- $mid = floor((100-(strlen($string)*imagefontwidth($font)))/2)+1;
- imagestring($im, $font, $mid, $padding, $string, $text); // Print percent in black
+ $string = $quota.'%';
+ $mid = floor(($width-(strlen($string)*imagefontwidth($font)))/2)+1;
+ imagestring($im, $font, $mid, $padding, $string, $text); // Print percent in black
+ }
header('Content-Type: image/gif');
+ header("Expires: ".gmdate("D, d M Y H:i:s", mktime()+86400)." GMT");
+ header("Cache-Control: ");
+ header("Pragma: ");
+
imagegif($im);
imagedestroy($im);
}
-genQuota($used, $quota);
+genQuota($used, $quota, $width, $height);
exit;
?> \ No newline at end of file
diff --git a/skins/default/mail.css b/skins/default/mail.css
index 95e404691..d94d6a1f8 100644
--- a/skins/default/mail.css
+++ b/skins/default/mail.css
@@ -564,7 +564,8 @@ html>body*#quicksearchbar #quicksearchbox { width: 180px; top:0px; right: 1px; l
#quotadisplay img
{
vertical-align: middle;
- padding-left: 4px;
+ margin-left: 4px;
+ border: 1px solid #666666;
}
diff --git a/skins/default/templates/mail.html b/skins/default/templates/mail.html
index 962a298ab..663fdfd88 100644
--- a/skins/default/templates/mail.html
+++ b/skins/default/templates/mail.html
@@ -57,7 +57,7 @@
<roundcube:button command="select-all" label="all" classAct="active" />&nbsp;
<roundcube:button command="select-all" prop="unread" label="unread" classAct="active" />&nbsp;
<roundcube:button command="select-none" label="none" classAct="active" /> &nbsp;&nbsp;&nbsp;
-<roundcube:label name="quota" />: <roundcube:object name="quotaDisplay" display="text" id="quotadisplay" />
+<roundcube:label name="quota" />: <roundcube:object name="quotaDisplay" display="image" width="120" id="quotadisplay" />
</div>
</body>