Added a "compose in new window" option located in display prefs. Each file that calls...
authorjmunro <jmunro@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 11 Feb 2002 18:25:59 +0000 (18:25 +0000)
committerjmunro <jmunro@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 11 Feb 2002 18:25:59 +0000 (18:25 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2410 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/page_header.php
functions/url_parser.php
plugins/listcommands/setup.php
src/addrbook_search_html.php
src/addressbook.php
src/compose.php
src/delete_message.php
src/load_prefs.php
src/options_display.php
src/read_body.php

index 6e64f67..fc2655d 100644 (file)
@@ -49,7 +49,7 @@ function displayInternalLink($path, $text, $target='') {
 
 function displayPageHeader($color, $mailbox) {
 
-    global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, $frame_top;
+    global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, $frame_top, $compose_new_win, $username, $datadir;
 
     displayHtmlHeader ();
 
@@ -87,16 +87,30 @@ function displayPageHeader($color, $mailbox) {
                 "if( pos >= 0 ) {\n".
                     "document.forms[i-1].elements[pos].focus();\n".
                 "}\n".
-            "}\n".
-            "// -->\n".
-            "</script>\n";
+            "}\n";
+            if ($compose_new_win == '1') {
+                $width= getPref($username, $datadir, 'editor_size', 76);
+                if ($width < 65) {
+                    $pix_width = 560;
+                }
+                else {
+                    $width = (.9*$width);
+                    $pix_width = intval($width).'0';
+                }
+                echo "function comp_in_new() {\n".
+                     "    var newwin = window.open(\"".$base_uri."src/compose.php\"".
+                     ", \"compose_window\", \"width=".$pix_width.",height=650".
+                     ",scrollbars=yes,resizable=yes\");\n".
+                     "}\n";
+            }
+        echo "// -->\n".
+                "</script>\n";
         $onload = "onLoad=\"checkForm();\"";
         break;   
 
     }
 
     echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\" $onload>\n\n";
-
     /** Here is the header and wrapping table **/
     $shortBoxName = readShortMailboxName($mailbox, $delimiter);
     if ( $shortBoxName == 'INBOX' ) {
@@ -119,7 +133,13 @@ function displayPageHeader($color, $mailbox) {
         . "   <TR BGCOLOR=\"$color[4]\">\n"
         . "      <TD ALIGN=left>\n";
     $urlMailbox = urlencode($mailbox);
-    displayInternalLink ("src/compose.php?mailbox=$urlMailbox", _("Compose"), 'right');
+    if ($compose_new_win == '1') {
+        echo "<a href=$base_uri". "src/compose.php?mailbox=$urlMailbox target=".
+             '"compose_window" onClick="comp_in_new()">Compose</a>';
+    }
+    else {
+        displayInternalLink ("src/compose.php?mailbox=$urlMailbox", _("Compose"), 'right');
+    } 
     echo "&nbsp;&nbsp;\n";
     displayInternalLink ("src/addressbook.php", _("Addresses"), 'right');
     echo "&nbsp;&nbsp;\n";
@@ -142,4 +162,70 @@ function displayPageHeader($color, $mailbox) {
         "</TABLE>\n\n";
 }
 
+/* blatently copied/truncated/modified from the above function */
+function compose_Header($color, $mailbox) {
+
+    global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, $frame_top, $compose_new_win;
+
+    displayHtmlHeader ('Compose');
+
+    $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 );
+    if (!isset($frame_top)) {
+        $frame_top = '_top';
+    }
+
+    /*
+        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();\"";
+        break;
+    default:
+        echo '<script language="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".
+                "i++;\n".
+                "}\n".
+                "if( pos >= 0 ) {\n".
+                    "document.forms[i-1].elements[pos].focus();\n".
+                "}\n".
+            "}\n";
+            if ($compose_new_win == '1') {
+                $width= getPref($username, $datadir, 'editor_size', 76);
+                if ($width < 65) {
+                    $pix_width = 560;
+                }
+                else {
+                    $width = (.9*$width);
+                    $pix_width = intval($width).'0';
+                }
+                echo "function comp_in_new() {\n".
+                     "    var newwin = window.open(\"".$base_uri."src/compose.php\"".
+                     ", \"compose_window\", \"width=".$pix_width.",height=650".
+                     ",scrollbars=yes,resizable=yes\");\n".
+                     "}\n";
+            }
+        echo "// -->\n".
+                "</script>\n";
+        $onload = "onLoad=\"checkForm();\"";
+        break;   
+
+    }
+
+    echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\" $onload>\n\n";
+}
 ?>
index 635c24f..f084a43 100644 (file)
@@ -35,7 +35,7 @@ $Email_RegExp_Match = '[0-9a-z]([-_.+]?[0-9a-z])*(%' . $Host_RegExp_Match .
     ')?@' . $Host_RegExp_Match;
       
 function parseEmail (&$body) {
-    global $color, $Email_RegExp_Match;
+    global $color, $Email_RegExp_Match, $compose_new_win;
     $Size = strlen($body);
       
     /*
@@ -55,8 +55,13 @@ function parseEmail (&$body) {
      */
      
     if( eregi($Email_RegExp_Match, $body, $regs) ) {
-        $body = str_replace($regs[0],  '<a href="../src/compose.php?send_to='.
+               if ($compose_new_win == '1') {
+               $body = str_replace($regs[0],  '<a href="../src/compose.php?send_to='.urlencode($regs[0]).'" target="compose_window" onClick="comp_in_new()">'.$regs[0].'</a>', $body);
+               }
+               else {
+               $body = str_replace($regs[0],  '<a href="../src/compose.php?send_to='.
             urlencode($regs[0]).'">'.$regs[0].'</a>', $body);
+               }
     } 
 
     /* If there are any changes, it'll just get bigger. */
index a6c0baa..aa7dba0 100644 (file)
@@ -22,7 +22,7 @@ function squirrelmail_plugin_init_listcommands () {
 
 function plugin_listcommands_menu() {
     global $imapConnection, $passed_id, $color, $mailbox,
-           $subject, $ent_num, $priority_level;
+           $subject, $ent_num, $priority_level, $compose_new_win;
 
     /**
      * Array of commands we can deal with from the header. The Reply option
@@ -83,16 +83,24 @@ function plugin_listcommands_menu() {
             if (isset($purl['query'])) {
                 $url .= '&' . $purl['query'];
             }
-
-            $output[] = '<A HREF="' . $url . '">' . $fieldsdescr[$cmd] . '</A>';
-
+            if ($compose_new_win == '1') {
+                $output[] = '<A HREF="' . $url . '" target="compose_window" onClick="comp_in_new()">' . $fieldsdescr[$cmd] . '</A>';
+            }
+            else {
+                $output[] = '<A HREF="' . $url . '">' . $fieldsdescr[$cmd] . '</A>';
+            }
             if ($cmd == 'Post') {
                 $url .= '&reply_subj=' . urlencode($subject)
                       . '&reply_id=' . $passed_id
                       . '&ent_num=' . $ent_num
                       . '&mailprio=' . $priority_level;
+            if ($compose_new_win == '1') {
+                $output[] = '<A HREF="' . $url . '" target="compose_window" onClick="comp_in_new()">' . $fieldsdescr['Reply'] . '</A>';
+            }
+            else {
                 $output[] = '<A HREF="' . $url . '">' . $fieldsdescr['Reply'] . '</A>';
             }
+            }
         } else if (eregi('^(http|ftp)', $url)) {
             $output[] = '<A HREF="' . $url . '" TARGET="_blank">'
                       . $fieldsdescr[$cmd] . '</A>';
index 4b16fe1..81cb0bc 100644 (file)
@@ -105,8 +105,12 @@ function addr_display_result($res, $includesource = true) {
 /* --- End functions --- */
 
 global $mailbox;
-displayPageHeader($color, $mailbox);
-
+if ($compose_new_win == '1') {
+    compose_Header($color, $mailbox);
+}
+else {
+    displayPageHeader($color, $mailbox);
+}
 /* Initialize addressbook */
 $abook = addressbook_init();
 
index ac99586..bfeac24 100644 (file)
@@ -310,8 +310,11 @@ if ($showaddrlist) {
                  '<TD VALIGN=top NOWRAP WIDTH="1%">&nbsp;' . $row['name'] .
                  '&nbsp;</TD>',
                  '<TD VALIGN=top NOWRAP WIDTH="1%">&nbsp;' .
-                 '<A HREF="compose.php?send_to=' . rawurlencode($row['email']) .
-                 '">' . $row['email'] . '</A>&nbsp;</TD>'."\n",
+                 '<A HREF="compose.php?send_to=' . rawurlencode($row['email']);
+                if ($compose_new_win == '1') {
+                     echo '" TARGET="compose_window" onClick="comp_in_new()"';
+                }
+                echo '">' . $row['email'] . '</A>&nbsp;</TD>'."\n",
                  '<TD VALIGN=top WIDTH="1%">&nbsp;' . $row['label'] . '&nbsp;</TD>' .
                  "</TR>\n";
             $line++;
index 9a02057..78d1690 100644 (file)
@@ -44,12 +44,19 @@ if (isset($draft)) {
         /* If this is a resumed draft, then delete the original */
         if(isset($delete_draft)) {
             Header("Location: delete_message.php?mailbox=$draft_folder".
-                   "&message=$delete_draft&sort=$sort&startMessage=1");
+                   "&message=$delete_draft&sort=$sort&startMessage=1&saved_draft=yes");
             exit();
-        } else {
+        } 
+        else {
+            if ($compose_new_win == '1') {
+                Header("Location: compose.php?saved_draft=yes");
+            exit();
+            }
+            else {
             Header("Location: right_main.php?mailbox=$draft_folder&sort=$sort".
                    "&startMessage=1&note=$draft_message");
             exit();
+            }
         }
     }
 }
@@ -115,19 +122,27 @@ if (isset($send)) {
         }
         if ( isset($delete_draft)) {
             Header("Location: delete_message.php?mailbox=$draft_folder".
-                   "&message=$delete_draft&sort=$sort&startMessage=1");
+                   "&message=$delete_draft&sort=$sort&startMessage=1&mail_sent=yes");
             exit();
         }
-
-        Header("Location: right_main.php?mailbox=$urlMailbox&sort=$sort".
-               "&startMessage=1");
+        if ($compose_new_win == '1') {
+            Header("Location: compose.php?mail_sent=yes");
+        }
+        else {
+            Header("Location: right_main.php?mailbox=$urlMailbox&sort=$sort".
+                   "&startMessage=1");
+        }
     } else {
         /*
          *$imapConnection = sqimap_login($username, $key, $imapServerAddress,
          *                               $imapPort, 0);
          */
-        displayPageHeader($color, $mailbox);
-
+        if ($compose_new_win == '1') {
+            compose_Header($color, $mailbox);
+        }
+        else {
+            displayPageHeader($color, $mailbox);
+        }
         if (isset($AttachFailure)) {
              plain_error_message(_("Could not move/copy file. File not attached"),
                                  $color);
@@ -139,7 +154,12 @@ if (isset($send)) {
     }
 }
 elseif (isset($html_addr_search_done)) {
-    displayPageHeader($color, $mailbox);
+        if ($compose_new_win == '1') {
+            compose_Header($color, $mailbox);
+        }
+        else {
+            displayPageHeader($color, $mailbox);
+        }
 
     if (isset($send_to_search) && is_array($send_to_search)) {
         foreach ($send_to_search as $k => $v) {
@@ -183,11 +203,21 @@ elseif (isset($attach)) {
     if (saveAttachedFiles()) {
         plain_error_message(_("Could not move/copy file. File not attached"), $color);
     }
-    displayPageHeader($color, $mailbox);
+        if ($compose_new_win == '1') {
+            compose_Header($color, $mailbox);
+        }
+        else {
+            displayPageHeader($color, $mailbox);
+        }
     showInputForm();
 }
 elseif (isset($do_delete)) {
-    displayPageHeader($color, $mailbox);
+        if ($compose_new_win == '1') {
+            compose_Header($color, $mailbox);
+        }
+        else {
+            displayPageHeader($color, $mailbox);
+        }
 
     $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
     if (isset($delete) && is_array($delete)) {
@@ -207,7 +237,12 @@ elseif (isset($do_delete)) {
      */
     $imapConnection = sqimap_login($username, $key, $imapServerAddress,
                                    $imapPort, 0);
-    displayPageHeader($color, $mailbox);
+        if ($compose_new_win == '1') {
+            compose_Header($color, $mailbox);
+        }
+        else {
+            displayPageHeader($color, $mailbox);
+        }
 
     $newmail = true;
 
@@ -420,7 +455,8 @@ function showInputForm () {
            $use_javascript_addr_book, $send_to_bcc, $reply_id, $mailbox,
            $from_htmladdr_search, $location_of_buttons, $attachment_dir,
            $username, $data_dir, $identity, $draft_id, $delete_draft,
-           $mailprio, $default_use_mdn, $mdn_user_support;
+           $mailprio, $default_use_mdn, $mdn_user_support, $compose_new_win,
+           $saved_draft, $mail_sent;
 
     $subject = decodeHeader($subject, false);
     $reply_subj = decodeHeader($reply_subj, false);
@@ -450,9 +486,16 @@ function showInputForm () {
     if (isset($delete_draft)) {
         echo '<input type="hidden" name="delete_draft" value="' . $delete_draft. "\">\n";
     }
-
+    if ($saved_draft == 'yes') {
+        echo '<BR><CENTER><B>'. _("Draft Saved").'</CENTER></B>';
+    }
+    if ($mail_sent == 'yes') {
+        echo '<BR><CENTER><B>'. _("Your Message has been sent").'</CENTER></B>';
+    }
     echo '<TABLE WIDTH="100%" ALIGN=center CELLSPACING=0 BORDER=0>' . "\n";
-
+    if ($compose_new_win == '1') {
+        echo '   <TR><TD></TD><TD ALIGN="RIGHT"><INPUT TYPE="BUTTON" NAME="Close" onClick="return self.close()" VALUE="Close"></TD></TR>'."\n";
+    }
     if ($location_of_buttons == 'top') {
         showComposeButtonRow();
     }
index 1862922..80094bc 100644 (file)
@@ -23,14 +23,22 @@ sqimap_messages_delete($imapConnection, $message, $message, $mailbox);
 if ($auto_expunge) {
     sqimap_mailbox_expunge($imapConnection, $mailbox, true);
 }
+if (!isset($saved_draft)) {
+    $saved_draft = '';
+}
 
 $location = get_location();
 if (isset($where) && isset($what)) {
     header("Location: $location/search.php?where=" . urlencode($where) .
            '&what=' . urlencode($what) . '&mailbox=' . urlencode($mailbox));
 } else {
+    if ($compose_new_win == '1') {
+          header("Location: $location/compose.php?mail_sent=$mail_sent&saved_draft=$saved_draft");
+    }
+    else {
     header("Location: $location/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=" .
            urlencode($mailbox));
+    }
 }
 
 sqimap_logout($imapConnection);
index acd61f7..4c9a0b2 100644 (file)
@@ -205,6 +205,9 @@ $page_selector_max = getPref($data_dir, $username, 'page_selector_max', 10);
 $date_format = getPref($data_dir, $username, 'date_format', 3);
 $hour_format = getPref($data_dir, $username, 'hour_format', 2);
 
+/*  compose in new window setting */
+$compose_new_win = getPref($data_dir, $username, 'compose_new_win', 0);
+
 /* Load the javascript settings. */
 $javascript_setting =
     getPref($data_dir, $username, 'javascript_setting', SMPREF_JS_AUTODETECT);
@@ -215,4 +218,4 @@ $search_memory = getPref($data_dir, $username, 'search_memory', 0);
 
 do_hook('loading_prefs');
 
-?>
\ No newline at end of file
+?>
index ec88146..59fa470 100644 (file)
@@ -233,7 +233,12 @@ function load_optpage_data_display() {
             'refresh' => SMOPT_REFRESH_NONE
         );
     }
-
+    $optvals[SMOPT_GRP_MESSAGE][] = array(
+        'name'    => 'compose_new_win',
+        'caption' => _("Always compose in a new window"),
+        'type'    => SMOPT_TYPE_BOOLEAN,
+        'refresh' => SMOPT_REFRESH_ALL
+    );
     /* Assemble all this together and return it as our result. */
     $result = array(
         'grps' => $optgrps,
index a8eb305..165b642 100644 (file)
@@ -519,6 +519,9 @@ if (isset ($message->header->cc[0]) && trim($message->header->cc[0])) {
         }
     }
 }
+else {
+    $cc_string = '';
+}
 
 /** FORMAT THE BCC STRING **/
 $i = 0;
@@ -560,6 +563,9 @@ if (isset ($message->header->bcc[0]) && trim($message->header->bcc[0])){
         }
     }
 }
+else {
+    $bcc_string = '';
+}
 
 if ($default_use_priority) {
     $priority_level = substr($message->header->priority,0,1);
@@ -620,7 +626,11 @@ if ($where && $what) {
 echo _("Delete") . '</A>&nbsp;';
 if (($mailbox == $draft_folder) && ($save_as_draft)) {
     echo '|&nbsp;<A HREF="' . $base_uri .
-         "src/compose.php?mailbox=$mailbox&send_to=$to_string&send_to_cc=$cc_string&send_to_bcc=$bcc_string&subject=$url_subj&draft_id=$passed_id&ent_num=$ent_num\">".
+         "src/compose.php?mailbox=$mailbox&send_to=$to_string&send_to_cc=$cc_string&send_to_bcc=$bcc_string&subject=$url_subj&draft_id=$passed_id&ent_num=$ent_num\"";
+    if ($compose_new_win == '1') {
+        echo 'TARGET="compose_window" onClick="comp_in_new()"';
+    }
+    echo '>'.
          _("Resume Draft") . '</a>';
 }
 
@@ -657,17 +667,29 @@ echo                '</SMALL>' .
                    '<SMALL>' .
                    '<A HREF="' . $base_uri . "src/compose.php?forward_id=$passed_id&forward_subj=$url_subj&".
                     ($default_use_priority?"mailprio=$priority_level&":"")
-                    ."mailbox=$urlMailbox&ent_num=$ent_num\">" .
+                    ."mailbox=$urlMailbox&ent_num=$ent_num\"";
+    if ($compose_new_win == '1') {
+        echo 'TARGET="compose_window" onClick="comp_in_new()"';
+    }
+    echo '>'.
     _("Forward") .
     '</A>&nbsp;|&nbsp;' .
                    '<A HREF="' . $base_uri . "src/compose.php?send_to=$url_replyto&reply_subj=$url_subj&".
                     ($default_use_priority?"mailprio=$priority_level&":"").
-                    "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\">" .
+                    "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\"";
+    if ($compose_new_win == '1') {
+        echo 'TARGET="compose_window" onClick="comp_in_new()"';
+    }
+    echo '>'.
     _("Reply") .
     '</A>&nbsp;|&nbsp;' .
                    '<A HREF="' . $base_uri . "src/compose.php?send_to=$url_replytoall&send_to_cc=$url_replytoallcc&reply_subj=$url_subj&".
                     ($default_use_priority?"mailprio=$priority_level&":"").
-                    "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\">" .
+                    "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\"";
+    if ($compose_new_win == '1') {
+        echo 'TARGET="compose_window" onClick="comp_in_new()"';
+    }
+    echo '>'.
     _("Reply All") .
     '</A>&nbsp;&nbsp;' .
                    '</SMALL>' .