thomascube
2010-12-17 db1a87cd6c506f2afbd1a37c64cb56ae11120b49
program/steps/mail/func.inc
@@ -46,7 +46,7 @@
}
// set imap properties and session vars
if ($mbox = get_input_value('_mbox', RCUBE_INPUT_GPC))
if (strlen(trim($mbox = get_input_value('_mbox', RCUBE_INPUT_GPC, true))))
  $IMAP->set_mailbox(($_SESSION['mbox'] = $mbox));
else if ($IMAP)
  $_SESSION['mbox'] = $IMAP->get_mailbox_name();
@@ -131,7 +131,8 @@
  if (!$OUTPUT->ajax_call)
    $OUTPUT->add_label('checkingmail', 'deletemessage', 'movemessagetotrash',
      'movingmessage', 'copyingmessage', 'copy', 'move', 'quota');
      'movingmessage', 'copyingmessage', 'deletingmessage', 'markingmessage',
      'copy', 'move', 'quota');
  $OUTPUT->set_pagetitle(rcmail_localize_foldername($mbox_name));
}
@@ -422,86 +423,22 @@
function rcmail_messagecount_display($attrib)
  {
  global $IMAP, $OUTPUT;
  global $RCMAIL;
  if (!$attrib['id'])
    $attrib['id'] = 'rcmcountdisplay';
  $OUTPUT->add_gui_object('countdisplay', $attrib['id']);
  $RCMAIL->output->add_gui_object('countdisplay', $attrib['id']);
  return html::span($attrib, rcmail_get_messagecount_text());
  }
  $content =  $RCMAIL->action != 'show' ? rcmail_get_messagecount_text() : rcube_label('loading');
function rcmail_quota_display($attrib)
  {
  global $OUTPUT;
  if (!$attrib['id'])
    $attrib['id'] = 'rcmquotadisplay';
  if(isset($attrib['display']))
    $_SESSION['quota_display'] = $attrib['display'];
  $OUTPUT->add_gui_object('quotadisplay', $attrib['id']);
  $quota = rcmail_quota_content($attrib);
  $OUTPUT->add_script('$(document).ready(function(){
   rcmail.set_quota('.json_serialize($quota).')});', 'foot');
  return html::span($attrib, '');
  }
function rcmail_quota_content($attrib=NULL)
  {
  global $COMM_PATH, $RCMAIL;
  $quota = $RCMAIL->imap->get_quota();
  $quota = $RCMAIL->plugins->exec_hook('quota', $quota);
  $quota_result = (array) $quota;
  $quota_result['type'] = isset($_SESSION['quota_display']) ? $_SESSION['quota_display'] : '';
  if (!$quota['total'] && $RCMAIL->config->get('quota_zero_as_unlimited')) {
    $quota_result['title'] = rcube_label('unlimited');
    $quota_result['percent'] = 0;
    }
  else if ($quota['total']) {
    if (!isset($quota['percent']))
      $quota_result['percent'] = min(100, round(($quota['used']/max(1,$quota['total']))*100));
    $title = sprintf('%s / %s (%.0f%%)',
        show_bytes($quota['used'] * 1024), show_bytes($quota['total'] * 1024),
        $quota_result['percent']);
    $quota_result['title'] = $title;
    if ($attrib['width'])
      $quota_result['width'] = $attrib['width'];
    if ($attrib['height'])
      $quota_result['height']   = $attrib['height'];
    }
  else {
    $quota_result['title'] = rcube_label('unknown');
    $quota_result['percent'] = 0;
    }
  return $quota_result;
  return html::span($attrib, $content);
  }
function rcmail_get_messagecount_text($count=NULL, $page=NULL)
  {
  global $RCMAIL, $IMAP, $MESSAGE;
  if (isset($MESSAGE->index))
    {
    return rcube_label(array('name' => 'messagenrof',
        'vars' => array('nr'  => $MESSAGE->index+1,
        'count' => $count!==NULL ? $count : $IMAP->messagecount(NULL, 'ALL')))); // Only messages, no threads here
    }
  global $RCMAIL, $IMAP;
  if ($page===NULL)
    $page = $IMAP->list_page;
@@ -549,7 +486,7 @@
{
  global $RCMAIL;
  $old_unseen = $_SESSION['unseen_count'][$mbox_name];
  $old_unseen = rcmail_get_unseen_count($mbox_name);
  if ($count === null)
    $unseen = $RCMAIL->imap->messagecount($mbox_name, 'UNSEEN', $force);
@@ -559,10 +496,30 @@
  if ($unseen != $old_unseen || ($mbox_name == 'INBOX'))
    $RCMAIL->output->command('set_unread_count', $mbox_name, $unseen, ($mbox_name == 'INBOX'));
  // @TODO: this data is doubled (session and cache tables) if caching is enabled
  $_SESSION['unseen_count'][$mbox_name] = $unseen;
  rcmail_set_unseen_count($mbox_name, $unseen);
  return $unseen;
}
function rcmail_set_unseen_count($mbox_name, $count)
{
  // @TODO: this data is doubled (session and cache tables) if caching is enabled
  // Make sure we have an array here (#1487066)
  if (!is_array($_SESSION['unseen_count']))
    $_SESSION['unseen_count'] = array();
  $_SESSION['unseen_count'][$mbox_name] = $count;
}
function rcmail_get_unseen_count($mbox_name)
{
  if (is_array($_SESSION['unseen_count']) && array_key_exists($mbox_name, $_SESSION['unseen_count']))
    return $_SESSION['unseen_count'][$mbox_name];
  else
    return null;
}
@@ -835,8 +792,12 @@
    $quote_level = $q;
  }
  // quote plain text
  $body = Q(join("\n", $a_lines), 'dummy', false);
  $body = join("\n", $a_lines);
  // quote plain text (don't use Q() here, to display entities "as is")
  $table = get_html_translation_table(HTML_SPECIALCHARS);
  unset($table['?']);
  $body = strtr($body, $table);
  // colorize signature (up to <sig_max_lines> lines)
  $len = strlen($body);
@@ -966,17 +927,21 @@
    else
      $header_value = trim($IMAP->decode_header($value));
    $output_headers[$hkey] = array('title' => rcube_label($hkey), 'value' => $header_value, 'raw' => $value);
    $output_headers[$hkey] = array(
        'title' => rcube_label(preg_replace('/(^mail-|-)/', '', $hkey)),
        'value' => $header_value, 'raw' => $value
    );
  }
  $plugin = $RCMAIL->plugins->exec_hook('message_headers_output', array('output' => $output_headers, 'headers' => $MESSAGE->headers));
  $plugin = $RCMAIL->plugins->exec_hook('message_headers_output',
    array('output' => $output_headers, 'headers' => $MESSAGE->headers));
  // compose html table
  $table = new html_table(array('cols' => 2));
  foreach ($plugin['output'] as $hkey => $row) {
    $table->add(array('class' => 'header-title'), Q($row['title']));
    $table->add(array('class' => $hkey, 'width' => "90%"), Q($row['value'], ($hkey == 'subject' ? 'strict' : 'show')));
    $table->add(array('class' => 'header '.$hkey), Q($row['value'], ($hkey == 'subject' ? 'strict' : 'show')));
  }
  // all headers division
@@ -1544,6 +1509,7 @@
      $delim   = $RCMAIL->config->header_delimiter();
      $to      = $headers_enc['To'];
      $subject = $headers_enc['Subject'];
      $header_str = rtrim($header_str);
      if ($delim != "\r\n") {
        $header_str = str_replace("\r\n", $delim, $header_str);
@@ -1717,6 +1683,16 @@
  return $date;
}
// Fixes some content-type names
function rcmail_fix_mimetype($name)
{
  // Some versions of Outlook create garbage Content-Type:
  // application/pdf.A520491B_3BF7_494D_8855_7FAC2C6C0608
  if (preg_match('/^application\/pdf.+/', $name))
    $name = 'application/pdf';
  return $name;
}
function rcmail_search_filter($attrib)
{