Allow easy editing of address book DSN
authorsimond <simond@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 30 Jan 2002 18:43:14 +0000 (18:43 +0000)
committersimond <simond@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 30 Jan 2002 18:43:14 +0000 (18:43 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2296 7612ce4b-ef26-0410-bec9-ea0150e637f0

config/conf.pl
config/config_default.php
functions/addressbook.php
plugins/administrator/defines.php

index b66ebe5b3b7d3b655a23096cce6b8d78de0c33f6..20d736f5d110532d240c2284a0aff3bc380468cc 100755 (executable)
@@ -317,6 +317,7 @@ while (($command ne "q") && ($command ne "Q")) {
       print "6.  Address Books (LDAP)\n";
       print "7.  Message of the Day (MOTD)\n";
       print "8.  Plugins\n";
+      print "9.  Database\n";
       print "\n";
       print "D.  Set pre-defined settings for specific IMAP servers\n";
       print "\n";
@@ -450,6 +451,12 @@ while (($command ne "q") && ($command ne "Q")) {
       print "A   Sanitize all plugins for use with Squirrelmail 1.2\n";
       print "\n";
       print "R   Return to Main Menu\n";
+   } elsif ($menu == 9) {
+      print $WHT."Database\n".$NRM;
+      print "1.  DSN for Address Book : $WHT$addrbook_dsn$NRM\n";
+      print "\n";
+      print "S   Save data\n";
+      print "R   Return to Main Menu\n";
    }
    if ($config_use_color == 1) {
       print "C.  Turn color off\n";
@@ -496,7 +503,7 @@ while (($command ne "q") && ($command ne "Q")) {
    } else {
       $saved = 0;
       if ($menu == 0) {
-         if (($command > 0) && ($command < 9)) {
+         if (($command > 0) && ($command < 10)) {
             $menu = $command;
          }
       } elsif ($menu == 1) {
@@ -555,6 +562,8 @@ while (($command ne "q") && ($command ne "Q")) {
       } elsif ($menu == 8) {
          if    ($command =~ /^[0-9]+/) { @plugins = command81(); }
          elsif ($command eq "a") { command8s(); }
+      } elsif ($menu == 9) {
+         if    ($command == 1) { $addrbook_dsn = command91(); }
       }
    }   
 }
@@ -1813,6 +1822,31 @@ sub command62 {
    return $default_use_javascript_addr_book;
 }
 
+sub command91 {
+   print "If you want to store your users address book details 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 address books will not be used\n";
+   print "\n";
+
+   if ($addrbook_dsn eq "") {
+      $default_value = "Disabled";
+   } else {
+      $default_value = $addrbook_dsn;
+   }
+   print "[$WHT$addrbook_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 save_data {
     $tab = "    ";
@@ -1954,10 +1988,8 @@ sub save_data {
            print CF "\n";
         }
 
-        if (defined $addrbook_dsn) {
-            print CF "global \$addrbook_dsn;\n";
-            print CF "\$addrbook_dsn = '$addrbook_dsn';\n\n";
-        }
+        print CF "global \$addrbook_dsn;\n";
+        print CF "\$addrbook_dsn = '$addrbook_dsn';\n\n";
      
         print CF "/**\n";
         print CF " * Make sure there are no characters after the PHP closing\n";
index 309cc5c7a2bb6b2835ed1d141f6382bcc29085f7..62946d2095e6a891f4965c53deafaecd0993df73 100644 (file)
@@ -378,9 +378,10 @@ global $ldap_server;
  *   addressbooks are stored.  See doc/db-backend.txt for more info.
  *   If it is not defined, the addressbooks are stored in files
  *   in the data dir.
+ *   The DSN is in the format: mysql://user:pass@hostname/dbname
  */
-#global $addrbook_dsn;
-#$addrbook_dsn = 'mysql://user:pass@hostname/dbname';
+global $addrbook_dsn;
+$addrbook_dsn = '';
 
 /**
  * Users may search their addressbook via either a plain HTML or Javascript
index 4432751b2fa0ba4a2b61e43fa1353a13e007c878..61b9e7beefd811cc2a246c4cf53731f81d02631d 100644 (file)
@@ -41,7 +41,7 @@ if (isset($address_book_global_filename)) {
 }
 
 /* Only load database backend if database is configured */
-if(isset($addrbook_dsn)) {
+if(isset($addrbook_dsn) && !empty($addrbook_dsn)) {
   include_once('../functions/abook_database.php');
 }
 
index 4ebc5af30340bec0784e9c7ac2ffc7c87720a550..ea057b3f3399321e1ae504b79cb23dd6f910de17 100644 (file)
@@ -188,13 +188,20 @@ $defcfg = array( '$config_version' => array( 'name' => _("Config File Version"),
                                    'type' => SMOPT_TYPE_TEXTAREA,
                                    'size' => 40 ),
                  /* --------------------------------------------------------*/
-                 'Group6' => array( 'name' => _("Themes"),
+                 'Group6' => array( 'name' => _("Database"),
+                                    'type' => SMOPT_TYPE_TITLE ),
+                 '$addrbook_dsn' => array( 'name' => _("Address book DSN"),
+                                           'type' => SMOPT_TYPE_STRING,
+                                           'size' => 40 ), 
+                 /* --------------------------------------------------------*/
+                 'Group7' => array( 'name' => _("Themes"),
                                     'type' => SMOPT_TYPE_TITLE ),
                  '$theme_css' => array( 'name' => _("Style Sheet URL (css)"),
                                         'type' => SMOPT_TYPE_STRING,
                                         'size' => 40 ),
                  /* --------------------------------------------------------*/
                  '$config_use_color' => array( 'type' => SMOPT_TYPE_HIDDEN )
+                 /* --------------------------------------------------------*/
 
                );