From 9c3e6cd4518d9e0d072a146fd6d19acd4daac243 Mon Sep 17 00:00:00 2001 From: jmunro Date: Mon, 11 Feb 2002 18:25:59 +0000 Subject: [PATCH] Added a "compose in new window" option located in display prefs. Each file that calls compose.php has been modified git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2410 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/page_header.php | 98 +++++++++++++++++++++++++++++++--- functions/url_parser.php | 9 +++- plugins/listcommands/setup.php | 16 ++++-- src/addrbook_search_html.php | 8 ++- src/addressbook.php | 7 ++- src/compose.php | 73 +++++++++++++++++++------ src/delete_message.php | 8 +++ src/load_prefs.php | 5 +- src/options_display.php | 7 ++- src/read_body.php | 30 +++++++++-- 10 files changed, 224 insertions(+), 37 deletions(-) diff --git a/functions/page_header.php b/functions/page_header.php index 6e64f679..fc2655d4 100644 --- a/functions/page_header.php +++ b/functions/page_header.php @@ -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". - "\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". + "\n"; $onload = "onLoad=\"checkForm();\""; break; } echo "\n\n"; - /** Here is the header and wrapping table **/ $shortBoxName = readShortMailboxName($mailbox, $delimiter); if ( $shortBoxName == 'INBOX' ) { @@ -119,7 +133,13 @@ function displayPageHeader($color, $mailbox) { . " \n" . " \n"; $urlMailbox = urlencode($mailbox); - displayInternalLink ("src/compose.php?mailbox=$urlMailbox", _("Compose"), 'right'); + if ($compose_new_win == '1') { + echo "Compose'; + } + else { + displayInternalLink ("src/compose.php?mailbox=$urlMailbox", _("Compose"), 'right'); + } echo "  \n"; displayInternalLink ("src/addressbook.php", _("Addresses"), 'right'); echo "  \n"; @@ -142,4 +162,70 @@ function displayPageHeader($color, $mailbox) { "\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 '\n"; + $onload = "onLoad=\"checkForm();\""; + break; + + } + + echo "\n\n"; +} ?> diff --git a/functions/url_parser.php b/functions/url_parser.php index 635c24f2..f084a430 100644 --- a/functions/url_parser.php +++ b/functions/url_parser.php @@ -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], ''.$regs[0].'', $body); + } + else { + $body = str_replace($regs[0], ''.$regs[0].'', $body); + } } /* If there are any changes, it'll just get bigger. */ diff --git a/plugins/listcommands/setup.php b/plugins/listcommands/setup.php index a6c0baaa..aa7dba06 100644 --- a/plugins/listcommands/setup.php +++ b/plugins/listcommands/setup.php @@ -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[] = '' . $fieldsdescr[$cmd] . ''; - + if ($compose_new_win == '1') { + $output[] = '' . $fieldsdescr[$cmd] . ''; + } + else { + $output[] = '' . $fieldsdescr[$cmd] . ''; + } 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[] = '' . $fieldsdescr['Reply'] . ''; + } + else { $output[] = '' . $fieldsdescr['Reply'] . ''; } + } } else if (eregi('^(http|ftp)', $url)) { $output[] = '' . $fieldsdescr[$cmd] . ''; diff --git a/src/addrbook_search_html.php b/src/addrbook_search_html.php index 4b16fe1e..81cb0bc4 100644 --- a/src/addrbook_search_html.php +++ b/src/addrbook_search_html.php @@ -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(); diff --git a/src/addressbook.php b/src/addressbook.php index ac99586a..bfeac242 100644 --- a/src/addressbook.php +++ b/src/addressbook.php @@ -310,8 +310,11 @@ if ($showaddrlist) { ' ' . $row['name'] . ' ', ' ' . - '' . $row['email'] . ' '."\n", + '' . $row['email'] . ' '."\n", ' ' . $row['label'] . ' ' . "\n"; $line++; diff --git a/src/compose.php b/src/compose.php index 9a020574..78d16906 100644 --- a/src/compose.php +++ b/src/compose.php @@ -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¬e=$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 '\n"; } - + if ($saved_draft == 'yes') { + echo '
'. _("Draft Saved").'
'; + } + if ($mail_sent == 'yes') { + echo '
'. _("Your Message has been sent").'
'; + } echo '' . "\n"; - + if ($compose_new_win == '1') { + echo ' '."\n"; + } if ($location_of_buttons == 'top') { showComposeButtonRow(); } diff --git a/src/delete_message.php b/src/delete_message.php index 18629228..80094bc3 100644 --- a/src/delete_message.php +++ b/src/delete_message.php @@ -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); diff --git a/src/load_prefs.php b/src/load_prefs.php index acd61f77..4c9a0b2e 100644 --- a/src/load_prefs.php +++ b/src/load_prefs.php @@ -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 +?> diff --git a/src/options_display.php b/src/options_display.php index ec881463..59fa4705 100644 --- a/src/options_display.php +++ b/src/options_display.php @@ -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, diff --git a/src/read_body.php b/src/read_body.php index a8eb3056..165b6429 100644 --- a/src/read_body.php +++ b/src/read_body.php @@ -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") . ' '; if (($mailbox == $draft_folder) && ($save_as_draft)) { echo '| ". + "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") . ''; } @@ -657,17 +667,29 @@ echo '' . '' . '" . + ."mailbox=$urlMailbox&ent_num=$ent_num\""; + if ($compose_new_win == '1') { + echo 'TARGET="compose_window" onClick="comp_in_new()"'; + } + echo '>'. _("Forward") . ' | ' . '" . + "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") . ' | ' . '" . + "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") . '  ' . '' . -- 2.25.1