alecpl
2010-01-25 580ff9c55e81aae04add43c95071c57e346a19ce
program/steps/mail/func.inc
@@ -306,7 +306,7 @@
    // format each col
    foreach ($a_show_cols as $col)
      {
      if ($col=='from' || $col=='to')
      if (in_array($col, array('from', 'to', 'cc', 'replyto')))
        $cont = Q(rcmail_address_string($header->$col, 3, false, $attrib['addicon']), 'show');
      else if ($col=='subject')
        {
@@ -427,7 +427,7 @@
    // format each col; similar as in rcmail_message_list()
    foreach ($a_show_cols as $col)
      {
      if ($col=='from' || $col=='to')
      if (in_array($col, array('from', 'to', 'cc', 'replyto')))
        $cont = Q(rcmail_address_string($header->$col, 3), 'show');
      else if ($col=='subject')
        {
@@ -458,9 +458,6 @@
    if ($header->flagged)
      $a_msg_flags['flagged'] = 1;
      
    if ($browser->ie)
      $a_msg_cols = rc_utf8_clean($a_msg_cols);
    $OUTPUT->command('add_message_row',
      $header->uid,
      $a_msg_cols,
@@ -517,60 +514,56 @@
    $_SESSION['quota_display'] = $attrib['display'];
  $OUTPUT->add_gui_object('quotadisplay', $attrib['id']);
  return html::span($attrib, rcmail_quota_content(NULL, $attrib));
  $quota = rcmail_quota_content($attrib);
  if (is_array($quota)) {
    $OUTPUT->add_script('$(document).ready(function(){
   rcmail.set_quota('.json_serialize($quota).')});', 'foot');
    $quota = '';
    }
  return html::span($attrib, $quota);
  }
function rcmail_quota_content($quota=NULL, $attrib=NULL)
function rcmail_quota_content($attrib=NULL)
  {
  global $IMAP, $COMM_PATH, $RCMAIL;
  global $COMM_PATH, $RCMAIL;
  $display = isset($_SESSION['quota_display']) ? $_SESSION['quota_display'] : '';
  if (is_array($quota) && !empty($quota['used']) && !empty($quota['total']))
    {
      if (!isset($quota['percent']))
        $quota['percent'] = $quota['used'] / $quota['total'];
    }
  elseif (!$IMAP->get_capability('QUOTA'))
  $quota = $RCMAIL->imap->get_quota();
  $quota = $RCMAIL->plugins->exec_hook('quota', $quota);
  if (!isset($quota['used']) || !isset($quota['total']))
    return rcube_label('unknown');
  else
    $quota = $IMAP->get_quota();
  if ($quota && !($quota['total']==0 && $RCMAIL->config->get('quota_zero_as_unlimited')))
  if (!($quota['total']==0 && $RCMAIL->config->get('quota_zero_as_unlimited')))
    {
    $quota_text = sprintf('%s / %s (%.0f%%)',
                          show_bytes($quota['used'] * 1024),
                          show_bytes($quota['total'] * 1024),
                          $quota['percent']);
    if (!isset($quota['percent']))
      $quota['percent'] = min(100, round(($quota['used']/max(1,$quota['total']))*100));
    $quota_result = sprintf('%s / %s (%.0f%%)',
        show_bytes($quota['used'] * 1024), show_bytes($quota['total'] * 1024),
        $quota['percent']);
    // show quota as image (by Brett Patterson)
    if ($display == 'image' && function_exists('imagegif'))
      {
      if (!$attrib['width'])
        $attrib['width'] = isset($_SESSION['quota_width']) ? $_SESSION['quota_width'] : 100;
      else
   $_SESSION['quota_width'] = $attrib['width'];
    if ($display == 'image') {
      $quota_result = array(
       'percent'    => $quota['percent'],
        'title'      => $quota_result,
   );
      if (!$attrib['height'])
        $attrib['height'] = isset($_SESSION['quota_height']) ? $_SESSION['quota_height'] : 14;
      else
   $_SESSION['quota_height'] = $attrib['height'];
      $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" />',
                            $quota['used'], $quota['total'],
                            $attrib['width'], $attrib['height'],
                            $attrib['width'], $attrib['height'],
                            $quota_text,
                            show_bytes($quota['used'] * 1024),
                            show_bytes($quota['total'] * 1024));
      if ($attrib['width'])
        $quota_result['width'] = $attrib['width'];
      if ($attrib['height'])
        $quota_result['height']   = $attrib['height'];
      }
    }
  else
    $quota_text = rcube_label('unlimited');
    return rcube_label('unlimited');
  return $quota_text;
  return $quota_result;
  }
@@ -615,6 +608,7 @@
  return html::span($attrib, rcmail_get_mailbox_name_text());
}
function rcmail_get_mailbox_name_text()
{
  global $RCMAIL;
@@ -637,7 +631,7 @@
    
  return $unseen;
}
/**
 * Sets message is_safe flag according to 'show_images' option value
@@ -667,6 +661,7 @@
  }
}
/**
 * Cleans up the given message HTML Body (for displaying)
 *
@@ -684,7 +679,7 @@
  // special replacements (not properly handled by washtml class)
  $html_search = array(
    '/(<\/nobr>)(\s+)(<nobr>)/i',   // space(s) between <NOBR>
    '/<title>.*<\/title>/i',      // PHP bug #32547 workaround: remove title tag
    '/<title[^>]*>.*<\/title>/i',      // PHP bug #32547 workaround: remove title tag
    '/^(\0\0\xFE\xFF|\xFF\xFE\0\0|\xFE\xFF|\xFF\xFE|\xEF\xBB\xBF)/',   // byte-order mark (only outlook?)
    '/<html\s[^>]+>/i',         // washtml/DOMDocument cannot handle xml namespaces
  );
@@ -697,7 +692,7 @@
  $html = preg_replace($html_search, $html_replace, $html);
  // fix (unknown/malformed) HTML tags before "wash"
  $html = preg_replace_callback('/(<[\/!]*)([^ >]+)/', 'rcmail_html_tag_callback', $html);
  $html = preg_replace_callback('/(<[\/]*)([^\s>]+)/', 'rcmail_html_tag_callback', $html);
  // charset was converted to UTF-8 in rcube_imap::get_message_part(),
  // -> change charset specification in HTML accordingly
@@ -741,7 +736,7 @@
  $html = $washer->wash($html);
  $REMOTE_OBJECTS = $washer->extlinks;
  return $html;
}
@@ -797,6 +792,7 @@
  return $data['type'] == 'html' ? $data['body'] : html::tag('pre', array(), $data['body']);
}
/**
 * Handle links and citation marks in plain text message
@@ -908,13 +904,9 @@
{
  $tagname = $matches[2];
  // html comments (#1486189)
  if ($matches[1] == '<!')
    return '<!';
  $tagname = preg_replace(array(
    '/:.*$/',      // Microsoft's Smart Tags <st1:xxxx>
    '/[^a-z0-9_-]/i',   // forbidden characters
    '/:.*$/',         // Microsoft's Smart Tags <st1:xxxx>
    '/[^a-z0-9_\[\]\!-]/i',   // forbidden characters
    ), '', $tagname);
  return $matches[1].$tagname;