Fix display of quota image/text after a remote command.

release-0.6
svncommit 18 years ago
parent 04d6304b4d
commit 23796ec290

@ -314,6 +314,9 @@ if ($_task=='mail')
if ($_action=='quotaimg') if ($_action=='quotaimg')
include('program/steps/mail/quotaimg.inc'); include('program/steps/mail/quotaimg.inc');
if ($_action=='quotadisplay')
include('program/steps/mail/quotadisplay.inc');
// make sure the message count is refreshed // make sure the message count is refreshed
$IMAP->messagecount($_SESSION['mbox'], 'ALL', TRUE); $IMAP->messagecount($_SESSION['mbox'], 'ALL', TRUE);

@ -3040,10 +3040,14 @@ function rcube_webmail()
}; };
// replace content of quota display // replace content of quota display
this.set_quota = function(text) this.set_quota = function()
{ {
if (this.gui_objects.quotadisplay) if (this.gui_objects.quotadisplay &&
this.gui_objects.quotadisplay.innerHTML = text; this.gui_objects.quotadisplay.attributes.getNamedItem('display') &&
this.gui_objects.quotadisplay.attributes.getNamedItem('id'))
this.http_request('quotadisplay', '_display='+
this.gui_objects.quotadisplay.attributes.getNamedItem('display').nodeValue+
'&_id='+this.gui_objects.quotadisplay.attributes.getNamedItem('id').nodeValue, false);
}; };

@ -634,7 +634,7 @@ function rcmail_messagecount_display($attrib)
function rcmail_quota_display($attrib) function rcmail_quota_display($attrib)
{ {
global $IMAP, $OUTPUT, $JS_OBJECT_NAME, $COMM_PATH; global $OUTPUT, $JS_OBJECT_NAME, $COMM_PATH;
if (!$attrib['id']) if (!$attrib['id'])
$attrib['id'] = 'rcmquotadisplay'; $attrib['id'] = 'rcmquotadisplay';
@ -642,7 +642,18 @@ function rcmail_quota_display($attrib)
$OUTPUT->add_script(sprintf("%s.gui_object('quotadisplay', '%s');", $JS_OBJECT_NAME, $attrib['id'])); $OUTPUT->add_script(sprintf("%s.gui_object('quotadisplay', '%s');", $JS_OBJECT_NAME, $attrib['id']));
// allow the following attributes to be added to the <span> tag // allow the following attributes to be added to the <span> tag
$attrib_str = create_attrib_string($attrib, array('style', 'class', 'id')); $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id', 'display'));
$out = '<span' . $attrib_str . '>';
$out .= rcmail_quota_content($attrib['display']);
$out .= '</span>';
return $out;
}
function rcmail_quota_content($display)
{
global $IMAP, $COMM_PATH;
if (!$IMAP->get_capability('QUOTA')) if (!$IMAP->get_capability('QUOTA'))
$quota_text = rcube_label('unknown'); $quota_text = rcube_label('unknown');
@ -654,9 +665,9 @@ function rcmail_quota_display($attrib)
$quota["percent"]); $quota["percent"]);
// show quota as image (by Brett Patterson) // show quota as image (by Brett Patterson)
if ($attrib['display'] == 'image' && function_exists('imagegif')) if ($display == 'image' && function_exists('imagegif'))
{ {
$attrib += array('width' => 100, 'height' => 14); $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" />', $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, $COMM_PATH,
$quota['used'], $quota['total'], $quota['used'], $quota['total'],
@ -670,11 +681,7 @@ function rcmail_quota_display($attrib)
else else
$quota_text = rcube_label('unlimited'); $quota_text = rcube_label('unlimited');
return $quota_text;
$out = '<span' . $attrib_str . '>';
$out .= $quota_text;
$out .= '</span>';
return $out;
} }

@ -0,0 +1,29 @@
<?php
/*
+-----------------------------------------------------------------------+
| program/steps/mail/quotadisplay.inc |
| |
| This file is part of the RoundCube Webmail client |
| Copyright (C) 2005, RoundCube Dev. - Switzerland |
| Licensed under the GNU GPL |
| |
| PURPOSE: |
| Remote call to return the quota image or text |
| |
+-----------------------------------------------------------------------+
| Author: Robin Elfrink <robin@15augustus.nl> |
+-----------------------------------------------------------------------+
$Id$
*/
$display = isset($_GET['_display']) ? $_GET['_display'] : 'text';
$id = isset($_GET['_id']) ? $_GET['_id'] : 'rcmquotadisplay';
$quota = rcmail_quota_content($display);
$command = sprintf("this.gui_objects.%s.innerHTML = '%s';\n", $id, $quota);
rcube_remote_response($command);
exit;
?>
Loading…
Cancel
Save