alecpl
2008-07-28 3ac95d5a673db544d7ceeaa9e5fca766cb738120
program/steps/mail/compose.inc
@@ -63,7 +63,10 @@
if (!is_array($_SESSION['compose']) || $_SESSION['compose']['id'] != get_input_value('_id', RCUBE_INPUT_GET))
{
  rcmail_compose_cleanup();
  $_SESSION['compose'] = array('id' => uniqid(rand()));
  $_SESSION['compose'] = array('id' => uniqid(rand()), 'param' => array_map('strip_tags', $_GET));
  // redirect to a unique URL with all parameters stored in session
  $OUTPUT->redirect(array('_action' => 'compose', '_id' => $_SESSION['compose']['id']));
}
// add some labels to client
@@ -74,11 +77,11 @@
// get reference message and set compose mode
if ($msg_uid = get_input_value('_reply_uid', RCUBE_INPUT_GET))
if ($msg_uid = $_SESSION['compose']['param']['_reply_uid'])
  $compose_mode = RCUBE_COMPOSE_REPLY;
else if ($msg_uid = get_input_value('_forward_uid', RCUBE_INPUT_GET))
else if ($msg_uid = $_SESSION['compose']['param']['_forward_uid'])
  $compose_mode = RCUBE_COMPOSE_FORWARD;
else if ($msg_uid = get_input_value('_draft_uid', RCUBE_INPUT_GET))
else if ($msg_uid = $_SESSION['compose']['param']['_draft_uid'])
  $compose_mode = RCUBE_COMPOSE_DRAFT;
if (!empty($msg_uid))
@@ -95,16 +98,12 @@
    $_SESSION['compose']['reply_msgid'] = $MESSAGE->headers->messageID;
    $_SESSION['compose']['references']  = trim($MESSAGE->headers->references . " " . $MESSAGE->headers->messageID);
    if (!empty($_GET['_all']))
    if (!empty($_SESSION['compose']['param']['_all']))
      $MESSAGE->reply_all = 1;
  }
  else if ($compose_mode == RCUBE_COMPOSE_FORWARD)
  {
    $_SESSION['compose']['forward_uid'] = $msg_uid;
  }
  else if ($compose_mode == RCUBE_COMPOSE_DRAFT)
  {
    $_SESSION['compose']['draft_uid'] = $msg_uid;
  }
}
@@ -131,10 +130,10 @@
      $header = 'to';
      
      // we have a set of recipients stored is session
      if (($mailto_id = get_input_value('_mailto', RCUBE_INPUT_GET)) && $_SESSION['mailto'][$mailto_id])
        $fvalue = $_SESSION['mailto'][$mailto_id];
      else if (!empty($_GET['_to']))
        $fvalue = get_input_value('_to', RCUBE_INPUT_GET);
      if (($mailto_id = $_SESSION['compose']['param']['_mailto']) && $_SESSION['mailto'][$mailto_id])
        $fvalue = urldecode($_SESSION['mailto'][$mailto_id]);
      else if (!empty($_SESSION['compose']['param']['_to']))
        $fvalue = $_SESSION['compose']['param']['_to'];
        
    case 'cc':
      if (!$fname)
@@ -522,7 +521,7 @@
  // add attachments
  if (!isset($_SESSION['compose']['forward_attachments']) && is_array($MESSAGE->mime_parts))
    rcmail_write_compose_attachments($MESSAGE);
    rcmail_write_compose_attachments($MESSAGE, $bodyIsHtml);
    
  return $prefix.$body;
}
@@ -539,13 +538,13 @@
  if (!isset($_SESSION['compose']['forward_attachments'])
      && is_array($MESSAGE->mime_parts)
      && count($MESSAGE->mime_parts) > 0)
    rcmail_write_compose_attachments($MESSAGE);
    rcmail_write_compose_attachments($MESSAGE, $bodyIsHtml);
  return $body;
}
  
  
function rcmail_write_compose_attachments(&$message)
function rcmail_write_compose_attachments(&$message, $bodyIsHtml)
{
  global $RCMAIL, $IMAP;
@@ -556,7 +555,7 @@
  
  foreach ((array)$message->mime_parts as $pid => $part)
  {
    if ($part->ctype_primary != 'message' &&
    if (($part->ctype_primary != 'message' || !$bodyIsHtml) &&
        ($part->disposition=='attachment' || $part->disposition=='inline' || $part->headers['content-id'] ||
         (empty($part->disposition) && $part->filename)))
    {
@@ -646,12 +645,17 @@
      $button = Q(rcube_label('delete'));
    foreach ($_SESSION['compose']['attachments'] as $id => $a_prop)
    {
      if (empty($a_prop))
        continue;
      $out .= html::tag('li', array('id' => "rcmfile".$id),
        html::a(array(
            'href' => "#delete",
            'title' => rcube_label('delete'),
              'onclick' => sprintf("return %s.command(\'remove-attachment\',\'rcmfile%d\', this)", JS_OBJECT_NAME, $id)),
            'onclick' => sprintf("return %s.command('remove-attachment','rcmfile%d', this)", JS_OBJECT_NAME, $id)),
          $button) . Q($a_prop['name']));
    }
  }
  $OUTPUT->add_gui_object('attachmentlist', $attrib['id']);
@@ -722,7 +726,7 @@
function rcmail_receipt_checkbox($attrib)
{
  global $MESSAGE;
  global $MESSAGE, $compose_mode;
  
  list($form_start, $form_end) = get_form_tags($attrib);
  unset($attrib['form']);
@@ -735,7 +739,8 @@
  $checkbox = new html_checkbox($attrib);
  $out = $form_start ? "$form_start\n" : '';
  $out .= $checkbox->show($MESSAGE->headers->mdn_to ? 1 : 0);
  $out .= $checkbox->show(
    $compose_mode == RCUBE_COMPOSE_DRAFT && $MESSAGE->headers->mdn_to ? 1 : 0);
  $out .= $form_end ? "\n$form_end" : '';
  return $out;
@@ -823,15 +828,16 @@
    if ($sql_arr['email'])
      $a_contacts[] = format_email_recipient($sql_arr['email'], $sql_arr['name']);
  }
if (isset($CONFIG['ldap_public']))
if (!empty($CONFIG['ldap_public']) && is_array($CONFIG['ldap_public']))
  {
  /* LDAP autocompletion */ 
  foreach ($CONFIG['ldap_public'] as $ldapserv_config) 
    { 
    if ($ldapserv_config['fuzzy_search'] != 1)
    if ($ldapserv_config['fuzzy_search'] != 1 ||
        $ldapserv_config['global_search'] != 1)
      { 
      continue; 
      }
      }
    
    $LDAP = new rcube_ldap($ldapserv_config); 
    $LDAP->connect(); 
@@ -855,6 +861,8 @@
if ($a_contacts) 
  { 
    $OUTPUT->set_env('contacts', $a_contacts); 
  }
  }
$OUTPUT->send('compose');
?>