missing '}' in session_expired_post, thanks Rusty Nejdl
[squirrelmail.git] / src / compose.php
index 5915bcc111904327001a7ad2cf0ca953e8b5bff3..059fd8f7b9b9278921d40fc231f3dd5b355a9975 100644 (file)
@@ -295,13 +295,19 @@ if (sqsession_is_registered('session_expired_post')) {
         sqsession_unregister('session_expired_post');
         session_write_close();
     } else {
-        foreach ($session_expired_post as $postvar => $val) {
-            if (isset($val)) {
-                $$postvar = $val;
-            } else {
-                $$postvar = '';
+        // these are the vars that we can set from the expired composed session   
+        $compo_var_list = array ( 'send_to', 'send_to_cc','body','startMessage',
+            'passed_body','use_signature','signature','attachments','subject','newmail',
+            'send_to_bcc', 'passed_id', 'mailbox', 'from_htmladdr_search', 'identity',
+            'draft_id', 'delete_draft', 'mailprio', 'edit_as_new', 'compose_messsages',
+            'composesession', 'request_mdn', 'request_dr');
+
+        foreach ($compo_var_list as $var) {
+            if ( isset($session_expired_post[$var]) && !isset($$var) ) {
+               $$var = $session_expired_post[$var];
             }
         }
+
         $compose_messages = unserialize(urldecode($restoremessages));
         sqsession_register($compose_messages,'compose_messages');
         sqsession_register($composesession,'composesession');
@@ -565,7 +571,7 @@ if ($send) {
             $_FILES['attachfile']['tmp_name'] &&
             $_FILES['attachfile']['tmp_name'] != 'none') {
         if(saveAttachedFiles($session)) {
-            plain_error_message(_("Could not move/copy file. File not attached"), $color);
+            plain_error_message(_("Could not move/copy file. File not attached"));
         }
     }
     /*
@@ -580,7 +586,7 @@ if ($send) {
         displayPageHeader($color, $mailbox);
     }
     if (saveAttachedFiles($session)) {
-        plain_error_message(_("Could not move/copy file. File not attached"), $color);
+        plain_error_message(_("Could not move/copy file. File not attached"));
     }
     showInputForm($session);
 }
@@ -681,7 +687,7 @@ function getforwardSubject($subject)
 function newMail ($mailbox='', $passed_id='', $passed_ent_id='', $action='', $session='') {
     global $editor_size, $default_use_priority, $body, $idents,
         $use_signature, $data_dir, $username,
-        $username, $key, $imapServerAddress, $imapPort, $compose_messages,
+        $key, $imapServerAddress, $imapPort, $compose_messages,
         $composeMessage, $body_quote;
     global $languages, $squirrelmail_language, $default_charset;
 
@@ -1035,7 +1041,7 @@ function showInputForm ($session, $values=false) {
         $from_htmladdr_search, $location_of_buttons, $attachment_dir,
         $username, $data_dir, $identity, $idents, $delete_draft,
         $mailprio, $compose_new_win, $saved_draft, $mail_sent, $sig_first,
-        $username, $compose_messages, $composesession, $default_charset,
+        $compose_messages, $composesession, $default_charset,
         $compose_onsubmit, $oTemplate;
 
     if (checkForJavascript()) {
@@ -1151,7 +1157,7 @@ function showInputForm ($session, $values=false) {
         }
         echo '   <tr>' . "\n" .
             html_tag( 'td', '', 'right', $color[4], 'width="10%"' ) .
-            _("From:") . '</td>' . "\n" .
+            '<label for="identity">' . _("From:") . '</label></td>' . "\n" .
             html_tag( 'td', '', 'left', $color[4], 'width="90%"' ) .
             '         '.
             addSelect('identity', $ident_list, $identity, TRUE);
@@ -1162,28 +1168,28 @@ function showInputForm ($session, $values=false) {
 
     echo '   <tr>' . "\n" .
         html_tag( 'td', '', 'right', $color[4], 'width="10%"' ) .
-        _("To") . ':</td>' . "\n" .
+        '<label for="send_to">' . _("To") . '</label>:</td>' . "\n" .
         html_tag( 'td', '', 'left', $color[4], 'width="90%"' ) .
         addInput('send_to', $send_to, 60, 0, $onfocus_array). '<br />' . "\n" .
         '      </td>' . "\n" .
         '   </tr>' . "\n" .
         '   <tr>' . "\n" .
         html_tag( 'td', '', 'right', $color[4] ) .
-        _("Cc") . ':</td>' . "\n" .
+        '<label for="send_to_cc">' . _("Cc") . '</label>:</td>' . "\n" .
         html_tag( 'td', '', 'left', $color[4] ) .
         addInput('send_to_cc', $send_to_cc, 60, 0, $onfocus_array). '<br />' . "\n" .
         '      </td>' . "\n" .
         '   </tr>' . "\n" .
         '   <tr>' . "\n" .
         html_tag( 'td', '', 'right', $color[4] ) .
-        _("Bcc") . ':</td>' . "\n" .
+        '<label for="send_to_bcc">' . _("Bcc") . '</label>:</td>' . "\n" .
         html_tag( 'td', '', 'left', $color[4] ) .
         addInput('send_to_bcc', $send_to_bcc, 60, 0, $onfocus_array).'<br />' . "\n" .
         '      </td>' . "\n" .
         '   </tr>' . "\n" .
         '   <tr>' . "\n" .
         html_tag( 'td', '', 'right', $color[4] ) .
-        _("Subject") . ':</td>' . "\n" .
+        '<label for="subject">' . _("Subject") . '</label>:</td>' . "\n" .
         html_tag( 'td', '', 'left', $color[4] ) . "\n";
     echo '         '.addInput('subject', $subject, 60, 0, $onfocus_array).
         '      </td>' . "\n" .
@@ -1193,18 +1199,20 @@ function showInputForm ($session, $values=false) {
         showComposeButtonRow();
     }
 
-    /* why this distinction? */
+    /**
+     * When message is compose in new window, different colors are used.
+     */
     if ($compose_new_win == '1') {
         echo '   <tr>' . "\n" .
             '      <td bgcolor="' . $color[0] . '" colspan="2" align="center">' . "\n" .
             '         <textarea name="body" id="body" rows="' . (int)$editor_height .
-            '" cols="' . (int)$editor_size . '" wrap="virtual"' . $onfocus . '>';
+            '" cols="' . (int)$editor_size . '"' . $onfocus . '>';
     }
     else {
         echo '   <tr>' . "\n" .
             '      <td bgcolor="' . $color[4] . '" colspan="2">' . "\n" .
             '         &nbsp;&nbsp;<textarea name="body" id="body" rows="' . (int)$editor_height .
-            '" cols="' . (int)$editor_size . '" wrap="virtual"' . $onfocus . '>';
+            '" cols="' . (int)$editor_size . '"' . $onfocus . '>';
     }
 
     if ($use_signature == true && $newmail == true && !isset($from_htmladdr_search)) {
@@ -1368,7 +1376,7 @@ function showComposeButtonRow() {
         if(!isset($mailprio)) {
             $mailprio = '3';
         }
-        echo '          ' . _("Priority") .
+        echo '          <label for="mailprio">' . _("Priority") . '</label>: '.
             addSelect('mailprio', array(
                         '1' => _("High"),
                         '3' => _("Normal"),
@@ -1378,8 +1386,10 @@ function showComposeButtonRow() {
     if ($default_use_mdn) {
         if ($mdn_user_support) {
             echo '          ' . _("Receipt") .': '.
-                addCheckBox('request_mdn', $request_mdn == '1', '1'). _("On Read").
-                addCheckBox('request_dr',  $request_dr  == '1', '1'). _("On Delivery");
+                addCheckBox('request_mdn', $request_mdn == '1', '1') .
+                    '<label for="request_mdn">' . _("On Read") . '</label>' .
+                addCheckBox('request_dr',  $request_dr  == '1', '1') .
+                    '<label for="request_dr">' .  _("On Delivery") . '</label>';
         }
     }
 
@@ -1420,11 +1430,11 @@ function checkInput ($show) {
      * using $show=false, and then when i'm ready to display the error
      * message, show=true
      */
-    global $body, $send_to, $send_to_bcc, $subject, $color;
+    global $send_to, $send_to_bcc;
 
     if ($send_to == '' && $send_to_bcc == '') {
         if ($show) {
-            plain_error_message(_("You have not filled in the \"To:\" field."), $color);
+            plain_error_message(_("You have not filled in the \"To:\" field."));
         }
         return false;
     }
@@ -1620,6 +1630,14 @@ function deliverMessage($composeMessage, $draft=false) {
     } elseif (!$draft) {
         require_once(SM_PATH . 'class/deliver/Deliver_SendMail.class.php');
         global $sendmail_path, $sendmail_args;
+        // Check for outdated configuration
+        if (!isset($sendmail_args)) {
+            if ($sendmail_path=='/var/qmail/bin/qmail-inject') {
+                $sendmail_args = '';
+            } else {
+                $sendmail_args = '-i -t';
+            }
+        }
         $deliver = new Deliver_SendMail(array('sendmail_args'=>$sendmail_args));
         $stream = $deliver->initStream($composeMessage,$sendmail_path);
     } elseif ($draft) {
@@ -1640,7 +1658,7 @@ function deliverMessage($composeMessage, $draft=false) {
             return $length;
         } else {
             $msg  = '<br />'.sprintf(_("Error: Draft folder %s does not exist."), htmlspecialchars($draft_folder));
-            plain_error_message($msg, $color);
+            plain_error_message($msg);
             return false;
         }
     }
@@ -1659,7 +1677,7 @@ function deliverMessage($composeMessage, $draft=false) {
                 _("Server replied:") . ' ' . $deliver->dlv_ret_nr . ' ' .
                 nl2br(htmlspecialchars($deliver->dlv_server_msg));
         }
-        plain_error_message($msg, $color);
+        plain_error_message($msg);
     } else {
         unset ($deliver);
         $move_to_sent = getPref($data_dir,$username,'move_to_sent');
@@ -1730,5 +1748,4 @@ function deliverMessage($composeMessage, $draft=false) {
     }
     return $success;
 }
-
-?>
\ No newline at end of file
+?>