瀏覽代碼

Added new config flag 'allow_charset_search' for those unfortunate using
other charset than US-ASCII with server which doesn't support it.

Ondřej Surý 23 年之前
父節點
當前提交
a8c1c80685
共有 3 個文件被更改,包括 29 次插入4 次删除
  1. 25 0
      config/conf.pl
  2. 2 2
      functions/imap_search.php
  3. 2 2
      plugins/filters/filters.php

+ 25 - 0
config/conf.pl

@@ -426,6 +426,7 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) ) {
         if ( lc($edit_identity) eq "false" ) {
         if ( lc($edit_identity) eq "false" ) {
             print "13. Allow editing of name     : $WHT$edit_name$NRM\n";
             print "13. Allow editing of name     : $WHT$edit_name$NRM\n";
         }
         }
+        print "14. Allow server charset search : $WHT$allow_charset_search$NRM\n";
         print "\n";
         print "\n";
         print "R   Return to Main Menu\n";
         print "R   Return to Main Menu\n";
     } elsif ( $menu == 5 ) {
     } elsif ( $menu == 5 ) {
@@ -606,6 +607,7 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) ) {
             elsif ( $command == 11 ) { $allow_thread_sort        = command312(); }
             elsif ( $command == 11 ) { $allow_thread_sort        = command312(); }
             elsif ( $command == 12 ) { $allow_server_sort        = command313(); }
             elsif ( $command == 12 ) { $allow_server_sort        = command313(); }
             elsif ( $command == 13 ) { $edit_name                = command311(); }
             elsif ( $command == 13 ) { $edit_name                = command311(); }
+            elsif ( $command == 14 ) { $allow_charset_search     = command314(); }
         } elsif ( $menu == 5 ) {
         } elsif ( $menu == 5 ) {
             if ( $command == 1 ) { command41(); }
             if ( $command == 1 ) { command41(); }
             elsif ( $command == 2 ) { $theme_css = command42(); }
             elsif ( $command == 2 ) { $theme_css = command42(); }
@@ -1744,6 +1746,27 @@ sub command313 {
     return $allow_server_sort;
     return $allow_server_sort;
 }
 }
 
 
+sub command314 {
+    print "This option allows you to choose if SM uses charset search\n";
+    print "Your IMAP server must support the SEARCH CHARSET command for this to work\n";
+    print "\n";
+
+    if ( lc($allow_charset_search) eq "true" ) {
+        $default_value = "y";
+    } else {
+        $default_value = "n";
+    }
+    print "Allow charset searching? (y/n) [$WHT$default_value$NRM]: $WHT";
+    $allow_charset_search = <STDIN>;
+    if ( ( $allow_charset_search =~ /^y\n/i ) || ( ( $allow_charset_search =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
+        $allow_charset_search = "true";
+    } else {
+        $allow_charset_search = "false";
+    }
+    return $allow_charset_search;
+}
+
+
 sub command41 {
 sub command41 {
     print "\nNow we will define the themes that you wish to use.  If you have added\n";
     print "\nNow we will define the themes that you wish to use.  If you have added\n";
     print "a theme of your own, just follow the instructions (?) about how to add\n";
     print "a theme of your own, just follow the instructions (?) about how to add\n";
@@ -2321,6 +2344,8 @@ sub save_data {
         print CF "\$allow_thread_sort        = $allow_thread_sort;\n";
         print CF "\$allow_thread_sort        = $allow_thread_sort;\n";
 	# boolean
 	# boolean
         print CF "\$allow_server_sort        = $allow_server_sort;\n";
         print CF "\$allow_server_sort        = $allow_server_sort;\n";
+        # boolean
+        print CF "\$allow_charset_search        = $allow_charset_search;\n";
         print CF "\n";
         print CF "\n";
 	
 	
 	# all plugins are strings
 	# all plugins are strings

+ 2 - 2
functions/imap_search.php

@@ -21,7 +21,7 @@ function sqimap_search($imapConnection, $search_where, $search_what, $mailbox,
                        $color, $search_position = '', $search_all, $count_all) {
                        $color, $search_position = '', $search_all, $count_all) {
 
 
     global $msgs, $message_highlight_list, $squirrelmail_language, $languages,
     global $msgs, $message_highlight_list, $squirrelmail_language, $languages,
-           $index_order, $pos;
+           $index_order, $pos, $allow_charset_search;
 
 
     $pos = $search_position;
     $pos = $search_position;
 
 
@@ -41,7 +41,7 @@ function sqimap_search($imapConnection, $search_where, $search_what, $mailbox,
     $search_string = trim($search_string);
     $search_string = trim($search_string);
 
 
     /* now use $search_string in the imap search */
     /* now use $search_string in the imap search */
-    if (isset($languages[$squirrelmail_language]['CHARSET']) &&
+    if ($allow_charset_search && isset($languages[$squirrelmail_language]['CHARSET']) &&
         $languages[$squirrelmail_language]['CHARSET']) {
         $languages[$squirrelmail_language]['CHARSET']) {
         $ss = "SEARCH CHARSET "
         $ss = "SEARCH CHARSET "
             . strtoupper($languages[$squirrelmail_language]['CHARSET']) 
             . strtoupper($languages[$squirrelmail_language]['CHARSET']) 

+ 2 - 2
plugins/filters/filters.php

@@ -317,14 +317,14 @@ function user_filters($imap_stream) {
 }
 }
 
 
 function filter_search_and_delete($imap, $where, $what, $where_to, $user_scan) {
 function filter_search_and_delete($imap, $where, $what, $where_to, $user_scan) {
-    global $languages, $squirrelmail_language;
+    global $languages, $squirrelmail_language, $allow_charset_search;
     if ($user_scan == 'new') {
     if ($user_scan == 'new') {
         $category = 'UNSEEN';
         $category = 'UNSEEN';
     } else {
     } else {
         $category = 'ALL';
         $category = 'ALL';
     }
     }
 
 
-    if (isset($languages[$squirrelmail_language]['CHARSET']) &&
+    if ($allow_charset_search && isset($languages[$squirrelmail_language]['CHARSET']) &&
         $languages[$squirrelmail_language]['CHARSET']) {
         $languages[$squirrelmail_language]['CHARSET']) {
         $search_str = "SEARCH CHARSET "
         $search_str = "SEARCH CHARSET "
             . strtoupper($languages[$squirrelmail_language]['CHARSET']) 
             . strtoupper($languages[$squirrelmail_language]['CHARSET'])