Browse Source

Fix comp_in_new: make outputing the compose link a function so that
the comp_in_new works the same everywhere.
In this new function, make sure that comp_in_new still works when
JavaScript off.
When JavaScript off, do not output all kinds of JavaScript functions
which are never going to be called.

Thijs Kinkhorst 22 năm trước cách đây
mục cha
commit
9d5490c98a

+ 5 - 0
ChangeLog

@@ -26,6 +26,11 @@ Version 1.5.0 -- CVS
   - Fixed language bug in posting on modifying/deleting servers on mail_fetch plugin
   - Fixed language bug in posting on modifying/deleting servers on mail_fetch plugin
     (#742705).
     (#742705).
   - Fixed infinite loop in parseAddress on invalid mailadress (#742584).
   - Fixed infinite loop in parseAddress on invalid mailadress (#742584).
+  - Rewrote ugly "Not a very useful errormessage" to something more friendly.
+  - Make central function for compose links to make sure compose_in_new always
+    works the same way.
+  - Fix that when JavaScript off, compose in new was broken (#749654).
+  - Do not output JavaScript functions in page_header when JavaScript off.
 
 
 **************************************
 **************************************
 *** SquirrelMail Stable Series 1.4 ***
 *** SquirrelMail Stable Series 1.4 ***

+ 165 - 158
functions/page_header.php

@@ -66,20 +66,24 @@ ECHO;
     echo "\n</head>\n\n";
     echo "\n</head>\n\n";
 }
 }
 
 
-
-function displayInternalLink($path, $text, $target='') {
+function makeInternalLink($path, $text, $target='') {
     sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION);
     sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION);
     if ($target != '') {
     if ($target != '') {
         $target = " target=\"$target\"";
         $target = " target=\"$target\"";
     }
     }
-    echo '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
+    return '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>';
+}
+
+function displayInternalLink($path, $text, $target='') {
+    echo makeInternalLink($path, $text, $target='');
 }
 }
 
 
 function displayPageHeader($color, $mailbox, $xtra='', $session=false) {
 function displayPageHeader($color, $mailbox, $xtra='', $session=false) {
 
 
     global $hide_sm_attributions, $PHP_SELF, $frame_top,
     global $hide_sm_attributions, $PHP_SELF, $frame_top,
            $compose_new_win, $compose_width, $compose_height,
            $compose_new_win, $compose_width, $compose_height,
-           $attachemessages, $provider_name, $provider_uri;
+           $attachemessages, $provider_name, $provider_uri,
+           $javascript_on;
 
 
     sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION );
     sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION );
     sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION );
     sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION );
@@ -97,121 +101,127 @@ function displayPageHeader($color, $mailbox, $xtra='', $session=false) {
         $compose_uri = $base_uri.'src/compose.php?newmessage=1';
         $compose_uri = $base_uri.'src/compose.php?newmessage=1';
 	$session = 0;
 	$session = 0;
     }
     }
-   
-    switch ( $module ) {
-    case 'src/read_body.php':
-            $js ='';
-            if ($compose_new_win == '1') {
-                if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
-                    $compose_width = '640';
-                }
-                if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
-                    $compose_height = '550';
-                }
-                $js .= "\n".'<script language="JavaScript" type="text/javascript">' .
-                    "\n<!--\n";
-                $js .= "function comp_in_new(comp_uri) {\n".
-		     "       if (!comp_uri) {\n".
-		     '           comp_uri = "'.$compose_uri."\";\n".
-		     '       }'. "\n".
-                     '    var newwin = window.open(comp_uri' .
-                     ', "_blank",'.
-                     '"width='.$compose_width. ',height='.$compose_height.
-                     ',scrollbars=yes,resizable=yes");'."\n".
-                     "}\n\n";
-
-
-                $js .= 'function sendMDN() {'."\n".
-                       "mdnuri=window.location+'&sendreceipt=1';".
-                       "var newwin = window.open(mdnuri,'right');".
-	               "\n}\n\n";
-
-                $js .= "// -->\n".
-        	       "</script>\n";
+  
+    if($javascript_on) { 
+
+      switch ( $module ) {
+        case 'src/read_body.php':
+                $js ='';
+                if ($compose_new_win == '1') {
+                    if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
+                        $compose_width = '640';
+                    }
+                    if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
+                        $compose_height = '550';
+                    }
+                    $js .= "\n".'<script language="JavaScript" type="text/javascript">' .
+                        "\n<!--\n";
+                    $js .= "function comp_in_new(comp_uri) {\n".
+    		     "       if (!comp_uri) {\n".
+    		     '           comp_uri = "'.$compose_uri."\";\n".
+    		     '       }'. "\n".
+                         '    var newwin = window.open(comp_uri' .
+                         ', "_blank",'.
+                         '"width='.$compose_width. ',height='.$compose_height.
+                         ',scrollbars=yes,resizable=yes");'."\n".
+                         "}\n\n";
+
+
+                    $js .= 'function sendMDN() {'."\n".
+                           "mdnuri=window.location+'&sendreceipt=1';".
+                           "var newwin = window.open(mdnuri,'right');".
+    	               "\n}\n\n";
+
+                    $js .= "// -->\n".
+            	       "</script>\n";
 	     
 	     
-             }
-             displayHtmlHeader ('SquirrelMail', $js);
-             $onload = $xtra;
-        break;
-    case 'src/compose.php':
-        $js = '<script language="JavaScript" type="text/javascript">' .
-             "\n<!--\n" .
-             "function checkForm() {\n".
-                "var f = document.forms.length;\n".
-                "var i = 0;\n".
-                "var pos = -1;\n".
-                "while( pos == -1 && i < f ) {\n".
-                    "var e = document.forms[i].elements.length;\n".
-                    "var j = 0;\n".
-                    "while( pos == -1 && j < e ) {\n".
-                        "if ( document.forms[i].elements[j].type == 'text' ) {\n".
-                            "pos = j;\n".
+                 }
+                 displayHtmlHeader ('SquirrelMail', $js);
+                 $onload = $xtra;
+            break;
+        case 'src/compose.php':
+            $js = '<script language="JavaScript" type="text/javascript">' .
+                 "\n<!--\n" .
+                 "function checkForm() {\n".
+                    "var f = document.forms.length;\n".
+                    "var i = 0;\n".
+                    "var pos = -1;\n".
+                    "while( pos == -1 && i < f ) {\n".
+                        "var e = document.forms[i].elements.length;\n".
+                        "var j = 0;\n".
+                        "while( pos == -1 && j < e ) {\n".
+                            "if ( document.forms[i].elements[j].type == 'text' ) {\n".
+                                "pos = j;\n".
+                            "}\n".
+                            "j++;\n".
                         "}\n".
                         "}\n".
-                        "j++;\n".
+                    "i++;\n".
                     "}\n".
                     "}\n".
-                "i++;\n".
-                "}\n".
-                "if( pos >= 0 ) {\n".
-                    "document.forms[i-1].elements[pos].focus();\n".
-                "}\n".
-            "}\n";
+                    "if( pos >= 0 ) {\n".
+                        "document.forms[i-1].elements[pos].focus();\n".
+                    "}\n".
+                "}\n";
 	    
 	    
-        $js .= "// -->\n".
-        	 "</script>\n";
-        $onload = 'onload="checkForm();"';
-        displayHtmlHeader ('SquirrelMail', $js);
-        break;   
-
-    default:
-        $js = '<script language="JavaScript" type="text/javascript">' .
-             "\n<!--\n" .
-             "function checkForm() {\n".
-                "var f = document.forms.length;\n".
-                "var i = 0;\n".
-                "var pos = -1;\n".
-                "while( pos == -1 && i < f ) {\n".
-                    "var e = document.forms[i].elements.length;\n".
-                    "var j = 0;\n".
-                    "while( pos == -1 && j < e ) {\n".
-                        "if ( document.forms[i].elements[j].type == 'text' " .
-                        "|| document.forms[i].elements[j].type == 'password' ) {\n".
-                            "pos = j;\n".
+            $js .= "// -->\n".
+            	 "</script>\n";
+            $onload = 'onload="checkForm();"';
+            displayHtmlHeader ('SquirrelMail', $js);
+            break;   
+
+        default:
+            $js = '<script language="JavaScript" type="text/javascript">' .
+                 "\n<!--\n" .
+                 "function checkForm() {\n".
+                    "var f = document.forms.length;\n".
+                    "var i = 0;\n".
+                    "var pos = -1;\n".
+                    "while( pos == -1 && i < f ) {\n".
+                        "var e = document.forms[i].elements.length;\n".
+                        "var j = 0;\n".
+                        "while( pos == -1 && j < e ) {\n".
+                            "if ( document.forms[i].elements[j].type == 'text' " .
+                            "|| document.forms[i].elements[j].type == 'password' ) {\n".
+                                "pos = j;\n".
+                            "}\n".
+                            "j++;\n".
                         "}\n".
                         "}\n".
-                        "j++;\n".
+                    "i++;\n".
+                    "}\n".
+                    "if( pos >= 0 ) {\n".
+                        "document.forms[i-1].elements[pos].focus();\n".
                     "}\n".
                     "}\n".
-                "i++;\n".
-                "}\n".
-                "if( pos >= 0 ) {\n".
-                    "document.forms[i-1].elements[pos].focus();\n".
-                "}\n".
-		"$xtra\n".
-            "}\n";
+	    	"$xtra\n".
+                "}\n";
 	    
 	    
-            if ($compose_new_win == '1') {
-                if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
-                    $compose_width = '640';
-                }
-                if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
-                    $compose_height = '550';
+                if ($compose_new_win == '1') {
+                    if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
+                        $compose_width = '640';
+                    }
+                    if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) {
+                        $compose_height = '550';
+                    }
+                    $js .= "function comp_in_new(comp_uri) {\n".
+    		     "       if (!comp_uri) {\n".
+		         '           comp_uri = "'.$compose_uri."\";\n".
+	    	     '       }'. "\n".
+                         '    var newwin = window.open(comp_uri' .
+                         ', "_blank",'.
+                         '"width='.$compose_width. ',height='.$compose_height.
+                         ',scrollbars=yes,resizable=yes");'."\n".
+                         "}\n\n";
+
                 }
                 }
-                $js .= "function comp_in_new(comp_uri) {\n".
-		     "       if (!comp_uri) {\n".
-		     '           comp_uri = "'.$compose_uri."\";\n".
-		     '       }'. "\n".
-                     '    var newwin = window.open(comp_uri' .
-                     ', "_blank",'.
-                     '"width='.$compose_width. ',height='.$compose_height.
-                     ',scrollbars=yes,resizable=yes");'."\n".
-                     "}\n\n";
-
-            }
-        $js .= "// -->\n". "</script>\n";
+            $js .= "// -->\n". "</script>\n";
 	
 	
+            $onload = 'onload="checkForm();"';
+            displayHtmlHeader ('SquirrelMail', $js);
+            break;   
 
 
-        $onload = 'onload="checkForm();"';
-        displayHtmlHeader ('SquirrelMail', $js);
-        break;   
-
+        }
+    } else {
+        /* do not use JavaScript */
+        displayHtmlHeader ('SquirrelMail');
+        $onload = '';
     }
     }
 
 
     echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";
     echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";
@@ -238,12 +248,7 @@ function displayPageHeader($color, $mailbox, $xtra='', $session=false) {
         . html_tag( 'tr', '', '', $color[4] ) ."\n"
         . html_tag( 'tr', '', '', $color[4] ) ."\n"
         . html_tag( 'td', '', 'left' ) ."\n";
         . html_tag( 'td', '', 'left' ) ."\n";
     $urlMailbox = urlencode($mailbox);
     $urlMailbox = urlencode($mailbox);
-    if ($compose_new_win == '1') {
-        echo '<a href="javascript:void(0)" onclick="comp_in_new()">'. _("Compose").'</a>';
-    }
-    else {
-        displayInternalLink ("src/compose.php?mailbox=$urlMailbox", _("Compose"), 'right');
-    } 
+    echo makeComposeLink('src/compose.php?mailbox='.$urlMailbox);
     echo "&nbsp;&nbsp;\n";
     echo "&nbsp;&nbsp;\n";
     displayInternalLink ('src/addressbook.php', _("Addresses"), 'right');
     displayInternalLink ('src/addressbook.php', _("Addresses"), 'right');
     echo "&nbsp;&nbsp;\n";
     echo "&nbsp;&nbsp;\n";
@@ -272,55 +277,57 @@ function displayPageHeader($color, $mailbox, $xtra='', $session=false) {
 /* blatently copied/truncated/modified from the above function */
 /* blatently copied/truncated/modified from the above function */
 function compose_Header($color, $mailbox) {
 function compose_Header($color, $mailbox) {
 
 
-    global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, 
-           $data_dir, $username, $frame_top, $compose_new_win;
-
-
-    $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
-    if (!isset($frame_top)) {
-        $frame_top = '_top';
-    }
+    global $javascript_on;
 
 
     /*
     /*
-        Locate the first displayable form element
-    */
-    switch ( $module ) {
-    case 'src/search.php':
-        $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1;
-        $onload = "onload=\"document.forms[$pos].elements[2].focus();\"";
-        displayHtmlHeader (_("Compose"));
-        break;
-    default:
-        $js = '<script language="JavaScript" type="text/javascript">' .
-             "\n<!--\n" .
-             "function checkForm() {\n".
-                "var f = document.forms.length;\n".
-                "var i = 0;\n".
-                "var pos = -1;\n".
-                "while( pos == -1 && i < f ) {\n".
-                    "var e = document.forms[i].elements.length;\n".
-                    "var j = 0;\n".
-                    "while( pos == -1 && j < e ) {\n".
-                        "if ( document.forms[i].elements[j].type == 'text' ) {\n".
-                            "pos = j;\n".
+     * Locate the first displayable form element (only when JavaScript on)
+     */
+    if($javascript_on) {
+        global $delimiter, $base_uri, $PHP_SELF, $data_dir, $username;
+
+        $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
+
+        switch ( $module ) {
+        case 'src/search.php':
+            $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1;
+            $onload = "onload=\"document.forms[$pos].elements[2].focus();\"";
+            displayHtmlHeader (_("Compose"));
+            break;
+        default:
+            $js = '<script language="JavaScript" type="text/javascript">' .
+                 "\n<!--\n" .
+                 "function checkForm() {\n".
+                    "var f = document.forms.length;\n".
+                    "var i = 0;\n".
+                    "var pos = -1;\n".
+                    "while( pos == -1 && i < f ) {\n".
+                        "var e = document.forms[i].elements.length;\n".
+                        "var j = 0;\n".
+                        "while( pos == -1 && j < e ) {\n".
+                            "if ( document.forms[i].elements[j].type == 'text' ) {\n".
+                                "pos = j;\n".
+                            "}\n".
+                            "j++;\n".
                         "}\n".
                         "}\n".
-                        "j++;\n".
+                    "i++;\n".
                     "}\n".
                     "}\n".
-                "i++;\n".
-                "}\n".
-                "if( pos >= 0 ) {\n".
-                    "document.forms[i-1].elements[pos].focus();\n".
-                "}\n".
-            "}\n";
-        $js .= "// -->\n".
-        	 "</script>\n";
-        $onload = 'onload="checkForm();"';
-        displayHtmlHeader (_("Compose"), $js);
-        break;   
-
+                    "if( pos >= 0 ) {\n".
+                        "document.forms[i-1].elements[pos].focus();\n".
+                    "}\n".
+                "}\n";
+            $js .= "// -->\n".
+            	 "</script>\n";
+            $onload = 'onload="checkForm();"';
+            displayHtmlHeader (_("Compose"), $js);
+            break;   
+        }
+    } else {
+        /* javascript off */
+        displayHtmlHeader(_("Compose"));
+        $onload = '';
     }
     }
 
 
     echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";
     echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";
 }
 }
 
 
-?>
+?>

+ 23 - 0
functions/strings.php

@@ -415,6 +415,29 @@ function TrimArray(&$array) {
     }
     }
 }   
 }   
 
 
+/* returns a link to the compose-page, taking in consideration
+ * the compose_in_new and javascript settings. */
+function makeComposeLink($url, $text = null)
+{
+    global $compose_new_win,$javascript_on;
+
+    if(!$text) {
+        $text = _("Compose");
+    }
+
+    if($compose_new_win != '1') {
+        return makeInternalLink($url, $text, 'right');
+    }
+
+    /* if we can use JS, use the fancy window, else just open a new one HTML-style */
+    if($javascript_on) {
+        sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION);
+        return '<a href="javascript:void(0)" onclick="comp_in_new(\''.$base_uri.$url.'\')">'. $text.'</a>';
+    }
+
+    return makeInternalLink($url, $text, '_blank');
+}
+
 $PHP_SELF = php_self();
 $PHP_SELF = php_self();
 
 
 ?>
 ?>

+ 2 - 7
functions/url_parser.php

@@ -35,7 +35,7 @@ $Email_RegExp_Match = '[0-9a-z]([-_.+]?[0-9a-z])*(%' . $Host_RegExp_Match .
     ')?@' . $Host_RegExp_Match;
     ')?@' . $Host_RegExp_Match;
 
 
 function parseEmail (&$body) {
 function parseEmail (&$body) {
-    global $color, $Email_RegExp_Match, $compose_new_win;
+    global $color, $Email_RegExp_Match;
     $sbody     = $body;
     $sbody     = $body;
     $addresses = array();
     $addresses = array();
 
 
@@ -47,12 +47,7 @@ function parseEmail (&$body) {
     }
     }
     /* Replace each email address with a compose URL */
     /* Replace each email address with a compose URL */
     foreach ($addresses as $email) {
     foreach ($addresses as $email) {
-        $comp_uri = '../src/compose.php?send_to='.urlencode($email);
-        if ($compose_new_win == '1') {
-            $comp_uri  = 'javascript:void(0)" onClick="comp_in_new('
-                       . "'$comp_uri'" . ')';
-        }
-        $comp_uri = '<a href="'.$comp_uri.'">'.$email.'</a>';
+        $comp_uri = makeComposeLink('src/compose.php?send_to='.urlencode($email), $email);
         $body = str_replace($email, $comp_uri, $body);
         $body = str_replace($email, $comp_uri, $body);
     }
     }
     /* Return number of unique addresses found */
     /* Return number of unique addresses found */

+ 7 - 15
plugins/listcommands/setup.php

@@ -21,8 +21,7 @@ function squirrelmail_plugin_init_listcommands () {
 }
 }
 
 
 function plugin_listcommands_menu() {
 function plugin_listcommands_menu() {
-    global $passed_id, $passed_ent_id, $color, $mailbox,
-           $message, $compose_new_win;
+    global $passed_id, $passed_ent_id, $color, $mailbox, $message;
 
 
     /**
     /**
      * Array of commands we can deal with from the header. The Reply option
      * Array of commands we can deal with from the header. The Reply option
@@ -55,28 +54,21 @@ function plugin_listcommands_menu() {
         if ($proto == 'mailto') {
         if ($proto == 'mailto') {
 
 
             if (($cmd == 'post') || ($cmd == 'owner')) {
             if (($cmd == 'post') || ($cmd == 'owner')) {
-                $url = 'compose.php?';
+                $url = 'src/compose.php?';
             } else {
             } else {
-                $url = "../plugins/listcommands/mailout.php?action=$cmd&amp;";
+                $url = "plugins/listcommands/mailout.php?action=$cmd&amp;";
             }
             }
             $url .= 'send_to=' . strtr($act,'?','&');
             $url .= 'send_to=' . strtr($act,'?','&');
 
 
-            if ($compose_new_win == '1') {
-                $output[] = "<a href=\"javascript:void(0)\" onclick=\"comp_in_new('$url')\">" . $fieldsdescr[$cmd] . '</a>';
-            }
-            else {
-                $output[] = '<a href="' . $url . '">' . $fieldsdescr[$cmd] . '</a>';
-            }
+            $output[] = makeComposeLink($url, $fieldsdescr[$cmd]);
+
             if ($cmd == 'post') {
             if ($cmd == 'post') {
 	        $url .= '&amp;passed_id='.$passed_id.
 	        $url .= '&amp;passed_id='.$passed_id.
 		        '&amp;mailbox='.urlencode($mailbox).
 		        '&amp;mailbox='.urlencode($mailbox).
 		        (isset($passed_ent_id)?'&amp;passed_ent_id='.$passed_ent_id:'');
 		        (isset($passed_ent_id)?'&amp;passed_ent_id='.$passed_ent_id:'');
                 $url .= '&amp;action=reply';
                 $url .= '&amp;action=reply';
-                if ($compose_new_win == '1') {
-                    $output[] = "<a href=\"javascript:void(0)\" onclick=\"comp_in_new('$url')\">" . $fieldsdescr['reply'] . '</a>';
-                } else {
-                    $output[] = '<a href="' . $url . '">' . $fieldsdescr['reply'] . '</a>';
-                }
+
+                $output[] = makeComposeLink($url, $fieldsdescr['reply']);
             }
             }
         } else if ($proto == 'href') {
         } else if ($proto == 'href') {
             $output[] = '<a href="' . $act . '" target="_blank">'
             $output[] = '<a href="' . $act . '" target="_blank">'

+ 3 - 7
src/addressbook.php

@@ -386,13 +386,9 @@ if ($showaddrlist) {
             html_tag( 'td', '', 'left', '', 'valign="top" width="1%" nowrap' ) . '&nbsp;';
             html_tag( 'td', '', 'left', '', 'valign="top" width="1%" nowrap' ) . '&nbsp;';
                 }
                 }
             $email = $abook->full_address($row);
             $email = $abook->full_address($row);
-            if ($compose_new_win == '1') {
-                echo '<a href="javascript:void(0)" onclick=comp_in_new("compose.php?send_to='.rawurlencode($email).'")>';
-            }
-            else {
-                echo '<A HREF="compose.php?send_to=' . rawurlencode($email).'">';
-            }
-            echo htmlspecialchars($row['email']) . '</A>&nbsp;</td>'."\n".
+            echo makeComposeLink('src/compose.php?send_to='.rawurlencode($email),
+                 htmlspecialchars($row['email']) ) .
+            '&nbsp;</td>'."\n".
             html_tag( 'td', '&nbsp;' . htmlspecialchars($row['label']) . '&nbsp;', 'left', '', 'valign="top" width="1%"' ) .
             html_tag( 'td', '&nbsp;' . htmlspecialchars($row['label']) . '&nbsp;', 'left', '', 'valign="top" width="1%"' ) .
             "</tr>\n";
             "</tr>\n";
             $line++;
             $line++;

+ 9 - 16
src/read_body.php

@@ -472,7 +472,7 @@ function formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message,
 
 
 function formatMenubar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_response) {
 function formatMenubar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_response) {
     global $base_uri, $draft_folder, $where, $what, $color, $sort,
     global $base_uri, $draft_folder, $where, $what, $color, $sort,
-           $startMessage, $compose_new_win, $PHP_SELF, $save_as_draft,
+           $startMessage, $PHP_SELF, $save_as_draft,
            $enable_forward_as_attachment;
            $enable_forward_as_attachment;
 
 
     $topbar_delimiter = '&nbsp;|&nbsp;';
     $topbar_delimiter = '&nbsp;|&nbsp;';
@@ -505,18 +505,11 @@ function formatMenubar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_resp
         $s .= '<a href="' . $delete_url . '">' . _("Delete") . '</a>';
         $s .= '<a href="' . $delete_url . '">' . _("Delete") . '</a>';
     }
     }
 
 
-    $comp_uri = $base_uri . 'src/compose.php' .
+    $comp_uri = 'src/compose.php' .
                             '?passed_id=' . $passed_id .
                             '?passed_id=' . $passed_id .
                             '&amp;mailbox=' . $urlMailbox .
                             '&amp;mailbox=' . $urlMailbox .
                             (isset($passed_ent_id)?'&amp;passed_ent_id='.$passed_ent_id:'');
                             (isset($passed_ent_id)?'&amp;passed_ent_id='.$passed_ent_id:'');
 
 
-    if ($compose_new_win == '1') {
-        $link_open  = '<a href="javascript:void(0)" onclick="comp_in_new(\'';
-        $link_close = '\')">';
-    } else {
-        $link_open  = '<a href="';
-        $link_close = '">';
-    }
     if (($mailbox == $draft_folder) && ($save_as_draft)) {
     if (($mailbox == $draft_folder) && ($save_as_draft)) {
         $comp_alt_uri = $comp_uri . '&amp;action=draft';
         $comp_alt_uri = $comp_uri . '&amp;action=draft';
         $comp_alt_string = _("Resume Draft");
         $comp_alt_string = _("Resume Draft");
@@ -526,7 +519,7 @@ function formatMenubar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_resp
     }
     }
     if (isset($comp_alt_uri)) {
     if (isset($comp_alt_uri)) {
         $s .= $topbar_delimiter;
         $s .= $topbar_delimiter;
-        $s .= $link_open . $comp_alt_uri . $link_close . $comp_alt_string . '</a>';
+        $s .= makeComposeLink($comp_alt_uri, $comp_alt_string);
     }
     }
 
 
     $s .= '</small></td><td align="center" width="33%"><small>';
     $s .= '</small></td><td align="center" width="33%"><small>';
@@ -594,25 +587,25 @@ function formatMenubar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_resp
     $s .= '</small></td>' . "\n" . 
     $s .= '</small></td>' . "\n" . 
           html_tag( 'td', '', 'right', '', 'width="33%" nowrap' ) . '<small>';
           html_tag( 'td', '', 'right', '', 'width="33%" nowrap' ) . '<small>';
     $comp_action_uri = $comp_uri . '&amp;action=forward';
     $comp_action_uri = $comp_uri . '&amp;action=forward';
-    $s .= $link_open . $comp_action_uri . $link_close . _("Forward") . '</a>';
+    $s .= makeComposeLink($comp_action_uri, _("Forward"));
 
 
     if ($enable_forward_as_attachment) {
     if ($enable_forward_as_attachment) {
         $comp_action_uri = $comp_uri . '&amp;action=forward_as_attachment';
         $comp_action_uri = $comp_uri . '&amp;action=forward_as_attachment';
         $s .= $topbar_delimiter;
         $s .= $topbar_delimiter;
-        $s .= $link_open . $comp_action_uri . $link_close . _("Forward as Attachment") . '</a>';
+        $s .= makeComposeLink($comp_action_uri, _("Forward as Attachment"));
     }
     }
 
 
     $comp_action_uri = $comp_uri . '&amp;action=reply';
     $comp_action_uri = $comp_uri . '&amp;action=reply';
     $s .= $topbar_delimiter;
     $s .= $topbar_delimiter;
-    $s .= $link_open . $comp_action_uri . $link_close . _("Reply") . '</a>';
+    $s .= makeComposeLink($comp_action_uri, _("Reply"));
 
 
     $comp_action_uri = $comp_uri . '&amp;action=reply_all';
     $comp_action_uri = $comp_uri . '&amp;action=reply_all';
     $s .= $topbar_delimiter;
     $s .= $topbar_delimiter;
-    $s .= $link_open . $comp_action_uri . $link_close . _("Reply All") . '</a>';
+    $s .= makeComposeLink($comp_action_uri, _("Reply All"));
     $s .= '</small></td></tr></table>';
     $s .= '</small></td></tr></table>';
-    do_hook("read_body_menu_top");
+    do_hook('read_body_menu_top');
     echo $s;
     echo $s;
-    do_hook("read_body_menu_bottom");
+    do_hook('read_body_menu_bottom');
 }
 }
 
 
 function formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color) {
 function formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color) {

+ 4 - 3
src/vcard.php

@@ -115,10 +115,11 @@ $ShowValues = array(
 echo '<tr><td><br>' .
 echo '<tr><td><br>' .
         '<TABLE border=0 cellpadding=2 cellspacing=0 align=center>' . "\n";
         '<TABLE border=0 cellpadding=2 cellspacing=0 align=center>' . "\n";
 
 
-if (isset($vcard_safe['email;internet'])) {     $vcard_safe['email;internet'] = '<A HREF="../src/compose.php?send_to=' .
-        $vcard_safe['email;internet'] . '">' . $vcard_safe['email;internet'] .
-        '</A>';
+if (isset($vcard_safe['email;internet'])) {
+    $vcard_safe['email;internet'] = makeComposeLink('src/compose.php?send_to='.urlencode($vcard_safe['email;internet']),
+        $vcard_safe['email;internet']);
 }
 }
+
 if (isset($vcard_safe['url'])) {
 if (isset($vcard_safe['url'])) {
     $vcard_safe['url'] = '<A HREF="' . $vcard_safe['url'] . '">' .
     $vcard_safe['url'] = '<A HREF="' . $vcard_safe['url'] . '">' .
         $vcard_safe['url'] . '</A>';
         $vcard_safe['url'] . '</A>';