thomascube
2008-02-06 6726f0c369e87c3cc34b2c2815935c87bc196c3d
program/steps/mail/show.inc
@@ -5,7 +5,7 @@
 | program/steps/mail/show.inc                                           |
 |                                                                       |
 | This file is part of the RoundCube Webmail client                     |
 | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland                 |
 | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland                 |
 | Licensed under the GNU GPL                                            |
 |                                                                       |
 | PURPOSE:                                                              |
@@ -20,6 +20,7 @@
*/
require_once('Mail/mimeDecode.php');
require_once('lib/rc_mail_mime.inc');
$PRINT_MODE = $_action=='print' ? TRUE : FALSE;
@@ -41,6 +42,12 @@
      return;
      }
    }
  // check if safe flag is set
  if ($MESSAGE['is_safe'] = intval($_GET['_safe']))
    $_SESSION['safe_messages'][$MESSAGE['UID']] = true;
  else if ($_SESSION['safe_messages'][$MESSAGE['UID']])
    $MESSAGE['is_safe'] = 1;
  // calculate Etag for this request
  $etag = md5($MESSAGE['UID'].$IMAP->get_mailbox_name().session_id().intval($MESSAGE['headers']->mdn_sent).intval($PRINT_MODE));
@@ -57,7 +64,7 @@
  if ($MESSAGE['structure'] = $IMAP->get_structure($MESSAGE['UID']))
    list($MESSAGE['parts'], $MESSAGE['attachments']) = rcmail_parse_message(
      $MESSAGE['structure'],
      array('safe' => intval($_GET['_safe']),
      array('safe' => $MESSAGE['is_safe'],
            'prefer_html' => $CONFIG['prefer_html'],
            'get_url' => $GET_URL.'&_part=%s')
      );
@@ -71,27 +78,28 @@
  // give message uid to the client
  $OUTPUT->set_env('uid', $MESSAGE['UID']);
  $OUTPUT->set_env('safemode', intval($_GET['_safe']));
  $OUTPUT->set_env('safemode', $MESSAGE['is_safe']);
  
  // check for unset disposition notification
  if ($MESSAGE['headers']->mdn_to && !$MESSAGE['headers']->mdn_sent)
  if ($MESSAGE['headers']->mdn_to && !$MESSAGE['headers']->mdn_sent && $IMAP->get_mailbox_name() != $CONFIG['drafts_mbox'])
  {
    rcube_add_label('mdnrequest');
    $OUTPUT->set_env('mdn_request', true);
    if (intval($CONFIG['mdn_requests']) === 1)
    {
      if (rcmail_send_mdn($MESSAGE['UID']))
        $OUTPUT->show_message('receiptsent', 'confirmation');
    }
    else if (empty($CONFIG['mdn_requests']))
    {
      rcube_add_label('mdnrequest');
      $OUTPUT->set_env('mdn_request', true);
    }
  }
  // set message set for search result
  if (!empty($_REQUEST['_search']) && isset($_SESSION['search'][$_REQUEST['_search']]))
    {
    $IMAP->set_search_set($_SESSION['search'][$_REQUEST['_search']]);
    $OUTPUT->set_env('search_request', $_REQUEST['_search']);
    }
  $next = $prev = $first = $last = -1;
  // get previous, first, next and last message UID
  if ((!($_SESSION['sort_col'] == 'date' && $_SESSION['sort_order'] == 'DESC') &&
      $IMAP->get_capability('sort') ) && !(!empty($_REQUEST['_search']) &&
      isset($_SESSION['search'][$_REQUEST['_search']])) )
      $IMAP->get_capability('sort')) || !empty($_REQUEST['_search']))
    {
    // Only if we use custom sorting
    $a_msg_index = $IMAP->message_index(NULL, $_SESSION['sort_col'], $_SESSION['sort_order']);
@@ -101,23 +109,6 @@
    $first = count($a_msg_index)>0 ? $a_msg_index[0] : -1;
    $next = isset($a_msg_index[$MESSAGE['index']+1]) ? $a_msg_index[$MESSAGE['index']+1] : -1 ;
    $last = count($a_msg_index)>0 ? $a_msg_index[count($a_msg_index)-1] : -1;
    }
  elseif (!empty($_REQUEST['_search']) && isset($_SESSION['search'][$_REQUEST['_search']]))
    {
      $search_data = $_SESSION['search'][$_REQUEST['_search']];
      $result = $IMAP->search(NULL, $search_data[0], $search_data[1],$search_data[3]);
      $result = array_reverse($result);
      foreach ($result as $key=>$rid)
        {
        $result[$key] = $IMAP->get_uid($rid);
        if ($MESSAGE['UID'] == $result[$key])
          $seq = $key;
        }
      $prev = isset($result[$seq-1]) ? $result[$seq-1] : -1 ;
      $first = count($result)>0 ? $result[0] : -1;
      $next = isset($result[$seq+1]) ? $result[$seq+1] : -1 ;
      $last = count($result)>0 ? $result[count($result)-1] : -1;
      $MESSAGE['index'] = $seq;
    }
  else
    {