Ticket #1484972: quotadisplay.patch

File quotadisplay.patch, 6.8 kB (added by alec, 8 months ago)

patch for point 2.

  • index.php

    diff -ru /home/alec/trunk/roundcubemail/index.php rc-beta/index.php
    old new  
    325325  if ($_action=='rss') 
    326326    include('program/steps/mail/rss.inc'); 
    327327     
    328   if ($_action=='quotadisplay') 
    329     include('program/steps/mail/quotadisplay.inc'); 
    330  
    331  
    332328  // make sure the message count is refreshed 
    333329  $IMAP->messagecount($_SESSION['mbox'], 'ALL', TRUE); 
    334330} 
  • program/js/app.js

    diff -ru /home/alec/trunk/roundcubemail/program/js/app.js rc-beta/program/js/app.js
    old new  
    32373237    this.set_page_buttons(); 
    32383238    }; 
    32393239 
     3240 
    32403241  // replace content of quota display 
    3241   this.set_quota = function() 
     3242  this.set_quota = function(content) 
    32423243    { 
    3243     if (this.gui_objects.quotadisplay && 
    3244         this.gui_objects.quotadisplay.attributes.getNamedItem('display') && 
    3245         this.gui_objects.quotadisplay.attributes.getNamedItem('id')) 
    3246       this.http_request('quotadisplay', '_display='+ 
    3247       this.gui_objects.quotadisplay.attributes.getNamedItem('display').nodeValue+ 
    3248       '&_id='+this.gui_objects.quotadisplay.attributes.getNamedItem('id').nodeValue, false); 
    3249      }; 
     3244    if (this.gui_objects.quotadisplay && content) 
     3245      this.gui_objects.quotadisplay.innerHTML = content; 
     3246    }; 
    32503247 
    32513248 
    32523249  // update the mailboxlist 
  • program/steps/mail/check_recent.inc

    diff -ru /home/alec/trunk/roundcubemail/program/steps/mail/check_recent.inc rc-beta/program/steps/mail/check_recent.inc
    old new  
    3737      $OUTPUT->set_env('messagecount', $IMAP->messagecount()); 
    3838      $OUTPUT->command('set_unread_count', $mbox_name, $unread_count, ($mbox_name == 'INBOX')); 
    3939      $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text()); 
    40       $OUTPUT->command('set_quota', $IMAP->get_quota()); 
     40      $OUTPUT->command('set_quota', rcmail_quota_content($IMAP->get_quota())); 
    4141 
    4242      // add new message headers to list 
    4343      $a_headers = array(); 
  • program/steps/mail/func.inc

    diff -ru /home/alec/trunk/roundcubemail/program/steps/mail/func.inc rc-beta/program/steps/mail/func.inc
    old new  
    1515 | Author: Thomas Bruederli <roundcube@gmail.com>                        | 
    1616 +-----------------------------------------------------------------------+ 
    1717 
    18  $Id: func.inc 1269 2008-04-07 19:48:32Z alec $ 
     18 $Id: func.inc 1214 2008-03-25 00:52:33Z till $ 
    1919 
    2020*/ 
    2121 
     
    408408  if (!$attrib['id']) 
    409409    $attrib['id'] = 'rcmquotadisplay'; 
    410410 
     411  if(isset($attrib['display'])) 
     412    $_SESSION['quota_display'] = $attrib['display']; 
     413 
    411414  $OUTPUT->add_gui_object('quotadisplay', $attrib['id']); 
    412415 
    413416  // allow the following attributes to be added to the <span> tag 
    414417  $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id', 'display')); 
    415418 
    416419  $out = '<span' . $attrib_str . '>'; 
    417   $out .= rcmail_quota_content($attrib['display']); 
     420  $out .= rcmail_quota_content(); 
    418421  $out .= '</span>'; 
    419422  return $out; 
    420423  } 
    421424 
    422425 
    423 function rcmail_quota_content($display) 
     426function rcmail_quota_content($quota=NULL) 
    424427  { 
    425428  global $IMAP, $COMM_PATH; 
    426429 
    427   if (!$IMAP->get_capability('QUOTA')) 
    428     $quota_text = rcube_label('unknown'); 
    429   else if ($quota = $IMAP->get_quota()) 
    430     { 
    431     $quota_text = sprintf("%s / %s (%.0f%%)", 
    432                           show_bytes($quota["used"] * 1024), 
    433                           show_bytes($quota["total"] * 1024), 
    434                           $quota["percent"]); 
     430  $display = isset($_SESSION['quota_display']) ? $_SESSION['quota_display'] : ''; 
     431 
     432  if (is_array($quota) && !empty($quota['used']) && !empty($quota['total'])) 
     433    { 
     434      if (!isset($quota['percent'])) 
     435        $quota['percent'] = $quota['used'] / $quota['total']; 
     436    } 
     437  elseif (!$IMAP->get_capability('QUOTA')) 
     438    return rcube_label('unknown'); 
     439  else 
     440    $quota = $IMAP->get_quota(); 
     441 
     442  if ($quota) 
     443    { 
     444    $quota_text = sprintf('%s / %s (%.0f%%)', 
     445                          show_bytes($quota['used'] * 1024), 
     446                          show_bytes($quota['total'] * 1024), 
     447                          $quota['percent']); 
    435448 
    436449    // show quota as image (by Brett Patterson) 
    437450    if ($display == 'image' && function_exists('imagegif')) 
  • program/steps/mail/move_del.inc

    diff -ru /home/alec/trunk/roundcubemail/program/steps/mail/move_del.inc rc-beta/program/steps/mail/move_del.inc
    old new  
    9292if ($_action=='moveto' && $target) 
    9393  $OUTPUT->command('set_unread_count', $target, $IMAP->messagecount($target, 'UNSEEN')); 
    9494 
    95 $OUTPUT->command('set_quota', $IMAP->get_quota()); 
     95$OUTPUT->command('set_quota', rcmail_quota_content($IMAP->get_quota())); 
    9696 
    9797// add new rows from next page (if any) 
    9898if ($_POST['_from']!='show' && ($jump_back || $nextpage_count > 0)) 
  • program/steps/mail/quotadisplay.inc

    diff -ruN /home/alec/trunk/roundcubemail/program/steps/mail/quotadisplay.inc rc-beta/program/steps/mail/quotadisplay.inc
    old new  
    1 <?php 
    2  
    3 /* 
    4  +-----------------------------------------------------------------------+ 
    5  | program/steps/mail/quotadisplay.inc                                   | 
    6  |                                                                       | 
    7  | This file is part of the RoundCube Webmail client                     | 
    8  | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland                 | 
    9  | Licensed under the GNU GPL                                            | 
    10  |                                                                       | 
    11  | PURPOSE:                                                              | 
    12  |   Remote call to return the quota image or text                       | 
    13  |                                                                       | 
    14  +-----------------------------------------------------------------------+ 
    15  | Author: Robin Elfrink <robin@15augustus.nl>                           | 
    16  +-----------------------------------------------------------------------+ 
    17  
    18  $Id: quotadisplay.inc 850 2007-10-03 00:13:32Z ihug $ 
    19  
    20 */ 
    21  
    22 $display = isset($_GET['_display']) ? $_GET['_display'] : 'text'; 
    23 $id = isset($_GET['_id']) ? $_GET['_id'] : 'rcmquotadisplay'; 
    24 $quota = rcmail_quota_content($display); 
    25 $OUTPUT->remote_response(sprintf("this.gui_objects.%s.innerHTML = '%s';\n", $id, $quota)); 
    26  
    27 exit; 
    28 ?>