Corified Msg_Flags plugin, along with Jimmy's icon themes
[squirrelmail.git] / config / conf.pl
index f2cd40715eeaca3ee203f977a3c4c8c82cb6087d..3798683bbd9470023c53cd28503f93e76da5a55b 100755 (executable)
@@ -230,6 +230,21 @@ while ( $line = <FILE> ) {
                     $tmp =~ s/[\'|\"],?\s*$//;
                     $tmp =~ s/[\'|\"]\);\s*$//;
                     $name = $tmp;
+                } elsif ( $tmp =~ /^\s*[\'|\"]binddn[\'|\"]/i ) {
+                    $tmp =~ s/^\s*[\'|\"]binddn[\'|\"]\s*=>\s*[\'|\"]//i;
+                    $tmp =~ s/[\'|\"],?\s*$//;
+                    $tmp =~ s/[\'|\"]\);\s*$//;
+                    $binddn = $tmp;
+                } elsif ( $tmp =~ /^\s*[\'|\"]bindpw[\'|\"]/i ) {
+                    $tmp =~ s/^\s*[\'|\"]bindpw[\'|\"]\s*=>\s*[\'|\"]//i;
+                    $tmp =~ s/[\'|\"],?\s*$//;
+                    $tmp =~ s/[\'|\"]\);\s*$//;
+                    $bindpw = $tmp;
+                } elsif ( $tmp =~ /^\s*[\'|\"]protocol[\'|\"]/i ) {
+                    $tmp =~ s/^\s*[\'|\"]protocol[\'|\"]\s*=>\s*[\'|\"]?//i;
+                    $tmp =~ s/[\'|\"]?,?\s*$//;
+                    $tmp =~ s/[\'|\"]?\);\s*$//;
+                    $protocol = $tmp;
                 }
             }
             $ldap_host[$sub]    = $host;
@@ -238,6 +253,9 @@ while ( $line = <FILE> ) {
             $ldap_port[$sub]    = $port;
             $ldap_maxrows[$sub] = $maxrows;
             $ldap_charset[$sub] = $charset;
+            $ldap_binddn[$sub]  = $binddn;
+            $ldap_bindpw[$sub]  = $bindpw;
+            $ldap_protocol[$sub] = $protocol;
         } elsif ( $options[0] =~ /^(data_dir|attachment_dir|theme_css|org_logo|signout_page)$/ ) {
             ${ $options[0] } = &change_to_rel_path($options[1]);
         } else {
@@ -327,6 +345,15 @@ if ( !$prefs_user_field ) {
 if ( !$prefs_key_field ) {
     $prefs_key_field = 'prefkey';
 }
+if ( !$addrbook_global_table ) {
+    $addrbook_global_table = 'global_abook';
+}
+if ( !$addrbook_global_writeable ) {
+    $addrbook_global_writeable = 'false';
+}
+if ( !$addrbook_global_listing ) {
+    $addrbook_global_listing = 'false';
+}
 if ( !$prefs_val_field ) {
     $prefs_val_field = 'prefval';
 }
@@ -371,6 +398,10 @@ if (!$oldway ) {
        $oldway = 'false';
 }
 
+if (!$use_icons ) {
+       $use_icons = 'false';
+}
+
 if (!$use_php_recode ) {
        $use_php_recode = 'false';
 }
@@ -622,6 +653,11 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) ) {
         print "6.  Field for prefs key    : $WHT$prefs_key_field$NRM\n";
         print "7.  Field for prefs value  : $WHT$prefs_val_field$NRM\n";
         print "\n";
+        print "8.  DSN for Global Address Book            : $WHT$addrbook_global_dsn$NRM\n";
+        print "9.  Table for Global Address Book          : $WHT$addrbook_global_table$NRM\n";
+        print "10. Allow writing into Global Address Book : $WHT$addrbook_global_writeable$NRM\n";
+        print "11. Allow listing of Global Address Book   : $WHT$addrbook_global_listing$NRM\n";
+        print "\n";
         print "R   Return to Main Menu\n";
     } elsif ( $menu == 10 ) {
        print $WHT. "Language settings\n" . $NRM;
@@ -636,10 +672,11 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) ) {
        print $WHT. "Interface tweaks\n" . $NRM;
        print "1.  Advanced tree            : $WHT$advanced_tree$NRM\n";
        print "2.  Oldway                   : $WHT$oldway$NRM\n";
+       print "3.  Use Icons                : $WHT$use_icons$NRM\n";
        print "\n";
        print $WHT. "PHP tweaks\n" . $NRM;
-       print "3.  Use php recode functions : $WHT$use_php_recode$NRM\n";
-       print "4.  Use php iconv functions  : $WHT$use_php_iconv$NRM\n";
+       print "4.  Use php recode functions : $WHT$use_php_recode$NRM\n";
+       print "5.  Use php iconv functions  : $WHT$use_php_iconv$NRM\n";
        print "\n";
         print "R   Return to Main Menu\n";
     }
@@ -758,7 +795,7 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) ) {
             elsif ( $command == 10 ) { $allow_thread_sort        = command312(); }
             elsif ( $command == 11 ) { $allow_server_sort        = command313(); }
             elsif ( $command == 12 ) { $allow_charset_search     = command314(); }
-                       elsif ( $command == 13 ) { $session_name             = command316(); }
+            elsif ( $command == 13 ) { $session_name             = command316(); }
         } elsif ( $menu == 5 ) {
             if ( $command == 1 ) { command41(); }
             elsif ( $command == 2 ) { $theme_css = command42(); }
@@ -777,6 +814,10 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) ) {
             elsif ( $command == 5 ) { $prefs_user_field = command95(); }
             elsif ( $command == 6 ) { $prefs_key_field  = command96(); }
             elsif ( $command == 7 ) { $prefs_val_field  = command97(); }
+            elsif ( $command == 8 ) { $addrbook_global_dsn       = command98(); }
+            elsif ( $command == 9 ) { $addrbook_global_table     = command99(); }
+            elsif ( $command == 10 ) { $addrbook_global_writeable = command910(); }
+            elsif ( $command == 11 ) { $addrbook_global_listing  = command911(); }
         } elsif ( $menu == 10 ) {
             if    ( $command == 1 ) { $squirrelmail_default_language = commandA1(); }
             elsif ( $command == 2 ) { $default_charset              = commandA2(); }
@@ -786,8 +827,9 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) ) {
         } elsif ( $menu == 11 ) {
             if    ( $command == 1 ) { $advanced_tree  = commandB1(); }
             elsif ( $command == 2 ) { $oldway                = commandB2(); }
-            elsif ( $command == 3 ) { $use_php_recode = commandB3(); }
-            elsif ( $command == 4 ) { $use_php_iconv  = commandB4(); }
+            elsif ( $command == 3 ) { $use_icons      = commandB3(); }
+            elsif ( $command == 4 ) { $use_php_recode = commandB4(); }
+            elsif ( $command == 5 ) { $use_php_iconv  = commandB5(); }
         }
     }
 }
@@ -1882,7 +1924,7 @@ sub command33a {
     print "  Relative:    ../data/\n";     
     print "Relative paths to directories outside of the SquirrelMail distribution\n";
     print "will be converted to their absolute path equivalents in config.php.\n\n";
-    print "Note: There are potential security risks with having a writable directory\n";
+    print "Note: There are potential security risks with having a writeable directory\n";
     print "under the web server's root directory (ex: /home/httpd/html).\n";
     print "For this reason, it is recommended to put the data directory\n";
     print "in an alternate location of your choice. \n";
@@ -2405,6 +2447,16 @@ sub command61 {
                 if ( $ldap_maxrows[$count] ) {
                     print "     maxrows: $ldap_maxrows[$count]\n";
                 }
+                if ( $ldap_binddn[$count] ) {
+                    print "      binddn: $ldap_binddn[$count]\n";
+                    if ( $ldap_bindpw[$count] ) {
+                        print "      bindpw: $ldap_bindpw[$count]\n";
+                    }
+                }
+               if ( $ldap_protocol[$count] ) {
+                    print "    protocol: $ldap_protocol[$count]\n";
+                }
+
                 print "\n";
                 $count++;
             }
@@ -2466,6 +2518,36 @@ sub command61 {
 
             print "\n";
 
+            print "If your LDAP server does not like anonymous logins, you can specify bind DN.\n";
+            print "Default is none, anonymous bind.  Press ENTER for default.\n";
+            print "binddn: ";
+            $name = <STDIN>;
+            $name =~ s/[\r|\n]//g;
+            $ldap_binddn[$sub] = $name;
+
+            print "\n";
+
+            if ( $ldap_binddn[$sub] ne '' ) {
+
+                print "Now, please specify password for that DN.\n";
+                print "bindpw: ";
+                $name = <STDIN>;
+                $name =~ s/[\r|\n]//g;
+                $ldap_bindpw[$sub] = $name;
+
+                print "\n";
+            }
+
+           print "You can specify bind protocol version here.\n";
+            print "Default protocol version depends on your php ldap settings.\n";
+           print "Press ENTER for default.\n";
+            print "protocol: ";
+            $name = <STDIN>;
+            $name =~ s/[\r|\n]//g;
+            $ldap_protocol[$sub] = $name;
+
+            print "\n";
+
         } elsif ( $input =~ /^\s*-\s*[0-9]?/ ) {
             if ( $input =~ /[0-9]+\s*$/ ) {
                 $rem_num = $input;
@@ -2481,6 +2563,9 @@ sub command61 {
             @new_ldap_name    = ();
             @new_ldap_charset = ();
             @new_ldap_maxrows = ();
+            @new_ldap_bindpw  = ();
+            @new_ldap_binddn  = ();
+            @new_ldap_protocol = ();
 
             while ( $count <= $#ldap_host ) {
                 if ( $count != $rem_num ) {
@@ -2490,6 +2575,9 @@ sub command61 {
                     @new_ldap_name    = ( @new_ldap_name,    $ldap_name[$count] );
                     @new_ldap_charset = ( @new_ldap_charset, $ldap_charset[$count] );
                     @new_ldap_maxrows = ( @new_ldap_maxrows, $ldap_maxrows[$count] );
+                    @new_ldap_binddn  = ( @new_ldap_binddn,  $ldap_binddn[$count] );
+                    @new_ldap_bindpw  = ( @new_ldap_bindpw,  $ldap_bindpw[$count] );
+                    @new_ldap_protocol  = ( @new_ldap_protocol,  $ldap_protocol[$count] );
                 }
                 $count++;
             }
@@ -2499,6 +2587,10 @@ sub command61 {
             @ldap_name    = @new_ldap_name;
             @ldap_charset = @new_ldap_charset;
             @ldap_maxrows = @new_ldap_maxrows;
+            @ldap_binddn  = @new_ldap_binddn;
+            @ldap_bindpw  = @new_ldap_bindpw;
+            @ldap_protocol = @new_ldap_protocol;
+
         } elsif ( $input =~ /^\s*\?\s*/ ) {
             print ".-------------------------.\n";
             print "| +            (add host) |\n";
@@ -2664,6 +2756,85 @@ sub command97 {
     return $new_field;
 }
 
+sub command98 {
+    print "If you want to store your global address book in a database then\n";
+    print "you need to set this DSN to a valid value. The format for this is:\n";
+    print "mysql://user:pass\@hostname/dbname\n";
+    print "Where mysql can be one of the databases PHP supports, the most common\n";
+    print "of these are mysql, msql and pgsql\n";
+    print "If the DSN is left empty (hit space and then return) the database\n";
+    print "related code for global SQL address book will not be used\n";
+    print "\n";
+
+    if ( $addrbook_global_dsn eq "" ) {
+        $default_value = "Disabled";
+    } else {
+        $default_value = $addrbook_global_dsn;
+    }
+    print "[$WHT$addrbook_global_dsn$NRM]: $WHT";
+    $new_dsn = <STDIN>;
+    if ( $new_dsn eq "\n" ) {
+        $new_dsn = "";
+    } else {
+        $new_dsn =~ s/[\r|\n]//g;
+        $new_dsn =~ s/^\s+$//g;
+    }
+    return $new_dsn;
+}
+
+sub command99 {
+    print "This is the name of the table you want to store the global address book\n";
+    print "data in, it defaults to 'global_address'\n";
+    print "\n";
+    print "[$WHT$addrbook_global_table$NRM]: $WHT";
+    $new_table = <STDIN>;
+    if ( $new_table eq "\n" ) {
+        $new_table = $addrbook_global_table;
+    } else {
+        $new_table =~ s/[\r|\n]//g;
+    }
+    return $new_table;
+}
+
+sub command910 {
+    print "This option controls users\' ability to add or modify records stored \n";
+    print "in global address book\n";
+
+    if ( lc($addrbook_global_writeable) eq "true" ) {
+        $default_value = "y";
+    } else {
+        $default_value = "n";
+    }
+    print "Allow writing into global address book? (y/n) [$WHT$default_value$NRM]: $WHT";
+    $addrbook_global_writeable = <STDIN>;
+    if ( ( $addrbook_global_writeable =~ /^y\n/i ) || ( ( $addrbook_global_writeable =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
+        $addrbook_global_writeable = "true";
+    } else {
+        $addrbook_global_writeable = "false";
+    }
+    return $addrbook_global_writeable;
+}
+
+sub command911 {
+    print "Enable this option if you want to see listing of addresses stored \n";
+    print "in global address book\n";
+
+    if ( lc($addrbook_global_listing) eq "true" ) {
+        $default_value = "y";
+    } else {
+        $default_value = "n";
+    }
+    print "Allow listing of global address book? (y/n) [$WHT$default_value$NRM]: $WHT";
+    $addrbook_global_listing = <STDIN>;
+    if ( ( $addrbook_global_listing =~ /^y\n/i ) || ( ( $addrbook_global_listing =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
+        $addrbook_global_listing = "true";
+    } else {
+        $addrbook_global_listing = "false";
+    }
+    return $addrbook_global_listing;
+}
+
+
 # Default language
 sub commandA1 {
     print "SquirrelMail attempts to set the language in many ways.  If it\n";
@@ -2819,8 +2990,33 @@ sub commandB2 {
     }
     return $oldway;
 }
-# php recode
+# use icons
 sub commandB3 {
+    print "Enabling this option will cause icons to be used instead of text\n";
+    print "markers next to each message in mailbox lists that represent\n";
+    print "new, read, flagged, and deleted messages, as well as those that\n";
+    print "have been replied to and forwarded. Icons are also used next to\n";
+    print "(un)expanded folders in the folder list (Oldway = false).  These\n";
+    print "icons are quite small, but will obviously be more of a resource\n";
+    print "drain than text markers.\n";
+    print "\n";
+
+    if ( lc($use_icons) eq "true" ) {
+        $default_value = "y";
+    } else {
+        $default_value = "n";
+    }
+    print "Use icons? (y/n) [$WHT$default_value$NRM]: $WHT";
+    $use_icons = <STDIN>;
+    if ( ( $use_icons =~ /^y\n/i ) || ( ( $use_icons =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
+        $use_icons = "true";
+    } else {
+        $use_icons = "false";
+    }
+    return $use_icons;
+}
+# php recode
+sub commandB4 {
     print "Enable this option if you want to use php recode functions to read\n";
     print "emails written in charset that differs from the one that is set in\n";
     print "translation selected by user. Code is experimental, it might cause\n";
@@ -2843,7 +3039,7 @@ sub commandB3 {
     return $use_php_recode;
 }
 # php iconv
-sub commandB4 {
+sub commandB5 {
     print "Enable this option if you want to use php iconv functions to read\n";
     print "emails written in charset that differs from the one that is set in\n";
     print "translation selected by user. Code is experimental, it works only\n";
@@ -3070,6 +3266,21 @@ sub save_data {
                # integer
                 print CF "    'maxrows' => $ldap_maxrows[$count]";
             }
+            if ( $ldap_binddn[$count] ) {
+                print CF ",\n";
+                # string
+                print CF "    'binddn' => '$ldap_binddn[$count]'";
+                if ( $ldap_bindpw[$count] ) {
+                    print CF ",\n";
+                    # string
+                    print CF "    'bindpw' => '$ldap_bindpw[$count]'";
+                }
+            }
+            if ( $ldap_protocol[$count] ) {
+                print CF ",\n";
+               # integer
+                print CF "    'protocol' => $ldap_protocol[$count]";
+            }
             print CF "\n";
             print CF ");\n";
             print CF "\n";
@@ -3088,20 +3299,30 @@ sub save_data {
        # string
         print CF "\$prefs_key_field = '$prefs_key_field';\n";
        # string
-        print CF "\$prefs_val_field = '$prefs_val_field';\n";
+        print CF "\$prefs_val_field = '$prefs_val_field';\n\n";
+       # string
+        print CF "\$addrbook_global_dsn = '$addrbook_global_dsn';\n";
+       # string
+        print CF "\$addrbook_global_table = '$addrbook_global_table';\n";
        # boolean
-               print CF "\$no_list_for_subscribe = $no_list_for_subscribe;\n";
+        print CF "\$addrbook_global_writeable = $addrbook_global_writeable;\n\n";
+       # boolean
+        print CF "\$addrbook_global_listing = $addrbook_global_listing;\n\n";
+       # boolean
+        print CF "\$no_list_for_subscribe = $no_list_for_subscribe;\n";
 
        # string
-               print CF "\$smtp_auth_mech = '$smtp_auth_mech';\n";
-               print CF "\$imap_auth_mech = '$imap_auth_mech';\n";
+        print CF "\$smtp_auth_mech = '$smtp_auth_mech';\n";
+       # string
+        print CF "\$imap_auth_mech = '$imap_auth_mech';\n";
        # boolean
-           print CF "\$use_imap_tls = $use_imap_tls;\n";
-               print CF "\$use_smtp_tls = $use_smtp_tls;\n";
-
-               print CF "\$session_name = '$session_name';\n";
+        print CF "\$use_imap_tls = $use_imap_tls;\n";
+       # boolean
+        print CF "\$use_smtp_tls = $use_smtp_tls;\n";
+       # string
+        print CF "\$session_name = '$session_name';\n";
 
-           print CF "\n";
+       print CF "\n";
 
        # boolean
        print CF "\$advanced_tree = $advanced_tree;\n";
@@ -3110,6 +3331,9 @@ sub save_data {
        print CF "\$oldway = $oldway;\n";
        print CF "\n";
        # boolean
+       print CF "\$use_icons = $use_icons;\n";
+       print CF "\n";
+       # boolean
        print CF "\$use_php_recode = $use_php_recode;\n";
        print CF "\n";
        # boolean