From 0e66bc84e81ea32f8d44c54b2142db17d040c0ef Mon Sep 17 00:00:00 2001 From: philippe_mingo Date: Sun, 27 Jan 2002 16:55:18 +0000 Subject: [PATCH] defines.php now indicates the order for options display. Added a group type in order to place options under different titles. Not yet finished. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2248 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- plugins/administrator/defines.php | 47 ++++++++++++++++++---- plugins/administrator/options.php | 66 ++++++++++++++++++++----------- 2 files changed, 83 insertions(+), 30 deletions(-) diff --git a/plugins/administrator/defines.php b/plugins/administrator/defines.php index d7180b8a..572e3bf7 100644 --- a/plugins/administrator/defines.php +++ b/plugins/administrator/defines.php @@ -22,6 +22,7 @@ define('SMOPT_TYPE_FLOAT', 4); define('SMOPT_TYPE_BOOLEAN', 5); define('SMOPT_TYPE_HIDDEN', 6); define('SMOPT_TYPE_COMMENT', 7); +define('SMOPT_TYPE_TITLE', 128); /* Define constants for the options refresh levels. */ define('SMOPT_REFRESH_NONE', 0); @@ -48,38 +49,68 @@ foreach ($languages as $lang_key => $lang_attributes) { } 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 ), - '$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, 'size' => 40 ), - '$org_name' => array( 'name' => _("Organization Name"), + '$org_logo' => array( 'name' => _("Organization Logo"), 'type' => SMOPT_TYPE_STRING, 'size' => 40 ), - '$org_title' => array( 'name' => _("Organization Name"), + '$org_title' => array( 'name' => _("Organization Title"), 'type' => SMOPT_TYPE_STRING, 'size' => 40 ), + '$signout_page' => array( 'name' => _("Signout Page"), + 'type' => SMOPT_TYPE_STRING, + 'size' => 40 ), '$squirrelmail_default_language' => array( 'name' => _("Default Language"), 'type' => SMOPT_TYPE_STRLIST, 'size' => 7, '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"), 'type' => SMOPT_TYPE_STRING, 'size' => 40 ), '$imapPort' => array( 'name' => _("IMAP Server Port"), '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"), 'type' => SMOPT_TYPE_STRING, 'size' => 40 ), '$smtpPort' => array( 'name' => _("SMTP Server Port"), '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"), 'type' => SMOPT_TYPE_STRING, 'size' => 40 ), + ); ?> \ No newline at end of file diff --git a/plugins/administrator/options.php b/plugins/administrator/options.php index b4600f6e..d75b0625 100644 --- a/plugins/administrator/options.php +++ b/plugins/administrator/options.php @@ -23,9 +23,15 @@ displayPageHeader($color, 'None'); $cfgfile = '../config/config.php'; $cfg_defaultfile = '../config/config_default.php'; $cfg = file( $cfg_defaultfile ); -$newcfg = $defcfg = array( ); +$newcfg = $dfncfg = array( ); $cm = FALSE; + +foreach ( $defcfg as $key => $def ) { + $newcfg[$key] = ''; +} + foreach ( $cfg as $l ) { + // Remove inline /* */ Blocks $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 ) ); $val = str_replace( ';', '', trim( substr( $v, $i + 1 ) ) ); $newcfg[$key] = $val; - $defcfg[$key] = $val; + $dfncfg[$key] = $val; } } $cfg = file( $cfgfile ); -asort( $cfg ); $cm = FALSE; foreach ( $cfg as $l ) { @@ -97,7 +102,8 @@ foreach ( $cfg as $l ) { } echo "
" . - '' , + "
". + "" , ""; foreach ( $newcfg as $k => $v ) { $l = strtolower( $v ); @@ -108,10 +114,10 @@ foreach ( $newcfg as $k => $v ) { $e = 'adm_' . $n; $name = $k; $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' ) { $v = 'TRUE'; $type = SMOPT_TYPE_BOOLEAN; @@ -124,14 +130,22 @@ foreach ( $newcfg as $k => $v ) { $type = SMOPT_TYPE_STRING; } - echo ""; + break; + case SMOPT_TYPE_COMMENT: + $v = substr( $v, 1, strlen( $v ) - 2 ); + echo "\n"; } echo "" , - '
" . _("Configuration Administrator") . "
$name"; - switch ( $type ) { + case SMOPT_TYPE_TITLE: + echo "
$name
$name"; + echo "$v"; + $newcfg[$k] = "'$v'"; + break; case SMOPT_TYPE_INTEGER: if ( isset( $HTTP_POST_VARS[$e] ) ) { $v = intval( $HTTP_POST_VARS[$e] ); $newcfg[$k] = $v; } + echo "
$name"; echo ""; break; case SMOPT_TYPE_STRLIST: @@ -139,8 +153,9 @@ foreach ( $newcfg as $k => $v ) { $v = '"' . $HTTP_POST_VARS[$e] . '"'; $newcfg[$k] = $v; } + echo "
$name"; echo "
$name"; echo ""; break; case SMOPT_TYPE_BOOLEAN: @@ -169,17 +185,19 @@ foreach ( $newcfg as $k => $v ) { $ct = ''; $cf = ' checked'; } + echo "
$name"; echo "" . _("Yes") . "" . _("No"); break; default: + echo "
$name"; echo "$v"; } echo "
'; + '
'; /* Write the options to the file. @@ -194,25 +212,29 @@ fwrite( $fp, " $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 ) { fwrite( $fp, ', ' ); } - fwrite( $fp, substr( $k, 0, $i) ); + fwrite( $fp, $k ); $not_first = TRUE; } - } else { - if( $not_first ) { - fwrite( $fp, ', ' ); - } - fwrite( $fp, $k ); - $not_first = TRUE; } } fwrite( $fp, ";\n" ); foreach ( $newcfg as $k => $v ) { - fwrite( $fp, "$k = $v;\n" ); + if ( $k{0} == '$' ) { + fwrite( $fp, "$k = $v;\n" ); + } } fwrite( $fp, '?>' ); fclose( $fp ); -- 2.25.1