Changeset 7415c02 in github for program/steps/mail/func.inc


Ignore:
Timestamp:
Oct 24, 2009 3:09:23 PM (4 years ago)
Author:
alecpl <alec@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
06e0757
Parents:
1d7e4d3
Message:
  • Fix quota indicator issues by content generation on client-size instead of bin/quotaimage.php: better performance, better styling posibilities (#1486197, #1486220)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • program/steps/mail/func.inc

    rb6673c4e r7415c02  
    518518 
    519519  $OUTPUT->add_gui_object('quotadisplay', $attrib['id']); 
    520  
    521   return html::span($attrib, rcmail_quota_content(NULL, $attrib)); 
     520   
     521  $quota = rcmail_quota_content(NULL, $attrib); 
     522   
     523  if (is_array($quota)) { 
     524    $OUTPUT->add_script('$(document).ready(function(){ 
     525        rcmail.set_quota('.json_serialize($quota).')});', 'foot'); 
     526    $quota = ''; 
     527    } 
     528   
     529  return html::span($attrib, $quota); 
    522530  } 
    523531 
     
    529537  $display = isset($_SESSION['quota_display']) ? $_SESSION['quota_display'] : ''; 
    530538 
    531   if (is_array($quota) && !empty($quota['used']) && !empty($quota['total'])) 
    532     { 
    533       if (!isset($quota['percent'])) 
    534         $quota['percent'] = $quota['used'] / $quota['total']; 
    535     } 
    536   elseif (!$IMAP->get_capability('QUOTA')) 
    537     return rcube_label('unknown'); 
    538   else 
    539     $quota = $IMAP->get_quota(); 
     539  if (empty($quota)) { 
     540    if (!$IMAP->get_capability('QUOTA')) 
     541      return rcube_label('unknown'); 
     542    else  
     543      $quota = $IMAP->get_quota(); 
     544    } 
    540545 
    541546  if ($quota && !($quota['total']==0 && $RCMAIL->config->get('quota_zero_as_unlimited'))) 
    542547    { 
    543     $quota_text = sprintf('%s / %s (%.0f%%)', 
    544                           show_bytes($quota['used'] * 1024), 
    545                           show_bytes($quota['total'] * 1024), 
    546                           $quota['percent']); 
    547  
    548     // show quota as image (by Brett Patterson) 
    549     if ($display == 'image' && function_exists('imagegif')) 
    550       { 
    551       if (!$attrib['width']) 
    552         $attrib['width'] = isset($_SESSION['quota_width']) ? $_SESSION['quota_width'] : 100; 
    553       else 
    554         $_SESSION['quota_width'] = $attrib['width']; 
    555  
    556       if (!$attrib['height']) 
    557         $attrib['height'] = isset($_SESSION['quota_height']) ? $_SESSION['quota_height'] : 14; 
    558       else 
    559         $_SESSION['quota_height'] = $attrib['height']; 
    560              
    561       $quota_text = sprintf('<img src="./bin/quotaimg.php?u=%s&amp;q=%d&amp;w=%d&amp;h=%d" width="%d" height="%d" alt="%s" title="%s / %s" />', 
    562                             $quota['used'], $quota['total'], 
    563                             $attrib['width'], $attrib['height'], 
    564                             $attrib['width'], $attrib['height'], 
    565                             $quota_text, 
    566                             show_bytes($quota['used'] * 1024), 
    567                             show_bytes($quota['total'] * 1024)); 
     548    $quota_result = sprintf('%s / %s (%.0f%%)', 
     549        show_bytes($quota['used'] * 1024), show_bytes($quota['total'] * 1024), 
     550        $quota['percent']); 
     551 
     552    if ($display == 'image') { 
     553      $quota_result = array(         
     554        'percent'       => $quota['percent'], 
     555        'title'         => $quota_result, 
     556        ); 
     557      if ($attrib['width']) 
     558        $quota_result['width'] = $attrib['width']; 
     559      if ($attrib['height']) 
     560        $quota_result['height'] = $attrib['height']; 
    568561      } 
    569562    } 
    570563  else 
    571     $quota_text = rcube_label('unlimited'); 
    572  
    573   return $quota_text; 
     564    return rcube_label('unlimited'); 
     565 
     566  return $quota_result; 
    574567  } 
    575568 
Note: See TracChangeset for help on using the changeset viewer.