made the sendmail/smtp option more clear
[squirrelmail.git] / config / conf.pl
index af2335262b1790f1de3574235e3e9b468e29a3db..ea7dcd07453317347794352ecc90eee7e9ee6299 100755 (executable)
@@ -38,11 +38,11 @@ if ( -e "config.php") {
    if ($config_version ne $conf_pl_version) {
       system "clear";
       print $WHT."WARNING:\n".$NRM;
-      print "  The file \"config.php\" was found, but it is for an older version of\n";
+      print "  The file \"config/config.php\" was found, but it is for an older version of\n";
       print "  SquirrelMail.  It is possible to still read the defaults from this file\n";
       print "  but be warned that many preferences change between versions.  It is\n";
       print "  recommended that you start with a clean config.php for each upgrade that\n";
-      print "  you do.  To do this, just move config.php out of the way.\n\n";
+      print "  you do.  To do this, just move config/config.php out of the way.\n\n";
       print "Continue loading with the old config.php [y/n]? ";
       $ctu = <STDIN>;
       if (($ctu =~ /^n\n/i) || ($ctu =~ /^\n/)) {
@@ -139,6 +139,9 @@ while ($line = <FILE>) {
             $sub = $options[0];
             $sub =~ s/\]\["PATH"\]//;
             $sub =~ s/.*\[//; 
+            if (-e "../themes") {
+               $options[1] =~ s/^\.\.\/config/\.\.\/themes/;
+            }   
             $theme_path[$sub] = $options[1];
          } elsif ($options[0] =~ /^theme\[[0-9]+\]\["NAME"\]/) {
             $sub = $options[0];
@@ -221,12 +224,13 @@ if (!$default_unseen_type) {
 
 while (($command ne "q") && ($command ne "Q")) {
    system "clear";
-   if ($menu == 0) {
-      print $WHT."SquirrelMail Configuration : ".$NRM;
-      if ($config == 1) { print "Read: config.php"; }
-      elsif ($config == 2) { print "Read: config_default.php"; }
-      print "\n";
+   print $WHT."SquirrelMail Configuration : ".$NRM;
+   if ($config == 1) { print "Read: config.php"; }
+   elsif ($config == 2) { print "Read: config_default.php"; }
+   print "\n";
+   print "---------------------------------------------------------\n";
 
+   if ($menu == 0) {
       print $WHT."Main Menu --\n".$NRM;
       print "1.  Organization Preferences\n";
       print "2.  Server Settings\n";
@@ -251,7 +255,13 @@ while (($command ne "q") && ($command ne "Q")) {
       print "1.  Domain               : $WHT$domain$NRM\n";
       print "2.  IMAP Server          : $WHT$imapServerAddress$NRM\n";
       print "3.  IMAP Port            : $WHT$imapPort$NRM\n";
-      print "4.  Use Sendmail         : $WHT$useSendmail$NRM\n";
+      print "4.  Use Sendmail/SMTP    : $WHT";
+      if ($useSendmail eq "true") {
+         print "Sendmail";
+      } else {
+         print "SMTP";
+      }
+      print "$NRM\n";
       if ($useSendmail eq "true") {
          print "5.    Sendmail Path      : $WHT$sendmail_path$NRM\n";
       } else {
@@ -392,9 +402,9 @@ while (($command ne "q") && ($command ne "Q")) {
          if    ($command == 1) { command61(); }
          elsif ($command == 2) { command62(); }
       } elsif ($menu == 7) {
-         if    ($command == 1) { $motd = command71(); }
+         if    ($command == 1) { $motd             = command71(); }
       } elsif ($menu == 8) {
-         if    ($command == 1) { $motd = command81(); }
+         if    ($command == 1) { $plugins = command81(); }
       }
    }   
 }
@@ -501,14 +511,16 @@ sub command14 {
    print "messages in SquirrelMail.  You can either connect to an SMTP server\n";
    print "or use sendmail directly.\n";
    if ($useSendmail eq "true") {
-      $default_value = "y";
+      $default_value = "1";
    } else {
-      $default_value = "n";
+      $default_value = "2";
    }
    print "\n";
-   print "Use Sendmail (y/n) [$WHT$default_value$NRM]: $WHT";
+   print "  1.  Sendmail\n";
+   print "  2.  SMTP\n";
+   print "Your choice [1/2] [$WHT$default_value$NRM]: $WHT";
    $use_sendmail = <STDIN>;
-   if (($use_sendmail =~ /^y\n/i) || (($use_sendmail =~ /^\n/) && ($default_value eq "y"))) {
+   if (($use_sendmail =~ /^1\n/i) || (($use_sendmail =~ /^\n/) && ($default_value eq "1"))) {
       $useSendmail = "true";
    } else {
       $useSendmail = "false";
@@ -583,7 +595,7 @@ sub command18 {
 sub command71 {
    print "\nYou can now create the welcome message that is displayed\n";
    print "every time a user logs on.  You can use HTML or just plain\n";
-   print "text.\n\n(Type @ on a blank line to exit)\n";
+   print "text.  If you do not wish to have one, just make it blank.\n\n(Type @ on a blank line to exit)\n";
    
    $new_motd = "";
    do {
@@ -1152,8 +1164,60 @@ sub command41 {
                $theme_default--;
             }   
          }
+      } elsif ($input =~ /^\s*t\s*/i) {
+         print "\nStarting detection...\n\n";
+         
+         opendir(DIR, "../themes");
+         @files = grep { /\.php$/i } readdir(DIR);
+         $cnt = 0;
+         while ($cnt <= $#files) {
+            $filename = "../themes/" . $files[$cnt];
+            $found = 0;
+            for ($x=0; $x <= $#theme_path; $x++) {
+               if ($theme_path[$x] eq $filename) {
+                  $found = 1;
+               }
+            }
+            if ($found != 1) {
+               print "** Found theme: $filename\n";
+               print "   What is its name? ";
+               $nm = <STDIN>;
+               $nm =~ s/[\n|\r]//g;
+               $theme_name[$#theme_name+1] = $nm;
+               $theme_path[$#theme_path+1] = $filename;
+            }
+            $cnt++;
+         }
+         print "\n";
+         for ($cnt=0; $cnt <= $#theme_path; $cnt++) {
+            $filename = $theme_path[$cnt];
+            if (! (-e $filename)) {
+               print "  Removing $filename (file not found)\n";
+               $offset = 0;
+               @new_theme_name = ();
+               @new_theme_path = ();
+               for ($x=0; $x < $#theme_path; $x++) {
+                  if ($theme_path[$x] eq $filename) {
+                     $offset = 1;
+                  }
+                  if ($offset == 1) {
+                     $new_theme_name[$x] = $theme_name[$x+1];
+                     $new_theme_path[$x] = $theme_path[$x+1];
+                  } else {
+                     $new_theme_name[$x] = $theme_name[$x];
+                     $new_theme_path[$x] = $theme_path[$x];
+                  }
+               }
+               @theme_name = @new_theme_name;
+               @theme_path = @new_theme_path;
+            }
+         }
+         print "\nDetection complete!\n\n";
+         
+         closedir DIR;  
       } elsif ($input =~ /^\s*\?\s*/) {
          print ".-------------------------.\n";
+         print "| t       (detect themes) |\n";
          print "| +           (add theme) |\n";
          print "| - N      (remove theme) |\n";
          print "| m N      (mark default) |\n";
@@ -1332,9 +1396,10 @@ sub save_data {
    print FILE "<?php\n\t/** SquirrelMail configuration\n";
    print FILE "\t ** Created using the configure script, conf.pl\n\t **/\n\n";
 
-   print FILE "\t\$config_version = \"$print_config_version\";\n";
-
-   print FILE "\n";
+   if ($print_config_version) {
+      print FILE "\t\$config_version = \"$print_config_version\";\n";
+      print FILE "\n";
+   }
    
    print FILE "\t\$org_name   = \"$org_name\";\n";
    print FILE "\t\$org_logo   = \"$org_logo\";\n";
@@ -1419,6 +1484,12 @@ sub save_data {
 
 sub set_defaults {
    system "clear";
+   print $WHT."SquirrelMail Configuration : ".$NRM;
+   if ($config == 1) { print "Read: config.php"; }
+   elsif ($config == 2) { print "Read: config_default.php"; }
+   print "\n";
+   print "---------------------------------------------------------\n";
+
    print "While we have been building SquirrelMail, we have discovered some\n";
    print "preferences that work better with some servers that don't work so\n";
    print "well with others.  If you select your IMAP server, this option will\n";
@@ -1485,12 +1556,21 @@ sub set_defaults {
                        $sent_folder = "INBOX/Sent Items";
                        $show_prefix_option = false;
                        $show_contain_subfolders_option = false;
-                       
                        $imap_server_type = "exchange";
          
+         print "          default_folder_prefix = INBOX/\n";
+         print "           default_sub_of_inbox = true\n";
+         print "                   trash_folder = \"INBOX/Deleted Items\"\n";
+         print "                    sent_folder = \"INBOX/Sent Items\"\n";
+         print "             show_prefix_option = false\n";
+         print " show_contain_subfolders_option = false\n";
+         print "               imap_server_type = exchange\n";
+         
                        $continue = 1;
       } elsif ($server eq "courier") {
                        $imap_server_type = "courier";
+
+         print "   imap_server_type = courier\n";
                        
          $continue = 1;
                } elsif ($server eq "quit") {