thomascube
2008-09-18 7dfb1fba5001299300736e6b5d95d9400575e3e7
program/steps/mail/show.inc
@@ -32,16 +32,28 @@
  // go back to list if message not found (wrong UID)
  if (empty($MESSAGE->headers)) {
    $OUTPUT->show_message('messageopenerror', 'error');
    if ($RCMAIL->action=='preview' && template_exists('messagepreview'))
    if ($RCMAIL->action=='preview' && $OUTPUT->template_exists('messagepreview'))
        $OUTPUT->send('messagepreview');
    else {
      $RCMAIL->action = 'list';
      rcmail_overwrite_action('');
      return;
    }
  }
    
  $mbox_name = $IMAP->get_mailbox_name();
  
  // check known senders to display images
  if (!$MESSAGE->is_safe
      && !empty($MESSAGE->sender['mailto'])
      && $RCMAIL->config->get('addrbook_show_images')
      && $MESSAGE->has_html_part()) {
    $CONTACTS = new rcube_contacts($DB, $_SESSION['user_id']);
    if ($CONTACTS->search('email', $MESSAGE->sender['mailto'], true, false)->count) {
      $MESSAGE->set_safe(true);
    }
  }
  // calculate Etag for this request
  $etag = md5($MESSAGE->uid.$mbox_name.session_id().intval($MESSAGE->headers->mdn_sent).intval($MESSAGE->is_safe).intval($PRINT_MODE));
@@ -67,15 +79,22 @@
  // give message uid to the client
  $OUTPUT->set_env('uid', $MESSAGE->uid);
  $OUTPUT->set_env('safemode', $MESSAGE->is_safe);
  $OUTPUT->set_env('sender', $MESSAGE->sender['string']);
  $OUTPUT->set_env('permaurl', rcmail_url('show', array('_uid' => $MESSAGE->uid, '_mbox' => $mbox_name)));
  
  // check for unset disposition notification
  if ($MESSAGE->headers->mdn_to && !$MESSAGE->headers->mdn_sent &&
      $mbox_name != $CONFIG['drafts_mbox'] && $mbox_name != $CONFIG['sent_mbox'])
  if ($MESSAGE->headers->mdn_to &&
      !$MESSAGE->headers->mdn_sent &&
      $IMAP->check_permflag('MDNSENT') &&
      $mbox_name != $CONFIG['drafts_mbox'] &&
      $mbox_name != $CONFIG['sent_mbox'])
  {
    if (intval($CONFIG['mdn_requests']) === 1)
    {
      if (rcmail_send_mdn($MESSAGE->uid))
        $OUTPUT->show_message('receiptsent', 'confirmation');
      else
        $OUTPUT->show_message('errorsendingreceipt', 'error');
    }
    else if (empty($CONFIG['mdn_requests']))
    {
@@ -134,6 +153,15 @@
        $ol .= html::tag('li', null, sprintf("%s (%s)", Q($attach_prop->filename), Q(show_bytes($attach_prop->size))));
      }
      else {
        if (rc_strlen($attach_prop->filename) > 50) {
          $filename = abbreviate_string($attach_prop->filename, 50);
          $title = $attach_prop->filename;
      }
      else {
        $filename = $attach_prop->filename;
        $title = '';
      }
        $ol .= html::tag('li', null,
          html::a(array(
            'href' => $MESSAGE->get_part_url($attach_prop->mime_id),
@@ -142,8 +170,9 @@
              JS_OBJECT_NAME,
              $attach_prop->mime_id,
              $attach_prop->mimetype),
              'title' => Q($title),
            ),
            Q($attach_prop->filename)));
            Q($filename)));
      }
    }
@@ -156,36 +185,35 @@
function rcmail_remote_objects_msg($attrib)
  {
  global $CONFIG, $OUTPUT;
{
  global $MESSAGE, $RCMAIL;
  
  if (!$attrib['id'])
    $attrib['id'] = 'rcmremoteobjmsg';
  // allow the following attributes to be added to the <div> tag
  $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id'));
  $out = '<div' . $attrib_str . ">";
  
  $out .= sprintf('%s&nbsp;<a href="#loadimages" onclick="%s.command(\'load-images\')">%s</a>',
                  Q(rcube_label('blockedimages')),
                  JS_OBJECT_NAME,
                  Q(rcube_label('showimages')));
  $msg = Q(rcube_label('blockedimages')) . '&nbsp;';
  $msg .= html::a(array('href' => "#loadimages", 'onclick' => JS_OBJECT_NAME.".command('load-images')"), Q(rcube_label('showimages')));
  
  $out .= '</div>';
  $OUTPUT->add_gui_object('remoteobjectsmsg', $attrib['id']);
  return $out;
  // add link to save sender in addressbook and reload message
  if ($MESSAGE->sender['mailto'] && $RCMAIL->config->get('addrbook_show_images')) {
    $msg .= ' ' . html::a(array('href' => "#alwaysload", 'onclick' => JS_OBJECT_NAME.".command('always-load')", 'style' => "white-space:nowrap"),
      Q(rcube_label(array('name' => 'alwaysshow', 'vars' => array('sender' => $MESSAGE->sender['mailto'])))));
  }
  $RCMAIL->output->add_gui_object('remoteobjectsmsg', $attrib['id']);
  return html::div($attrib, $msg);
}
$OUTPUT->add_handlers(array(
  'messageattachments' => 'rcmail_message_attachments',
  'mailboxname' => 'rcmail_mailbox_name_display',
  'blockedobjects' => 'rcmail_remote_objects_msg'));
if ($RCMAIL->action=='print' && template_exists('printmessage'))
if ($RCMAIL->action=='print' && $OUTPUT->template_exists('printmessage'))
  $OUTPUT->send('printmessage');
else if ($RCMAIL->action=='preview' && template_exists('messagepreview'))
else if ($RCMAIL->action=='preview' && $OUTPUT->template_exists('messagepreview'))
    $OUTPUT->send('messagepreview');
else
  $OUTPUT->send('message');