浏览代码

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.

Erin Schnabel 21 年之前
父节点
当前提交
c072809def
共有 10 个文件被更改,包括 97 次插入74 次删除
  1. 4 0
      ChangeLog
  2. 2 0
      functions/imap_general.php
  3. 5 4
      functions/mailbox_display.php
  4. 26 21
      functions/page_header.php
  5. 20 0
      functions/prefs.php
  6. 8 7
      include/load_prefs.php
  7. 2 10
      include/options/display.php
  8. 2 0
      src/compose.php
  9. 27 14
      src/read_body.php
  10. 1 18
      src/redirect.php

+ 4 - 0
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
 --------------------

+ 2 - 0
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;       
 }        

+ 5 - 4
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 '         </SELECT></TT>&nbsp;';
 }
 
-function getButton($type, $name, $value, $enabled = TRUE) {
+function getButton($type, $name, $value, $js = '', $enabled = TRUE) {
     $disabled = ( $enabled ? '' : 'disabled ' );
-    return '<INPUT '.$disabled.
+    $js = ( $js ? $js.' ' : '' );
+    return '<INPUT '.$disabled.$js.
                'TYPE="'.$type.
              '" NAME="'.$name.
             '" VALUE="'.$value .

+ 26 - 21
functions/page_header.php

@@ -134,10 +134,10 @@ function displayPageHeader($color, $mailbox, $xtra='', $session=false) {
     }
 
     if ($session) {
-	$compose_uri = $base_uri.'src/compose.php?mailbox='.urlencode($mailbox).'&amp;attachedmessages=true&amp;session='."$session";
+    $compose_uri = $base_uri.'src/compose.php?mailbox='.urlencode($mailbox).'&amp;attachedmessages=true&amp;session='."$session";
     } else {
         $compose_uri = $base_uri.'src/compose.php?newmessage=1';
-	$session = 0;
+    $session = 0;
     }
   
     if($javascript_on) { 
@@ -154,15 +154,20 @@ function displayPageHeader($color, $mailbox, $xtra='', $session=false) {
                     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_form(comp_uri, button, myform) {\n".
+                           '   if (!comp_uri) {'."\n".
+                           '       comp_uri = "'.$compose_uri."\";\n".
+                           '   }'. "\n".
+                           '   comp_uri += "&" + button.name + "=1";'."\n".
+                           '   for ( var i=0; i < myform.elements.length; i++ ) {'."\n".
+                           '      if ( myform.elements[i].type == "checkbox"  && myform.elements[i].checked )'."\n".
+                           '         comp_uri += "&" + myform.elements[i].name + "=1";'."\n".
+                           '   }'."\n".
+                           '   var newwin = window.open(comp_uri' .
+                           ', "_blank",'.
+                           '"width='.$compose_width. ',height='.$compose_height.
+                           ',scrollbars=yes,resizable=yes");'."\n".
+                           "}\n\n";
                 }
 
                 // javascript for sending read receipts
@@ -170,7 +175,7 @@ function displayPageHeader($color, $mailbox, $xtra='', $session=false) {
                     $js .= 'function sendMDN() {'."\n".
                            "    mdnuri=window.location+'&sendreceipt=1'; ".
                            "var newwin = window.open(mdnuri,'right');".
-    	               "\n}\n\n";
+                       "\n}\n\n";
                 }
 
                 // if any of the above passes, add the JS tags too.
@@ -212,9 +217,9 @@ function displayPageHeader($color, $mailbox, $xtra='', $session=false) {
                         "document.forms[i-1].elements[pos].focus();\n".
                     "}\n".
                 "}\n";
-	    
+        
             $js .= "// -->\n".
-            	 "</script>\n";
+                 "</script>\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". "</script>\n";
-	
+    
             $onload = 'onload="checkForm();"';
             displayHtmlHeader ('SquirrelMail', $js);
             break;   
@@ -387,7 +392,7 @@ function compose_Header($color, $mailbox) {
                     "}\n".
                 "}\n";
             $js .= "// -->\n".
-            	 "</script>\n";
+                 "</script>\n";
             $onload = 'onload="checkForm();"';
             displayHtmlHeader (_("Compose"), $js);
             break;   

+ 20 - 0
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;
+}
+
 ?>

+ 8 - 7
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);
 

+ 2 - 10
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();
 }
 
 /** 

+ 2 - 0
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) */

+ 27 - 14
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 = '&nbsp;|&nbsp;';
     $double_delimiter = '&nbsp;&nbsp;&nbsp;&nbsp;';
@@ -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 = '<tr bgcolor="'.$color[9].'"><td><small>';
-
-    // Start form for reply/reply all/forward.. 
     $comp_uri = $base_uri.'src/compose.php' .
                 '?passed_id=' . $passed_id .
                 '&amp;mailbox=' . $urlMailbox .
                 '&amp;startMessage=' . $startMessage .
                  (isset($passed_ent_id) ? '&amp;passed_ent_id='.$passed_ent_id : '');
-    $menu_row .= '<form action="'.$comp_uri.'" method="post"><small>';
+ 
+    // 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".'<form name="composeForm" action="'.$comp_uri.'" '.$method.$target.'><small>'."\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 .= '&nbsp;'.getButton('SUBMIT', 'smaction_reply_all', _("Reply All"));
-    $menu_row .= '&nbsp;'.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 .= '<input type="checkbox" name="smaction_attache">' . _("Attachment");
+        $menu_row .= '<input type="checkbox" name="smaction_attache">' . _("Attachment") ."\n";
 
-    $menu_row .= '</form>'.'&nbsp;&nbsp;';
+    $menu_row .= '</form>'.'&nbsp;&nbsp;'."\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 .= '<input type="checkbox" name="bypass_trash">' . _("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 .= '</form>' . "\n";
 

+ 1 - 18
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';