From 1a531551726e16fe9ccbd8de06731c1730d8fce2 Mon Sep 17 00:00:00 2001 From: ebullient Date: Sun, 28 Mar 2004 20:45:20 +0000 Subject: [PATCH] finish "buttonizing" read_body header. Correct some mistakes (compose_in_new, resume draft, edit as new) Centralize javascript detection in prefs.php - checkForJavascript Move javascript_on from prefs to session - have just javascript_setting in prefs. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@6917 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- ChangeLog | 4 +++ functions/imap_general.php | 2 ++ functions/mailbox_display.php | 9 ++++--- functions/page_header.php | 47 +++++++++++++++++++---------------- functions/prefs.php | 20 +++++++++++++++ include/load_prefs.php | 15 +++++------ include/options/display.php | 12 ++------- src/compose.php | 2 ++ src/read_body.php | 41 +++++++++++++++++++----------- src/redirect.php | 19 +------------- 10 files changed, 97 insertions(+), 74 deletions(-) diff --git a/ChangeLog b/ChangeLog index 31a26b3b..124a0902 100644 --- a/ChangeLog +++ b/ChangeLog @@ -29,7 +29,11 @@ Version 1.5.1 -- CVS (#915527). - Remove code related to non-UID-supporting IMAP servers. - Fix quoteimap() regex escaping problem (#921291). + - Added option to suppress Received: line in outbound SM headers (#847107) + - Changed read_body header from links to buttons (looks like message index) - Add functions for building HTML forms (functions/forms.php). + - Moved javascript_on to session (from prefs). Centralized javascript detection + in prefs.php method checkForJavascript. Version 1.5.0 -------------------- diff --git a/functions/imap_general.php b/functions/imap_general.php index 640de0a8..d353d512 100755 --- a/functions/imap_general.php +++ b/functions/imap_general.php @@ -190,6 +190,7 @@ function sqimap_fgets($imap_stream) { $offset = strlen($results) - 1; } $results .= $read; +#sm_print_r("Trace from line " . __LINE__, $results); } return $results; } @@ -251,6 +252,7 @@ function sqimap_fread($imap_stream,$iSize,$filter=false, } else { $results .= $sRead; } +#sm_print_r("Trace from line " . __LINE__, $results); } return $results; } diff --git a/functions/mailbox_display.php b/functions/mailbox_display.php index 35ee5d4a..0538fd6e 100644 --- a/functions/mailbox_display.php +++ b/functions/mailbox_display.php @@ -831,11 +831,11 @@ function mail_message_listing_beginning ($imapConnection, // display flag buttons only if supported if ($show_flag_buttons && $mbxresponse != NULL && strpos($mbxresponse['PERMANENTFLAGS'], '\Flagged') !== FALSE) { - echo getButton('SUBMIT', 'markUnflagged',_("Un")); + echo getButton('SUBMIT', 'markUnflagged',_("Unflag")); echo getButton('SUBMIT', 'markFlagged',_("Flag")); echo ' '; } - echo getButton('SUBMIT', 'markUnread',_("Un")); + echo getButton('SUBMIT', 'markUnread',_("Unread")); echo getButton('SUBMIT', 'markRead',_("Read")); echo ' '; @@ -1366,9 +1366,10 @@ function getMbxList($imapConnection, $boxes = 0) { echo '  '; } -function getButton($type, $name, $value, $enabled = TRUE) { +function getButton($type, $name, $value, $js = '', $enabled = TRUE) { $disabled = ( $enabled ? '' : 'disabled ' ); - return '\n"; + "\n"; $onload = 'onload="checkForm();"'; displayHtmlHeader ('SquirrelMail', $js); break; @@ -241,9 +246,9 @@ function displayPageHeader($color, $mailbox, $xtra='', $session=false) { "if( pos >= 0 ) {\n". "document.forms[i-1].elements[pos].focus();\n". "}\n". - "$xtra\n". + "$xtra\n". "}\n"; - + if ($compose_new_win == '1') { if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) { $compose_width = '640'; @@ -252,9 +257,9 @@ function displayPageHeader($color, $mailbox, $xtra='', $session=false) { $compose_height = '550'; } $js .= "function comp_in_new(comp_uri) {\n". - " if (!comp_uri) {\n". - ' comp_uri = "'.$compose_uri."\";\n". - ' }'. "\n". + " if (!comp_uri) {\n". + ' comp_uri = "'.$compose_uri."\";\n". + ' }'. "\n". ' var newwin = window.open(comp_uri' . ', "_blank",'. '"width='.$compose_width. ',height='.$compose_height. @@ -263,7 +268,7 @@ function displayPageHeader($color, $mailbox, $xtra='', $session=false) { } $js .= "// -->\n". "\n"; - + $onload = 'onload="checkForm();"'; displayHtmlHeader ('SquirrelMail', $js); break; @@ -387,7 +392,7 @@ function compose_Header($color, $mailbox) { "}\n". "}\n"; $js .= "// -->\n". - "\n"; + "\n"; $onload = 'onload="checkForm();"'; displayHtmlHeader (_("Compose"), $js); break; diff --git a/functions/prefs.php b/functions/prefs.php index 112d7572..dd97204b 100644 --- a/functions/prefs.php +++ b/functions/prefs.php @@ -145,4 +145,24 @@ function computeHashDirs($username) { return ($hash_dirs); } +function checkForJavascript() +{ + global $data_dir, $username, $javascript_on; + if ( sqGetGlobalVar('javascript_on', $javascript_on) ) + return; + + if ( !sqGetGlobalVar('js_autodetect_results', $js_autodetect_results) ) + $js_autodetect_results = SMPREF_JS_OFF; + + $javascript_setting = getPref($data_dir, $username, 'javascript_setting', SMPREF_JS_AUTODETECT); + + if ( $javascript_setting == SMPREF_JS_AUTODETECT ) + $js_pref = $js_autodetect_results; + else + $js_pref = $javascript_setting; + + sqsession_register('javascript_on',$js_pref); + return $js_pref; +} + ?> diff --git a/include/load_prefs.php b/include/load_prefs.php index 72eb0c6b..69e2724b 100644 --- a/include/load_prefs.php +++ b/include/load_prefs.php @@ -83,8 +83,6 @@ $icon_theme = getPref($data_dir, $username, 'icon_theme', 'none' ); // show (or not) flag and unflag buttons on mailbox list screen $show_flag_buttons = getPref($data_dir, $username, 'show_flag_buttons', SMPREF_OFF ); -$use_javascript_addr_book = getPref($data_dir, $username, 'use_javascript_addr_book', $default_use_javascript_addr_book); - /* Load the user's special folder preferences */ $move_to_sent = getPref($data_dir, $username, 'move_to_sent', $default_move_to_sent); @@ -216,7 +214,6 @@ $alt_index_colors = getPref($data_dir, $username, 'alt_index_colors', SMPREF_ON ); /* Folder List Display Format */ -$use_javascript_folder_list = getPref($data_dir, $username, 'use_javascript_folder_list'); $location_of_bar = getPref($data_dir, $username, 'location_of_bar', SMPREF_LOC_LEFT); $location_of_buttons = @@ -268,10 +265,14 @@ $internal_date_sort = getPref($data_dir, $username, 'internal_date_sort', SMPREF $sort_by_ref = getPref($data_dir, $username, 'sort_by_ref', 1); /* Load the javascript settings. */ -$javascript_setting = - getPref($data_dir, $username, 'javascript_setting', SMPREF_JS_AUTODETECT); -$javascript_on = getPref($data_dir, $username, 'javascript_on', SMPREF_ON); - +if ( checkForJavascript() ) +{ + $use_javascript_folder_list = getPref($data_dir, $username, 'use_javascript_folder_list'); + $use_javascript_addr_book = getPref($data_dir, $username, 'use_javascript_addr_book', $default_use_javascript_addr_book); +} else { + $use_javascript_folder_list = false; + $use_javascript_addr_book = false; +} $search_memory = getPref($data_dir, $username, 'search_memory', 0); diff --git a/include/options/display.php b/include/options/display.php index 72f7b559..43ef12ad 100644 --- a/include/options/display.php +++ b/include/options/display.php @@ -478,16 +478,8 @@ function save_option_theme($option) { function save_option_javascript_autodetect($option) { global $data_dir, $username, $new_javascript_setting; - /* Set javascript either on or off. */ - if ($new_javascript_setting == SMPREF_JS_AUTODETECT) { - if ($option->new_value == SMPREF_JS_ON) { - setPref($data_dir, $username, 'javascript_on', SMPREF_JS_ON); - } else { - setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF); - } - } else { - setPref($data_dir, $username, 'javascript_on', $new_javascript_setting); - } + setPref($data_dir, $username, 'javascript_setting', $new_javascript_setting); + checkForJavascript(); } /** diff --git a/src/compose.php b/src/compose.php index bbf93738..6b41f13e 100644 --- a/src/compose.php +++ b/src/compose.php @@ -98,6 +98,8 @@ if ( !sqgetGlobalVar('smaction',$action) ) if ( sqgetGlobalVar('smaction_reply_all',$tmp) ) $action = 'reply_all'; if ( sqgetGlobalVar('smaction_forward',$tmp) ) $action = 'forward'; if ( sqgetGlobalVar('smaction_attache',$tmp) ) $action = 'forward_as_attachment'; + if ( sqgetGlobalVar('smaction_draft',$tmp) ) $action = 'draft'; + if ( sqgetGlobalVar('smaction_edit_new',$tmp) ) $action = 'edit_as_new'; } /* Location (For HTTP 1.1 Header("Location: ...") redirects) */ diff --git a/src/read_body.php b/src/read_body.php index c4da8d04..0f3b2144 100644 --- a/src/read_body.php +++ b/src/read_body.php @@ -489,7 +489,8 @@ function formatMenubar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_resp global $base_uri, $draft_folder, $where, $what, $color, $sort, $startMessage, $PHP_SELF, $save_as_draft, $enable_forward_as_attachment, $imapConnection, $lastTargetMailbox, - $data_dir, $username, $delete_prev_next_display; + $data_dir, $username, $delete_prev_next_display, + $compose_new_win, $javascript_on; $topbar_delimiter = ' | '; $double_delimiter = '    '; @@ -613,36 +614,48 @@ function formatMenubar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_resp // BEGIN MENU ROW - DELETE/REPLY/FORWARD/MOVE/etc. $menu_row = ''; - - // Start form for reply/reply all/forward.. $comp_uri = $base_uri.'src/compose.php' . '?passed_id=' . $passed_id . '&mailbox=' . $urlMailbox . '&startMessage=' . $startMessage . (isset($passed_ent_id) ? '&passed_ent_id='.$passed_ent_id : ''); - $menu_row .= '
'; + + // Start form for reply/reply all/forward.. + $target = ''; + $on_click=''; + $method='method="get" '; + if ($compose_new_win == '1') { + if ( $javascript_on ) { + $on_click=' onclick="comp_in_new_form(\''.$comp_uri.'\', this, this.form)"'; + $comp_uri = 'javascript:void(0)'; + } else { + $target = 'target="_blank"'; + $method='method="post" '; + } + } + + $menu_row .= "\n".''."\n"; // If Draft folder - create Resume link if (($mailbox == $draft_folder) && ($save_as_draft)) { - $new_button = 'draft'; + $new_button = 'smaction_draft'; $comp_alt_string = _("Resume Draft"); } else if (handleAsSent($mailbox)) { // If in Sent folder, edit as new - $new_button = 'edit_as_new'; + $new_button = 'smaction_edit_new'; $comp_alt_string = _("Edit Message as New"); } // Show Alt URI for Draft/Sent if (isset($comp_alt_string)) - $menu_row .= getButton('SUBMIT', $new_button, $comp_alt_string) . "\n"; - - $menu_row .= getButton('SUBMIT', 'smaction_reply', _("Reply")); - $menu_row .= ' '.getButton('SUBMIT', 'smaction_reply_all', _("Reply All")); - $menu_row .= ' '.getButton('SUBMIT', 'smaction_forward', _("Forward")); + $menu_row .= getButton('SUBMIT', $new_button, $comp_alt_string, $on_click) . "\n"; + $menu_row .= getButton('SUBMIT', 'smaction_reply', _("Reply"), $on_click) . "\n"; + $menu_row .= getButton('SUBMIT', 'smaction_reply_all', _("Reply All"), $on_click) ."\n"; + $menu_row .= getButton('SUBMIT', 'smaction_forward', _("Forward"), $on_click); if ($enable_forward_as_attachment) - $menu_row .= '' . _("Attachment"); + $menu_row .= '' . _("Attachment") ."\n"; - $menu_row .= ''.'  '; + $menu_row .= ''.'  '."\n"; // Form for deletion $delete_url = $base_uri . 'src/delete_message.php?mailbox=' . $urlMailbox; @@ -662,7 +675,7 @@ function formatMenubar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_resp $menu_row .= '' . _("Bypass Trash"); } else - $menu_row .= getButton('SUBMIT', 'delete', _("Delete"), FALSE) . "\n"; // delete button is disabled + $menu_row .= getButton('SUBMIT', 'delete', _("Delete"), '', FALSE) . "\n"; // delete button is disabled $menu_row .= '' . "\n"; diff --git a/src/redirect.php b/src/redirect.php index 55a87886..c076b8eb 100644 --- a/src/redirect.php +++ b/src/redirect.php @@ -46,7 +46,6 @@ sqsession_register ($base_uri, 'base_uri'); /* get globals we me need */ sqGetGlobalVar('login_username', $login_username); sqGetGlobalVar('secretkey', $secretkey); -sqGetGlobalVar('js_autodetect_results', $js_autodetect_results); if(!sqGetGlobalVar('squirrelmail_language', $squirrelmail_language) || $squirrelmail_language == '') { $squirrelmail_language = $squirrelmail_default_language; } @@ -120,23 +119,7 @@ if ( sqgetGlobalVar('HTTP_ACCEPT', $http_accept, SQ_SERVER) && } /* Complete autodetection of Javascript. */ -$javascript_setting = getPref - ($data_dir, $username, 'javascript_setting', SMPREF_JS_AUTODETECT); -$js_autodetect_results = (isset($js_autodetect_results) ? - $js_autodetect_results : SMPREF_JS_OFF); -/* See if it's set to "Always on" */ -$js_pref = SMPREF_JS_ON; -if ($javascript_setting != SMPREF_JS_ON){ - if ($javascript_setting == SMPREF_JS_AUTODETECT) { - if ($js_autodetect_results == SMPREF_JS_OFF) { - $js_pref = SMPREF_JS_OFF; - } - } else { - $js_pref = SMPREF_JS_OFF; - } -} -/* Update the prefs */ -setPref($data_dir, $username, 'javascript_on', $js_pref); +checkForJavascript(); /* Compute the URL to forward the user to. */ $redirect_url = $location . '/webmail.php'; -- 2.25.1