Users can disable: AllowUserDropDatabase, UseDbSearch, QueryHistoryDB, ShowPhpInfo, ShowChgPassword

Users can change: QueryHistoryMax (must be lower than value from file config)
This commit is contained in:
Crack
2010-07-20 21:57:05 +02:00
parent a8ed8e6123
commit 43a7629da9
9 changed files with 64 additions and 19 deletions

View File

@@ -2316,6 +2316,17 @@ $cfg['InitialSlidersState'] = 'closed';
*/ */
$cfg['UserprefsDisallow'] = array(); $cfg['UserprefsDisallow'] = array();
/**
* User preferences: disabling options by users
*/
$cfg['disable'] = array(
'AllowUserDropDatabase' => false,
'UseDbSearch' => false,
'QueryHistoryDB' => false,
'ShowPhpInfo' => false,
'ShowChgPassword' => false
);
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// custom-setup by mkkeck: 2004-05-04 // custom-setup by mkkeck: 2004-05-04
// some specials for new icons and scrolling // some specials for new icons and scrolling

View File

@@ -163,5 +163,6 @@ $cfg_db['_validators'] = array(
*/ */
$cfg_db['_userValidators'] = array( $cfg_db['_userValidators'] = array(
'MaxDbList' => array(array('validate_upper_bound', 'value:MaxDbList')), 'MaxDbList' => array(array('validate_upper_bound', 'value:MaxDbList')),
'MaxTableList' => array(array('validate_upper_bound', 'value:MaxTableList'))); 'MaxTableList' => array(array('validate_upper_bound', 'value:MaxTableList')),
'QueryHistoryMax' => array(array('validate_upper_bound', 'value:QueryHistoryMax')),);
?> ?>

View File

@@ -699,7 +699,9 @@ class FormDisplay
*/ */
private static function _getOptName($path) private static function _getOptName($path)
{ {
return str_replace(array('Servers/1/', '/'), array('Servers/', '_'), $path); return str_replace(
array('Servers/1/', 'disable/', '/'),
array('Servers/', '', '_'), $path);
} }
} }
?> ?>

View File

@@ -155,15 +155,15 @@ function display_input($path, $name, $description = '', $type, $value, $value_is
<tr<?php echo $tr_class ?>> <tr<?php echo $tr_class ?>>
<th> <th>
<label for="<?php echo htmlspecialchars($path) ?>"><?php echo $name ?></label> <label for="<?php echo htmlspecialchars($path) ?>"><?php echo $name ?></label>
<?php if (!empty($opts['doc']) || !empty($opts['wiki'])): ?> <?php if (!empty($opts['doc']) || !empty($opts['wiki'])) { ?>
<span class="doc"> <span class="doc">
<?php if (!empty($opts['doc'])) { ?><a href="<?php echo $base_dir . $opts['doc'] ?>" target="documentation"><img class="icon" src="<?php echo $img_path ?>b_help.png" width="11" height="11" alt="Doc" title="<?php echo __('Documentation') ?>" /></a><?php } ?> <?php if (!empty($opts['doc'])) { ?><a href="<?php echo $base_dir . $opts['doc'] ?>" target="documentation"><img class="icon" src="<?php echo $img_path ?>b_help.png" width="11" height="11" alt="Doc" title="<?php echo __('Documentation') ?>" /></a><?php } ?>
<?php if (!empty($opts['wiki'])){ ?><a href="<?php echo $opts['wiki'] ?>" target="wiki"><img class="icon" src="<?php echo $img_path ?>b_info.png" width="11" height="11" alt="Wiki" title="Wiki" /></a><?php } ?> <?php if (!empty($opts['wiki'])){ ?><a href="<?php echo $opts['wiki'] ?>" target="wiki"><img class="icon" src="<?php echo $img_path ?>b_info.png" width="11" height="11" alt="Wiki" title="Wiki" /></a><?php } ?>
</span> </span>
<?php endif; ?> <?php } ?>
<?php if (!$is_setup_script && isset($opts['userprefs_allow']) && !$opts['userprefs_allow']): ?> <?php if (!$is_setup_script && isset($opts['userprefs_allow']) && !$opts['userprefs_allow']) { ?>
<span class="disabled-notice" title="<?php echo __('This setting is disabled, it will not be applied to your configuration') ?>"><?php echo __('Disabled') ?></span> <span class="disabled-notice" title="<?php echo __('This setting is disabled, it will not be applied to your configuration') ?>"><?php echo __('Disabled') ?></span>
<?php endif; ?> <?php } ?>
<?php if (!empty($description)) { ?><small><?php echo $description ?></small><?php } ?> <?php if (!empty($description)) { ?><small><?php echo $description ?></small><?php } ?>
</th> </th>
<td> <td>

View File

@@ -66,12 +66,15 @@ function PMA_lang($lang_key)
*/ */
function PMA_lang_name($canonical_path, $type = 'name', $default = 'key') function PMA_lang_name($canonical_path, $type = 'name', $default = 'key')
{ {
if ($type == 'name' && strpos($canonical_path, 'disable/') === 0) {
return __('Disable') . ': ' . lcfirst(PMA_lang_name(substr($canonical_path, 8), $type, $default));
}
$lang_key = str_replace( $lang_key = str_replace(
array('Servers/1/', '/'), array('Servers/1/', 'disable/', '/'),
array('Servers/', '_'), array('Servers/', '', '_'),
$canonical_path) . '_' . $type; $canonical_path) . '_' . $type;
return isset($GLOBALS["strConfig$lang_key"]) return isset($GLOBALS["strConfig$lang_key"])
? $GLOBALS["strConfig$lang_key"] ? ($type == 'desc' ? PMA_lang($lang_key) : $GLOBALS["strConfig$lang_key"])
: ($default == 'key' ? $lang_key : $default); : ($default == 'key' ? $lang_key : $default);
} }

View File

@@ -318,6 +318,7 @@ $strConfigProtectBinary_desc = __('Disallow BLOB and BINARY columns from editing
$strConfigProtectBinary_name = __('Protect binary columns'); $strConfigProtectBinary_name = __('Protect binary columns');
$strConfigQueryHistoryDB_desc = __('Enable if you want DB-based query history (requires pmadb). If disabled, this utilizes JS-routines to display query history (lost by window close).'); $strConfigQueryHistoryDB_desc = __('Enable if you want DB-based query history (requires pmadb). If disabled, this utilizes JS-routines to display query history (lost by window close).');
$strConfigQueryHistoryDB_name = __('Permanent query history'); $strConfigQueryHistoryDB_name = __('Permanent query history');
$strConfigQueryHistoryMax_cmt = __('Users cannot set a higher value');
$strConfigQueryHistoryMax_desc = __('How many queries are kept in history'); $strConfigQueryHistoryMax_desc = __('How many queries are kept in history');
$strConfigQueryHistoryMax_name = __('Query history length'); $strConfigQueryHistoryMax_name = __('Query history length');
$strConfigQueryWindowDefTab_desc = __('Tab displayed when opening a new query window'); $strConfigQueryWindowDefTab_desc = __('Tab displayed when opening a new query window');

View File

@@ -155,12 +155,13 @@ $forms['Left_frame']['Left_tables'] = array(
'ShowTooltipAliasTB'); 'ShowTooltipAliasTB');
$forms['Main_frame']['Startup'] = array( $forms['Main_frame']['Startup'] = array(
'MainPageIconic', 'MainPageIconic',
'ShowCreateDb' => ':group',
'SuggestDBName',
':group:end',
'ShowStats', 'ShowStats',
'ShowPhpInfo',
'ShowServerInfo', 'ShowServerInfo',
'ShowChgPassword', 'ShowPhpInfo',
'ShowCreateDb', 'ShowChgPassword');
'SuggestDBName');
$forms['Main_frame']['Browse'] = array( $forms['Main_frame']['Browse'] = array(
'NavigationBarIconic', 'NavigationBarIconic',
'ShowAll', 'ShowAll',

View File

@@ -20,7 +20,10 @@ $forms['Features']['General'] = array(
'ReplaceHelpImg', 'ReplaceHelpImg',
'SkipLockedTables', 'SkipLockedTables',
'MaxDbList', 'MaxDbList',
'MaxTableList'); 'MaxTableList',
'disable/AllowUserDropDatabase',
'disable/UseDbSearch',
'disable/QueryHistoryDB');
$forms['Features']['Text_fields'] = array( $forms['Features']['Text_fields'] = array(
'CharEditing', 'CharEditing',
'CharTextareaCols', 'CharTextareaCols',
@@ -31,6 +34,7 @@ $forms['Features']['Text_fields'] = array(
$forms['Sql_queries']['Sql_queries'] = array( $forms['Sql_queries']['Sql_queries'] = array(
'ShowSQL', 'ShowSQL',
'Confirm', 'Confirm',
'QueryHistoryMax',
'IgnoreMultiSubmitErrors', 'IgnoreMultiSubmitErrors',
'VerboseMultiSubmit', 'VerboseMultiSubmit',
'MaxCharactersInDisplayedSQL', 'MaxCharactersInDisplayedSQL',
@@ -44,10 +48,10 @@ $forms['Sql_queries']['Sql_box'] = array(
'SQLQuery/ShowAsPHP', 'SQLQuery/ShowAsPHP',
'SQLQuery/Validate', 'SQLQuery/Validate',
'SQLQuery/Refresh'); 'SQLQuery/Refresh');
$forms['Sql_queries']['Sql_validator'] = array('SQLValidator' => array( $forms['Sql_queries']['Sql_validator'] = array(
'use', 'SQLValidator/use',
'username', 'SQLValidator/username',
'password')); 'SQLValidator/password');
$forms['Features']['Page_titles'] = array( $forms['Features']['Page_titles'] = array(
'TitleDefault', 'TitleDefault',
'TitleTable', 'TitleTable',
@@ -76,7 +80,13 @@ $forms['Left_frame']['Left_tables'] = array(
'ShowTooltipAliasTB'); 'ShowTooltipAliasTB');
$forms['Main_frame']['Startup'] = array( $forms['Main_frame']['Startup'] = array(
'MainPageIconic', 'MainPageIconic',
'SuggestDBName'); 'ShowCreateDb' => ':group',
'SuggestDBName',
':group:end',
'ShowStats',
'ShowServerInfo',
'disable/ShowPhpInfo',
'disable/ShowChgPassword');
$forms['Main_frame']['Browse'] = array( $forms['Main_frame']['Browse'] = array(
'NavigationBarIconic', 'NavigationBarIconic',
'ShowAll', 'ShowAll',

View File

@@ -144,6 +144,22 @@ function PMA_apply_userprefs(array $config_data)
if (!isset($whitelist[$path]) || isset($blacklist[$path])) { if (!isset($whitelist[$path]) || isset($blacklist[$path])) {
continue; continue;
} }
if (strpos($path, 'disable/') === 0) {
// write disable/ value
PMA_array_write($path, $cfg, $value);
// prepare path and value for disabled key
$path = substr($path, 8);
switch (gettype(PMA_array_read($path, $GLOBALS['PMA_Config']->default))) {
case 'string':
$value = '';
break;
case 'double':
case 'integer':
$value = 0;
default:
$value = false;
}
}
PMA_array_write($path, $cfg, $value); PMA_array_write($path, $cfg, $value);
} }
return $cfg; return $cfg;