fix typo in address group.
[squirrelmail.git] / plugins / administrator / options.php
index c7af2d8bbf067243a2c67f979ec1c710f1caa0da..3c0313cd86b29ca999e92f161a80c419a9ce1ee0 100644 (file)
@@ -8,7 +8,7 @@
  *
  * @version $Id$
  * @author Philippe Mingo
- * @copyright (c) 1999-2004 The SquirrelMail Project Team
+ * @copyright (c) 1999-2005 The SquirrelMail Project Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @package plugins
  * @subpackage administrator
@@ -28,6 +28,7 @@ function parseConfig( $cfg_file ) {
     $mode = '';
     $l = count( $cfg );
     $modifier = FALSE;
+    $arraykey = 0;
 
     for ($i=0;$i<$l;$i++) {
         $line = trim( $cfg[$i] );
@@ -49,6 +50,11 @@ function parseConfig( $cfg_file ) {
                     $mode = '=';
                 } else {
                     $key .= $line{$j};
+                    // FIXME: this is only pour workaround for plugins[] array.
+                    if ($line{$j}=='[' && $line{($j+1)}==']') {
+                        $key .= $arraykey;
+                        $arraykey++;
+                    }
                 }
                 break;
             case ';':
@@ -146,31 +152,31 @@ function parseConfig( $cfg_file ) {
  *    '/absolute/path/logo.gif'   --> /absolute/path/logo.gif
  *    'http://whatever/'          --> http://whatever
  *  Note removal of quotes in returned value
- *  
+ *
  * @param string $old_path path that has to be converted
  * @return string new path
  * @access private
  */
 function change_to_rel_path($old_path) {
-    $new_path = str_replace("SM_PATH . '", "../", $old_path); 
+    $new_path = str_replace("SM_PATH . '", "../", $old_path);
     $new_path = str_replace("../config/","", $new_path);
     $new_path = str_replace("'","", $new_path);
     return $new_path;
 }
 
 /**
- * Change relative path (relative to config dir) to 
+ * Change relative path (relative to config dir) to
  *  internal SM_PATH, i.e.:
  *     empty_string            --> ''
  *     ../images/logo.gif      --> SM_PATH . 'images/logo.gif'
  *     images/logo.gif         --> SM_PATH . 'config/images/logo.gif'
  *     /absolute/path/logo.gif --> '/absolute/path/logo.gif'
  *     http://whatever/        --> 'http://whatever'
- *  
+ *
  * @param string $old_path path that has to be converted
  * @return string new path
  * @access private
-*/     
+*/
 function change_to_sm_path($old_path) {
     if ( $old_path === '' || $old_path == "''" ) {
         return "''";
@@ -179,15 +185,15 @@ function change_to_sm_path($old_path) {
     } elseif ( preg_match("/^(\$|SM_PATH)/", $old_path) ) {
         return $old_path;
     }
-   
+
     $new_path = '';
     $rel_path = explode("../", $old_path);
     if ( count($rel_path) > 2 ) {
-        // Since we're relative to the config dir, 
+        // Since we're relative to the config dir,
         // more than 1 ../ puts us OUTSIDE the SM tree.
         // get full path to config.php, then pop the filename
         $abs_path = explode('/', realpath (SM_PATH . 'config/config.php'));
-        array_pop ($abs_path); 
+        array_pop ($abs_path);
         foreach ( $rel_path as $subdir ) {
             if ( $subdir === '' ) {
                 array_pop ($abs_path);
@@ -203,9 +209,9 @@ function change_to_sm_path($old_path) {
         // we're within the SM tree, prepend SM_PATH
         $new_path = str_replace('../',"SM_PATH . '", $old_path . "'");
     } else {
-        // Last, if it's a relative path without a .. prefix, 
+        // Last, if it's a relative path without a .. prefix,
         // we're somewhere within the config dir, so prepend
-        //  SM_PATH . 'config/  
+        //  SM_PATH . 'config/
         $new_path = "SM_PATH . 'config/" . $old_path . "'";
     }
     return $new_path;
@@ -219,9 +225,7 @@ define('SM_PATH','../../');
 
 /* SquirrelMail required files. */
 require_once(SM_PATH . 'include/validate.php');
-require_once(SM_PATH . 'functions/page_header.php');
 require_once(SM_PATH . 'functions/imap.php');
-require_once(SM_PATH . 'include/load_prefs.php');
 require_once(SM_PATH . 'plugins/administrator/defines.php');
 require_once(SM_PATH . 'plugins/administrator/auth.php');
 
@@ -254,7 +258,8 @@ $colapse = array( 'Titles' => 'off',
                   'Group7' => getPref($data_dir, $username, 'adm_Group7', 'on' ),
                   'Group8' => getPref($data_dir, $username, 'adm_Group8', 'on' ),
                   'Group9' => getPref($data_dir, $username, 'adm_Group9', 'on' ),
-                  'Group10' => getPref($data_dir, $username, 'adm_Group10', 'on' ) );
+                  'Group10' => getPref($data_dir, $username, 'adm_Group10', 'on' ),
+                  'Group11' => getPref($data_dir, $username, 'adm_Group11', 'on' ) );
 
 /* look in $_GET array for 'switch' */
 if ( sqgetGlobalVar('switch', $switch, SQ_GET) ) {
@@ -353,8 +358,8 @@ foreach ( $newcfg as $k => $v ) {
             break;
         case SMOPT_TYPE_INTEGER:
             /* look for variable $e in POST, fill into $v */
-            if ( sqgetGlobalVar($e, $v, SQ_POST) ) {
-                $v = intval( $v );
+            if ( sqgetGlobalVar($e, $new_v, SQ_POST) ) {
+                $v = intval( $new_v );
                 $newcfg[$k] = $v;
             }
             echo "<tr><td>$name</td><td>".
@@ -365,7 +370,8 @@ foreach ( $newcfg as $k => $v ) {
             echo "</td></tr>\n";
             break;
         case SMOPT_TYPE_NUMLIST:
-            if (  sqgetGlobalVar($e, $v, SQ_POST) ) {
+            if (  sqgetGlobalVar($e, $new_v, SQ_POST) ) {
+                $v = $new_v;
                 $newcfg[$k] = $v;
             }
             echo "<tr><td>$name</td><td>";
@@ -384,8 +390,8 @@ foreach ( $newcfg as $k => $v ) {
             echo "</td></tr>\n";
             break;
         case SMOPT_TYPE_STRLIST:
-            if (  sqgetGlobalVar($e, $v, SQ_POST) ) {
-                $v = '"' . $v . '"';
+            if (  sqgetGlobalVar($e, $new_v, SQ_POST) ) {
+                $v = '"' . $new_v . '"';
                 $newcfg[$k] = $v;
             }
             echo "<tr><td>$name</td><td>".
@@ -405,8 +411,8 @@ foreach ( $newcfg as $k => $v ) {
             break;
 
         case SMOPT_TYPE_TEXTAREA:
-            if (  sqgetGlobalVar($e, $v, SQ_POST) ) {
-                $v = '"' . $v . '"';
+            if (  sqgetGlobalVar($e, $new_v, SQ_POST) ) {
+                $v = '"' . $new_v . '"';
                 $newcfg[$k] = str_replace( "\n", '', $v );
             }
             echo "<tr><td valign=\"top\">$name</td><td>".
@@ -417,8 +423,8 @@ foreach ( $newcfg as $k => $v ) {
             echo "</td></tr>\n";
             break;
         case SMOPT_TYPE_STRING:
-            if (  sqgetGlobalVar($e, $v, SQ_POST) ) {
-                $v = '"' . $v . '"';
+            if (  sqgetGlobalVar($e, $new_v, SQ_POST) ) {
+                $v = '"' . $new_v . '"';
                 $newcfg[$k] = $v;
             }
             if ( $v == '""' && isset( $defcfg[$k]['default'] ) ) {
@@ -433,7 +439,8 @@ foreach ( $newcfg as $k => $v ) {
             echo "</td></tr>\n";
             break;
         case SMOPT_TYPE_BOOLEAN:
-            if (  sqgetGlobalVar($e, $v, SQ_POST) ) {
+            if (  sqgetGlobalVar($e, $new_v, SQ_POST) ) {
+                $v = $new_v;
                 $newcfg[$k] = $v;
             } else {
                 $v = strtoupper( $v );
@@ -454,9 +461,10 @@ foreach ( $newcfg as $k => $v ) {
             echo "</td></tr>\n";
             break;
         case SMOPT_TYPE_PATH:
-            if (  sqgetGlobalVar($e, $v, SQ_POST) ) {
-               $v = change_to_sm_path($v);
-               $newcfg[$k] = $v;
+            if (  sqgetGlobalVar($e, $new_v, SQ_POST) ) {
+                // FIXME: fix use of $data_dir in $attachment_dir 
+                $v = change_to_sm_path($new_v);
+                $newcfg[$k] = $v;
             }
             if ( $v == "''" && isset( $defcfg[$k]['default'] ) ) {
                $v = change_to_sm_path($defcfg[$k]['default']);
@@ -543,9 +551,9 @@ if ( $colapse['Group8'] == 'off' ) {
 
         /* Lets get the plugins that are active */
         $plugins = array();
-        if (  sqgetGlobalVar('plg', $v, SQ_POST) ) {
+        if ( sqgetGlobalVar('plg', $v, SQ_POST) ) {
             foreach ( $op_plugin as $plg ) {
-                if (  sqgetGlobalVar("plgs_$plg", $v, SQ_POST) && $v == 'on' ) {
+                if (  sqgetGlobalVar("plgs_$plg", $v2, SQ_POST) && $v2 == 'on' ) {
                     $plugins[] = $plg;
                 }
             }
@@ -619,9 +627,13 @@ if ( $fp = @fopen( $cfgfile, 'w' ) ) {
                 $v = str_replace( 'array(', "array(\n\t", $v );
                 $v = str_replace( "',", "',\n\t", $v );
             }
+            /* FIXME: add elseif that reverts plugins[#] to plugins[] */
             fwrite( $fp, "$k = $v;\n" );
         }
     }
+    // add local config support
+    fwrite( $fp, "@include SM_PATH . 'config/config_local.php';\n" );
+    // close php
     fwrite( $fp, '?>' );
     fclose( $fp );
 } else {