瀏覽代碼

defines.php now indicates the order for options display. Added a group
type in order to place options under different titles.

Not yet finished.

philippe_mingo 23 年之前
父節點
當前提交
38ae25567f
共有 2 個文件被更改,包括 83 次插入30 次删除
  1. 39 8
      plugins/administrator/defines.php
  2. 44 22
      plugins/administrator/options.php

+ 39 - 8
plugins/administrator/defines.php

@@ -22,6 +22,7 @@ define('SMOPT_TYPE_FLOAT', 4);
 define('SMOPT_TYPE_BOOLEAN', 5);
 define('SMOPT_TYPE_BOOLEAN', 5);
 define('SMOPT_TYPE_HIDDEN', 6);
 define('SMOPT_TYPE_HIDDEN', 6);
 define('SMOPT_TYPE_COMMENT', 7);
 define('SMOPT_TYPE_COMMENT', 7);
+define('SMOPT_TYPE_TITLE', 128);
 
 
 /* Define constants for the options refresh levels. */
 /* Define constants for the options refresh levels. */
 define('SMOPT_REFRESH_NONE', 0);
 define('SMOPT_REFRESH_NONE', 0);
@@ -48,38 +49,68 @@ foreach ($languages as $lang_key => $lang_attributes) {
 }
 }
 asort( $language_values );
 asort( $language_values );
 
 
-$namcfg = array( '$config_version' => array( 'name' => _("Config File Version"),
-                                             'type' => 'string',
+$defcfg = array( '$config_version' => array( 'name' => _("Config File Version"),
+                                             'type' => SMOPT_TYPE_COMMENT,
                                              'size' => 7 ),
                                              'size' => 7 ),
-                 '$org_logo' => array( 'name' => _("Organization Logo"),
+                 /* --------------------------------------------------------*/
+                 'Group1' => array( 'name' => _("Organization Preferences"),
+                                    'type' => SMOPT_TYPE_TITLE ),
+                 '$org_name' => array( 'name' => _("Organization Name"),
                                        'type' => SMOPT_TYPE_STRING,
                                        'type' => SMOPT_TYPE_STRING,
                                        'size' => 40 ),
                                        'size' => 40 ),
-                 '$org_name' => array( 'name' => _("Organization Name"),
+                 '$org_logo' => array( 'name' => _("Organization Logo"),
                                        'type' => SMOPT_TYPE_STRING,
                                        'type' => SMOPT_TYPE_STRING,
                                        'size' => 40 ),
                                        'size' => 40 ),
-                 '$org_title' => array( 'name' => _("Organization Name"),
+                 '$org_title' => array( 'name' => _("Organization Title"),
                                         'type' => SMOPT_TYPE_STRING,
                                         'type' => SMOPT_TYPE_STRING,
                                         'size' => 40 ),
                                         'size' => 40 ),
+                 '$signout_page' => array( 'name' => _("Signout Page"),
+                                           'type' => SMOPT_TYPE_STRING,
+                                           'size' => 40 ),
                  '$squirrelmail_default_language' => array( 'name' => _("Default Language"),
                  '$squirrelmail_default_language' => array( 'name' => _("Default Language"),
                                                             'type' => SMOPT_TYPE_STRLIST,
                                                             'type' => SMOPT_TYPE_STRLIST,
                                                             'size' => 7,
                                                             'size' => 7,
                                                             'posvals' => $language_values ),
                                                             'posvals' => $language_values ),
+                 /* --------------------------------------------------------*/
+                 'Group2' => array( 'name' => _("Server Settings"),
+                                    'type' => SMOPT_TYPE_TITLE ),
+                 '$domain' => array( 'name' => _("Mail Domain"),
+                                                'type' => SMOPT_TYPE_STRING,
+                                                'size' => 40 ),
                  '$imapServerAddress' => array( 'name' => _("IMAP Server Address"),
                  '$imapServerAddress' => array( 'name' => _("IMAP Server Address"),
                                                 'type' => SMOPT_TYPE_STRING,
                                                 'type' => SMOPT_TYPE_STRING,
                                                 'size' => 40 ),
                                                 'size' => 40 ),
                  '$imapPort' => array( 'name' => _("IMAP Server Port"),
                  '$imapPort' => array( 'name' => _("IMAP Server Port"),
                                                  'type' => SMOPT_TYPE_INTEGER ),
                                                  'type' => SMOPT_TYPE_INTEGER ),
-                 '$domain' => array( 'name' => _("Mail Domain"),
-                                                'type' => SMOPT_TYPE_STRING,
-                                                'size' => 40 ),
+                 '$imap_server_type' => array( 'name' => _("IMAP Server Type"),
+                                               'type' => SMOPT_TYPE_STRLIST,
+                                               'size' => 7,
+                                               'posvals' => array( 'cyrus' => _("Cyrus IMAP server"),
+                                                                   'uw' => _("University of Washington's IMAP server"),
+                                                                   'exchange' => _("Microsoft Exchange IMAP server"),
+                                                                   'courier' => _("Courier IMAP server"),
+                                                                   'other' => _("Not one of the above servers") ) ),
+                 '$optional_delimiter' => array( 'name' => _("IMAP Folder Delimiter"),
+                                                 'type' => SMOPT_TYPE_STRING,
+                                                 'size' => 2 ),
+                 '$useSendmail' => array( 'name' => _("Use Sendmail"),
+                                          'type' => SMOPT_TYPE_BOOLEAN ),
                  '$smtpServerAddress' => array( 'name' => _("SMTP Server Address"),
                  '$smtpServerAddress' => array( 'name' => _("SMTP Server Address"),
                                                 'type' => SMOPT_TYPE_STRING,
                                                 'type' => SMOPT_TYPE_STRING,
                                                 'size' => 40 ),
                                                 'size' => 40 ),
                  '$smtpPort' => array( 'name' => _("SMTP Server Port"),
                  '$smtpPort' => array( 'name' => _("SMTP Server Port"),
                                                  'type' => SMOPT_TYPE_INTEGER ),
                                                  'type' => SMOPT_TYPE_INTEGER ),
+                 '$use_authenticated_smtp' => array( 'name' => _("Authenticated SMTP"),
+                                                     'type' => SMOPT_TYPE_BOOLEAN ),
+                 '$invert_time' => array( 'name' => _("Invert Time"),
+                                          'type' => SMOPT_TYPE_BOOLEAN ),
+                 /* --------------------------------------------------------*/
+                 'Group3' => array( 'name' => _("Folders Defaults"),
+                                    'type' => SMOPT_TYPE_TITLE ),
                  '$motd' => array( 'name' => _("Message of the Day"),
                  '$motd' => array( 'name' => _("Message of the Day"),
                                              'type' => SMOPT_TYPE_STRING,
                                              'type' => SMOPT_TYPE_STRING,
                                              'size' => 40 ),
                                              'size' => 40 ),
+
                );
                );
 
 
 ?>
 ?>

+ 44 - 22
plugins/administrator/options.php

@@ -23,9 +23,15 @@ displayPageHeader($color, 'None');
 $cfgfile = '../config/config.php';
 $cfgfile = '../config/config.php';
 $cfg_defaultfile = '../config/config_default.php';
 $cfg_defaultfile = '../config/config_default.php';
 $cfg = file( $cfg_defaultfile );
 $cfg = file( $cfg_defaultfile );
-$newcfg = $defcfg = array( );
+$newcfg = $dfncfg = array( );
 $cm = FALSE;
 $cm = FALSE;
+
+foreach ( $defcfg as $key => $def ) {
+    $newcfg[$key] = '';
+}
+
 foreach ( $cfg as $l ) {
 foreach ( $cfg as $l ) {
+    // Remove inline /* */ Blocks
     $l = preg_replace( '/\/\*.*\*\//', '', $l );
     $l = preg_replace( '/\/\*.*\*\//', '', $l );
     $l = preg_replace( '/#.*$/', '', $l );
     $l = preg_replace( '/#.*$/', '', $l );
     $l = preg_replace( '/\/\/.*$/', '', $l );
     $l = preg_replace( '/\/\/.*$/', '', $l );
@@ -54,13 +60,12 @@ foreach ( $cfg as $l ) {
         $key = trim( substr( $v, 0, $i - 1 ) );
         $key = trim( substr( $v, 0, $i - 1 ) );
         $val = str_replace( ';', '', trim( substr( $v, $i + 1 ) ) );
         $val = str_replace( ';', '', trim( substr( $v, $i + 1 ) ) );
         $newcfg[$key] = $val;
         $newcfg[$key] = $val;
-        $defcfg[$key] = $val;
+        $dfncfg[$key] = $val;
     }
     }
 
 
 }
 }
 
 
 $cfg = file( $cfgfile );
 $cfg = file( $cfgfile );
-asort( $cfg );
 
 
 $cm = FALSE;
 $cm = FALSE;
 foreach ( $cfg as $l ) {
 foreach ( $cfg as $l ) {
@@ -97,7 +102,8 @@ foreach ( $cfg as $l ) {
 }
 }
 
 
 echo "<form action=$PHP_SELF method=post>" .
 echo "<form action=$PHP_SELF method=post>" .
-    '<table width=100%>' ,
+    "<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>";
     "<tr bgcolor=\"$color[5]\"><th colspan=2>" . _("Configuration Administrator") . "</th></tr>";
 foreach ( $newcfg as $k => $v ) {
 foreach ( $newcfg as $k => $v ) {
     $l = strtolower( $v );
     $l = strtolower( $v );
@@ -108,10 +114,10 @@ foreach ( $newcfg as $k => $v ) {
     $e = 'adm_' . $n;
     $e = 'adm_' . $n;
     $name = $k;
     $name = $k;
     $size = 50;
     $size = 50;
-    if ( isset( $namcfg[$k] ) ) {
-        $name = $namcfg[$k]['name'];
-        $type = $namcfg[$k]['type'];
-        $size = $namcfg[$k]['size'];
+    if ( isset( $defcfg[$k] ) ) {
+        $name = $defcfg[$k]['name'];
+        $type = $defcfg[$k]['type'];
+        $size = $defcfg[$k]['size'];
     } else if ( $l == 'true' ) {
     } else if ( $l == 'true' ) {
         $v = 'TRUE';
         $v = 'TRUE';
         $type = SMOPT_TYPE_BOOLEAN;
         $type = SMOPT_TYPE_BOOLEAN;
@@ -124,14 +130,22 @@ foreach ( $newcfg as $k => $v ) {
         $type = SMOPT_TYPE_STRING;
         $type = SMOPT_TYPE_STRING;
     }
     }
 
 
-    echo "<tr><td>$name</td><td>";
-
     switch ( $type ) {
     switch ( $type ) {
+    case SMOPT_TYPE_TITLE:
+        echo "<tr bgcolor=\"$color[5]\"><th colspan=2>$name</th></tr>";
+        break;
+    case SMOPT_TYPE_COMMENT:
+        $v = substr( $v, 1, strlen( $v ) - 2 );
+        echo "<tr><td>$name</td><td>";
+        echo "<b>$v</b>";
+        $newcfg[$k] = "'$v'";
+        break;
     case SMOPT_TYPE_INTEGER:
     case SMOPT_TYPE_INTEGER:
         if ( isset( $HTTP_POST_VARS[$e] ) ) {
         if ( isset( $HTTP_POST_VARS[$e] ) ) {
             $v = intval( $HTTP_POST_VARS[$e] );
             $v = intval( $HTTP_POST_VARS[$e] );
             $newcfg[$k] = $v;
             $newcfg[$k] = $v;
         }
         }
+        echo "<tr><td>$name</td><td>";
         echo "<input size=10 name=\"adm_$n\" value=\"$v\">";
         echo "<input size=10 name=\"adm_$n\" value=\"$v\">";
         break;
         break;
     case SMOPT_TYPE_STRLIST:
     case SMOPT_TYPE_STRLIST:
@@ -139,8 +153,9 @@ foreach ( $newcfg as $k => $v ) {
             $v = '"' . $HTTP_POST_VARS[$e] . '"';
             $v = '"' . $HTTP_POST_VARS[$e] . '"';
             $newcfg[$k] = $v;
             $newcfg[$k] = $v;
         }
         }
+        echo "<tr><td>$name</td><td>";
         echo "<select name=\"adm_$n\">";
         echo "<select name=\"adm_$n\">";
-        foreach ( $namcfg[$k]['posvals'] as $kp => $vp ) {
+        foreach ( $defcfg[$k]['posvals'] as $kp => $vp ) {
             echo "<option value=\"$kp\"";
             echo "<option value=\"$kp\"";
             if ( $kp == substr( $v, 1, strlen( $v ) - 2 ) ) {
             if ( $kp == substr( $v, 1, strlen( $v ) - 2 ) ) {
                 echo ' selected';
                 echo ' selected';
@@ -155,6 +170,7 @@ foreach ( $newcfg as $k => $v ) {
             $v = '"' . $HTTP_POST_VARS[$e] . '"';
             $v = '"' . $HTTP_POST_VARS[$e] . '"';
             $newcfg[$k] = $v;
             $newcfg[$k] = $v;
         }
         }
+        echo "<tr><td>$name</td><td>";
         echo "<input size=\"$size\" name=\"adm_$n\" value=\"" . substr( $v, 1, strlen( $v ) - 2 ) . "\">";
         echo "<input size=\"$size\" name=\"adm_$n\" value=\"" . substr( $v, 1, strlen( $v ) - 2 ) . "\">";
         break;
         break;
     case SMOPT_TYPE_BOOLEAN:
     case SMOPT_TYPE_BOOLEAN:
@@ -169,17 +185,19 @@ foreach ( $newcfg as $k => $v ) {
             $ct = '';
             $ct = '';
             $cf = ' checked';
             $cf = ' checked';
         }
         }
+        echo "<tr><td>$name</td><td>";
         echo "<INPUT$ct type=radio NAME=\"adm_$n\" value=\"TRUE\">" . _("Yes") .
         echo "<INPUT$ct type=radio NAME=\"adm_$n\" value=\"TRUE\">" . _("Yes") .
             "<INPUT$cf type=radio NAME=\"adm_$n\" value=\"FALSE\">" . _("No");
             "<INPUT$cf type=radio NAME=\"adm_$n\" value=\"FALSE\">" . _("No");
         break;
         break;
     default:
     default:
+        echo "<tr><td>$name</td><td>";
         echo "<b><i>$v</i></b>";
         echo "<b><i>$v</i></b>";
     }
     }
     echo "</td></tr>\n";
     echo "</td></tr>\n";
 }
 }
 echo "<tr bgcolor=\"$color[5]\"><th colspan=2><input value=\"" .
 echo "<tr bgcolor=\"$color[5]\"><th colspan=2><input value=\"" .
      _("Change Settings") . "\" type=submit></th></tr>" ,
      _("Change Settings") . "\" type=submit></th></tr>" ,
-     '</table></form>';
+     '</table></td></tr></table></form>';
 
 
 /*
 /*
     Write the options to the file.
     Write the options to the file.
@@ -194,25 +212,29 @@ fwrite( $fp, "<?PHP\n".
 fwrite( $fp, 'GLOBAL ' );
 fwrite( $fp, 'GLOBAL ' );
 $not_first = FALSE;
 $not_first = FALSE;
 foreach ( $newcfg as $k => $v ) {
 foreach ( $newcfg as $k => $v ) {
-    if( $i = strpos( $k, '[' ) ) {
-        if( strpos( $k, '[0]' ) ) {
+    if ( $k{0} == '$' ) {
+        if( $i = strpos( $k, '[' ) ) {
+            if( strpos( $k, '[0]' ) ) {
+                if( $not_first ) {
+                    fwrite( $fp, ', ' );
+                }
+                fwrite( $fp, substr( $k, 0, $i) );
+                $not_first = TRUE;
+            }
+        } else {
             if( $not_first ) {
             if( $not_first ) {
                 fwrite( $fp, ', ' );
                 fwrite( $fp, ', ' );
             }
             }
-            fwrite( $fp, substr( $k, 0, $i) );
+            fwrite( $fp, $k );
             $not_first = TRUE;
             $not_first = TRUE;
         }
         }
-    } else {
-        if( $not_first ) {
-            fwrite( $fp, ', ' );
-        }
-        fwrite( $fp, $k );
-        $not_first = TRUE;
     }
     }
 }
 }
 fwrite( $fp, ";\n" );
 fwrite( $fp, ";\n" );
 foreach ( $newcfg as $k => $v ) {
 foreach ( $newcfg as $k => $v ) {
-    fwrite( $fp, "$k = $v;\n" );
+    if ( $k{0} == '$' ) {
+        fwrite( $fp, "$k = $v;\n" );
+    }
 }
 }
 fwrite( $fp, '?>' );
 fwrite( $fp, '?>' );
 fclose( $fp );
 fclose( $fp );