Plugins administration completed.
authorphilippe_mingo <philippe_mingo@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 31 Jan 2002 10:15:55 +0000 (10:15 +0000)
committerphilippe_mingo <philippe_mingo@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 31 Jan 2002 10:15:55 +0000 (10:15 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2308 7612ce4b-ef26-0410-bec9-ea0150e637f0

plugins/administrator/options.php

index 031ca43718b1ce596a55faeb6a8e22fac39ce262..55e5da07a3d1918082033b09487fc75a1a10ea87 100644 (file)
@@ -179,13 +179,13 @@ if ( isset( $switch ) ) {
     setPref($data_dir, $username, "adm_$switch", $colapse[$switch] );
 }
 
     setPref($data_dir, $username, "adm_$switch", $colapse[$switch] );
 }
 
-echo "<form action=$PHP_SELF method=post>" .
+echo "<form action=options.php method=post>" .
     "<br><center><table width=95% bgcolor=\"$color[5]\"><tr><td>".
     "<table width=100% cellspacing=0 bgcolor=\"$color[4]\">" ,
     "<tr bgcolor=\"$color[5]\"><th colspan=2>" . _("Configuration Administrator") . "</th></tr>";
 
 $act_grp = 'Titles';  /* Active group */
     "<br><center><table width=95% bgcolor=\"$color[5]\"><tr><td>".
     "<table width=100% cellspacing=0 bgcolor=\"$color[4]\">" ,
     "<tr bgcolor=\"$color[5]\"><th colspan=2>" . _("Configuration Administrator") . "</th></tr>";
 
 $act_grp = 'Titles';  /* Active group */
-    
+
 foreach ( $newcfg as $k => $v ) {
     $l = strtolower( $v );
     $type = SMOPT_TYPE_UNDEFINED;
 foreach ( $newcfg as $k => $v ) {
     $l = strtolower( $v );
     $type = SMOPT_TYPE_UNDEFINED;
@@ -300,7 +300,7 @@ foreach ( $newcfg as $k => $v ) {
             }
             echo "</td></tr>\n";
             break;
             }
             echo "</td></tr>\n";
             break;
-    
+
         case SMOPT_TYPE_TEXTAREA:
             if ( isset( $HTTP_POST_VARS[$e] ) ) {
                 $v = '"' . $HTTP_POST_VARS[$e] . '"';
         case SMOPT_TYPE_TEXTAREA:
             if ( isset( $HTTP_POST_VARS[$e] ) ) {
                 $v = '"' . $HTTP_POST_VARS[$e] . '"';
@@ -389,7 +389,7 @@ if ( !($colapse['Group7']) ) {
              "<td><input name=\"$e2\" value=\"$path\" size=40></td>".
              "</tr>\n";
         $i++;
              "<td><input name=\"$e2\" value=\"$path\" size=40></td>".
              "</tr>\n";
         $i++;
-    
+
     }
 }
 
     }
 }
 
@@ -400,50 +400,66 @@ if ( $colapse['Group8'] ) {
     $sw = '(-)';
 }
 echo "<tr bgcolor=\"$color[0]\"><th colspan=2>" .
     $sw = '(-)';
 }
 echo "<tr bgcolor=\"$color[0]\"><th colspan=2>" .
-     "<a href=options.php?switch=Group7 STYLE=\"text-decoration:none\"><b>$sw</b> </a>" .
+     "<a href=options.php?switch=Group8 STYLE=\"text-decoration:none\"><b>$sw</b> </a>" .
      _("Plugins") . '</th></tr>';
 
 if( !$colapse['Group8'] ) {
 
     $fd = opendir( '../plugins/' );
     $op_plugin = array();
      _("Plugins") . '</th></tr>';
 
 if( !$colapse['Group8'] ) {
 
     $fd = opendir( '../plugins/' );
     $op_plugin = array();
+    $p_count = 0;
     while (false!==($file = readdir($fd))) {
         if ($file != '.' && $file != '..' && $file != 'CVS' ) {
             if ( filetype( $file ) == 'dir' ) {
                 $op_plugin[] = $file;
     while (false!==($file = readdir($fd))) {
         if ($file != '.' && $file != '..' && $file != 'CVS' ) {
             if ( filetype( $file ) == 'dir' ) {
                 $op_plugin[] = $file;
+                $p_count++;
             }
         }
     }
     closedir($fd);
     asort( $op_plugin );
             }
         }
     }
     closedir($fd);
     asort( $op_plugin );
-    
-    $i = 0;
-    while ( isset( $newcfg["\$plugins[$i]"] ) ) {
-        $k = "\$plugins[$i]";
-        $e = "plugin_$i";
-        if ( isset( $HTTP_POST_VARS[$e] ) ) {
-            $v = '"' . $HTTP_POST_VARS[$e] . '"';
-            $newcfg[$k] = $v;
-        } else {
+
+    /* Lets get the plugins that are active */
+    $plugins = array();
+    if ( isset( $HTTP_POST_VARS['plg'] ) ) {
+        foreach ( $op_plugin as $plg ) {
+            if ( $HTTP_POST_VARS["plgs_$plg"] == 'on' ) {
+                $plugins[] = $plg;
+            }
+        }
+        $i = 0;
+        foreach ( $plugins as $plg ) {
+            $k = "\$plugins[$i]";
+            $newcfg[$k] = "'$plg'";
+            $i++;
+        }
+        while ( isset( $newcfg["\$plugins[$i]"] ) ) {
+            $k = "\$plugins[$i]";
+            $newcfg[$k] = '';
+            $i++;
+        }
+    } else {
+        $i = 0;
+        while ( isset( $newcfg["\$plugins[$i]"] ) ) {
+            $k = "\$plugins[$i]";
             $v = $newcfg[$k];
             $v = $newcfg[$k];
+            $plugins[] = substr( $v, 1, strlen( $v ) - 2 );
+            $i++;
         }
         }
-        $name = substr( $v, 1, strlen( $v ) - 2 );
-        echo '<tr>'.
-             "<td align=right>$i.</td>".
-             "<td><select name=\"$e\">";
-        foreach ( $op_plugin as $op ) {
-            if ( $op == $name ) {
-                $cs = ' selected';
-            } else {
-                $cs = '';
-            }
-            echo "<option$cs>$op</option>";
+    }
+    echo "<tr><td colspan=2><input type=hidden name=plg value=on><center><table><tr><td>";
+    foreach ( $op_plugin as $plg ) {
+        if ( in_array( $plg, $plugins ) ) {
+            $sw = ' checked';
+        } else {
+            $sw = '';
         }
         }
-        echo "</select></td>".
+        echo '<tr>' .
+             "<td>$plg</td><td><input$sw type=checkbox name=plgs_$plg></td>".
              '</tr>';
              '</tr>';
-        $i++;
-    
     }
     }
+    echo '</td></tr></table>';
+
 }
 echo "<tr bgcolor=\"$color[5]\"><th colspan=2><input value=\"" .
      _("Change Settings") . "\" type=submit></th></tr>" ,
 }
 echo "<tr bgcolor=\"$color[5]\"><th colspan=2><input value=\"" .
      _("Change Settings") . "\" type=submit></th></tr>" ,
@@ -484,7 +500,7 @@ foreach ( $newcfg as $k => $v ) {
 fwrite( $fp, ";\n" );
 */
 foreach ( $newcfg as $k => $v ) {
 fwrite( $fp, ";\n" );
 */
 foreach ( $newcfg as $k => $v ) {
-    if ( $k{0} == '$' ) {
+    if ( $k{0} == '$' && $v <> '' ) {
         if ( substr( $k, 1, 11 ) == 'ldap_server' ) {
             $v = substr( $v, 0, strlen( $v ) - 1 ) . "\n)";
             $v = str_replace( 'array(', "array(\n\t", $v );
         if ( substr( $k, 1, 11 ) == 'ldap_server' ) {
             $v = substr( $v, 0, strlen( $v ) - 1 ) . "\n)";
             $v = str_replace( 'array(', "array(\n\t", $v );