View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0007586 | mantisbt | customization | public | 2006-11-10 04:44 | 2014-12-22 08:23 |
Reporter | vreck | Assigned To | dregad | ||
Priority | normal | Severity | feature | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Product Version | 1.1.0a1 | ||||
Target Version | 1.2.13 | Fixed in Version | 1.2.13 | ||
Summary | 0007586: generic configuration editor cannot 'EDIT' an option | ||||
Description | The generic configuration feature is a really nice feature. | ||||
Tags | No tags attached. | ||||
Attached Files | mantisbt_7586_rev1.patch (4,345 bytes)
? adm_config_edit.php Index: adm_config_report.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/adm_config_report.php,v retrieving revision 1.9 diff -u -r1.9 adm_config_report.php --- adm_config_report.php 1 Apr 2007 06:30:24 -0000 1.9 +++ adm_config_report.php 8 Aug 2007 22:30:48 -0000 @@ -126,6 +126,7 @@ <?php if ( config_can_delete( $v_config_id ) ) { print_button( 'adm_config_delete.php?user_id=' . $v_user_id . '&project_id=' . $v_project_id . '&config_option=' . $v_config_id, lang_get( 'delete_link' ) ); + print_button( 'adm_config_edit.php?user_id=' . $v_user_id . '&project_id=' . $v_project_id . '&config_option=' . $v_config_id, lang_get( 'edit_link' ) ); } else { echo ' '; } Index: core/config_api.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/config_api.php,v retrieving revision 1.39 diff -u -r1.39 config_api.php --- core/config_api.php 25 Jul 2007 23:39:44 -0000 1.39 +++ core/config_api.php 8 Aug 2007 22:45:04 -0000 @@ -148,6 +148,95 @@ return $p_default; } } + + # ------------------ + # Retrieves the type of a config value + function config_get_type( $p_option, $p_user = null, $p_project = null ) + { + global $g_cache_config, $g_cache_config_access, $g_cache_db_table_exists, $g_cache_filled; + + # bypass table lookup for certain options + $t_bypass_lookup = !config_can_set_in_database( $p_option ); + + if ( ! $t_bypass_lookup ) { + $t_config_table = config_get_global( 'mantis_config_table' ); + if ( ! $g_cache_db_table_exists ) { + $g_cache_db_table_exists = ( TRUE === db_is_connected() ) && + db_table_exists( $t_config_table ); + } + + if ( $g_cache_db_table_exists ) { + + # prepare the user's list + $t_users = array(); + if ( null === $p_user ) { + $t_users[] = auth_is_user_authenticated() ? auth_get_current_user_id() : ALL_USERS; + } else { + $t_users[] = $p_user; + } + if ( ! in_array( ALL_USERS, $t_users ) ) { + $t_users[] = ALL_USERS; + } + + # prepare the projects list + $t_projects = array(); + if ( ( null === $p_project ) ) { + $t_projects[] = auth_is_user_authenticated() ? helper_get_current_project() : ALL_PROJECTS; + } else { + $t_projects[] = $p_project; + } + if ( ! in_array( ALL_PROJECTS, $t_projects ) ) { + $t_projects[] = ALL_PROJECTS; + } + + if ( ! $g_cache_filled ) { + + $query = "SELECT config_id, user_id, project_id, type, value, access_reqd FROM $t_config_table"; + $result = db_query( $query ); + while ( false <> ( $row = db_fetch_array( $result ) ) ) { + $t_config = $row['config_id']; + $t_user = $row['user_id']; + $t_project = $row['project_id']; + $g_cache_config[$t_config][$t_user][$t_project] = $row['type'] . ';' . $row['value']; + $g_cache_config_access[$t_config][$t_user][$t_project] = $row['access_reqd']; + } + $g_cache_filled = true; + } + + if( isset( $g_cache_config[$p_option] ) ) { + $t_found = false; + reset( $t_users ); + while ( ( list( , $t_user ) = each( $t_users ) ) && ! $t_found ) { + reset( $t_projects ); + while ( ( list( , $t_project ) = each( $t_projects ) ) && ! $t_found ) { + if ( isset( $g_cache_config[$p_option][$t_user][$t_project] ) ) { + $t_value = $g_cache_config[$p_option][$t_user][$t_project]; + $t_found = true; + } + } + } + + if ( $t_found ) { + list( $t_type, $t_raw_value ) = explode( ';', $t_value, 2 ); + + switch ( $t_type ) { + case CONFIG_TYPE_INT: + $t_value = (int) $t_raw_value; + break; + case CONFIG_TYPE_COMPLEX: + $t_value = unserialize( $t_raw_value ); + break; + case CONFIG_TYPE_STRING: + default: + $t_value = config_eval( $t_raw_value ); + } + return $t_type; + } + } + } + } + return CONFIG_TYPE_STRING; + } # ------------------ # Retrieves the access level needed to change a config value adm_config_edit.php (4,933 bytes)
<?php # Mantis - a php based bugtracking system # Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org # Copyright (C) 2002 - 2006 Mantis Team - mantisbt-dev@lists.sourceforge.net # This program is distributed under the terms and conditions of the GPL # See the README and LICENSE files for details # -------------------------------------------------------- # $Id: $ # -------------------------------------------------------- require_once( 'core.php' ); $t_core_path = config_get( 'core_path' ); $f_user_id = gpc_get_int( 'user_id' ); $f_project_id = gpc_get_int( 'project_id' ); $f_config_option = gpc_get_string( 'config_option' ); if ( $f_project_id == ALL_PROJECTS ) { access_ensure_global_level( config_get('set_configuration_threshold' ) ); } else { access_ensure_project_level( config_get('set_configuration_threshold' ), $f_project_id ); } $t_config_value = config_get( $f_config_option, null, $f_user_id, $f_project_id ); $t_config_type = get_config_type( config_get_type( $f_config_option, $f_user_id, $f_project_id ) ); html_page_top1( lang_get( 'configuration_report' ) ); html_page_top2(); function get_config_type( $p_type ) { switch( $p_type ) { case CONFIG_TYPE_INT: return "integer"; case CONFIG_TYPE_COMPLEX: return "complex"; case CONFIG_TYPE_STRING: default: return "string"; } } function print_config_value_as_string( $p_type, $p_value ) { switch( $p_type ) { case CONFIG_TYPE_INT: $t_value = (integer)$p_value; echo $t_value; return; case CONFIG_TYPE_STRING: $t_value = config_eval( $p_value ); echo string_nl2br( string_html_specialchars( "'$t_value'" ) ); return; case CONFIG_TYPE_COMPLEX: $t_value = unserialize( $p_value ); break; default: $t_value = config_eval( $p_value ); break; } echo '<pre>'; if ( function_exists( 'var_export' ) ) { var_export( $t_value ); } else { print_r( $t_value ); } echo '</pre>'; } ?> <div align="center"> <br /> <!-- Config Set Form --> <table class="width100" cellspacing="1"> <!-- Title --> <tr> <td class="form-title" colspan="2"> <?php echo lang_get( 'set_configuration_option' ) ?> </td> </tr> <form method="post" action="adm_config_set.php"> <tr <?php echo helper_alternate_class() ?> valign="top"> <td> <?php echo lang_get( 'username' ) ?> </td> <td> <select name="user_id"> <option value="0" selected="selected"><?php echo lang_get( 'all_users' ); ?></option> <?php print_user_option_list( $f_user_id ) ?> </select> </td> </tr> <tr <?php echo helper_alternate_class() ?> valign="top"> <td> <?php echo lang_get( 'project_name' ) ?> </td> <td> <select name="project_id"> <option value="0" selected="selected"><?php echo lang_get( 'all_projects' ); ?></option> <?php print_project_option_list( $f_project_id, false ) ?>" /> </select> </td> </tr> <tr <?php echo helper_alternate_class() ?> valign="top"> <td> <?php echo lang_get( 'configuration_option' ) ?> </td> <td> <input type="text" name="config_option" value="<?php echo $f_config_option; ?>" size="64" maxlength="64" /> </td> </tr> <tr <?php echo helper_alternate_class() ?> valign="top"> <td> <?php echo lang_get( 'configuration_option_type' ) ?> </td> <td> <select name="type"> <option value="default" <?php check_selected( 'default', $t_config_type); ?>>default</option> <option value="string" <?php check_selected( 'string', $t_config_type); ?>>string</option> <option value="integer" <?php check_selected( 'integer', $t_config_type); ?>>integer</option> <option value="complex" <?php check_selected( 'complex', $t_config_type); ?>>complex</option> </select> </td> </tr> <tr <?php echo helper_alternate_class() ?> valign="top"> <td> <?php echo lang_get( 'configuration_option_value' ) ?> </td> <td> <textarea name="value" cols="80" rows="10"><?php echo $t_config_value; ?></textarea> </td> </tr> <tr> <td colspan="2"> <input type="submit" name="config_set" class="button" value="<?php echo lang_get( 'set_configuration_option' ) ?>" /> </td> </tr> </form> </table> </div> <?php html_page_bottom1( __FILE__ ); ?> adm_config_edit2.php (5,070 bytes)
<?php # Mantis - a php based bugtracking system # Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org # Copyright (C) 2002 - 2006 Mantis Team - mantisbt-dev@lists.sourceforge.net # This program is distributed under the terms and conditions of the GPL # See the README and LICENSE files for details # -------------------------------------------------------- # $Id: $ # -------------------------------------------------------- require_once( 'core.php' ); $t_core_path = config_get( 'core_path' ); $f_user_id = gpc_get_int( 'user_id' ); $f_project_id = gpc_get_int( 'project_id' ); $f_config_option = gpc_get_string( 'config_option' ); if ( $f_project_id == ALL_PROJECTS ) { access_ensure_global_level( config_get('set_configuration_threshold' ) ); } else { access_ensure_project_level( config_get('set_configuration_threshold' ), $f_project_id ); } $t_config_value = config_get( $f_config_option, null, $f_user_id, $f_project_id ); $t_config_type = get_config_type( config_get_type( $f_config_option, $f_user_id, $f_project_id ) ); html_page_top1( lang_get( 'configuration_report' ) ); html_page_top2(); function get_config_type( $p_type ) { switch( $p_type ) { case CONFIG_TYPE_INT: return "integer"; case CONFIG_TYPE_COMPLEX: return "complex"; case CONFIG_TYPE_STRING: default: return "string"; } } function print_config_value_as_string( $p_type, $p_value ) { switch( $p_type ) { case CONFIG_TYPE_INT: $t_value = (integer)$p_value; echo $t_value; return; case CONFIG_TYPE_STRING: $t_value = config_eval( $p_value ); echo string_nl2br( string_html_specialchars( "'$t_value'" ) ); return; case CONFIG_TYPE_COMPLEX: $t_value = unserialize( $p_value ); break; default: $t_value = config_eval( $p_value ); break; } echo '<pre>'; if ( function_exists( 'var_export' ) ) { var_export( $t_value ); } else { print_r( $t_value ); } echo '</pre>'; } ?> <div align="center"> <br /> <!-- Config Set Form --> <table class="width100" cellspacing="1"> <!-- Title --> <tr> <td class="form-title" colspan="2"> <?php echo lang_get( 'set_configuration_option' ) ?> </td> </tr> <form method="post" action="adm_config_set.php"> <tr <?php echo helper_alternate_class() ?> valign="top"> <td> <?php echo lang_get( 'username' ) ?> </td> <td> <input type="hidden" name="user_id" value="<?php echo $f_user_id; ?>" /> <?php if ( $f_user_id == ALL_USERS ) { echo "All Users" ; } else { $t_user = user_cache_row( $f_user_id ); echo $t_user['username'] ; } ?> </td> </tr> <tr <?php echo helper_alternate_class() ?> valign="top"> <td> <?php echo lang_get( 'project_name' ) ?> </td> <td> <input type="hidden" name="project_id" value="<?php echo $f_project_id; ?>" /> <?php if ( $f_project_id == ALL_PROJECTS ) { echo "All Projects" ; } else { $t_project = project_cache_row( $f_project_id ); echo $t_project['name']; } ?> </td> </tr> <tr <?php echo helper_alternate_class() ?> valign="top"> <td> <?php echo lang_get( 'configuration_option' ) ?> </td> <td> <input type="hidden" name="config_option" value="<?php echo $f_config_option; ?>" /> <?php echo $f_config_option; ?> </td> </tr> <tr <?php echo helper_alternate_class() ?> valign="top"> <td> <?php echo lang_get( 'configuration_option_type' ) ?> </td> <td> <select name="type"> <option value="default" <?php check_selected( 'default', $t_config_type); ?>>default</option> <option value="string" <?php check_selected( 'string', $t_config_type); ?>>string</option> <option value="integer" <?php check_selected( 'integer', $t_config_type); ?>>integer</option> <option value="complex" <?php check_selected( 'complex', $t_config_type); ?>>complex</option> </select> </td> </tr> <tr <?php echo helper_alternate_class() ?> valign="top"> <td> <?php echo lang_get( 'configuration_option_value' ) ?> </td> <td> <textarea name="value" cols="80" rows="10"><?php echo $t_config_value; ?></textarea> </td> </tr> <tr> <td colspan="2"> <input type="submit" name="config_set" class="button" value="<?php echo lang_get( 'set_configuration_option' ) ?>" /> </td> </tr> </form> </table> </div> <?php html_page_bottom1( __FILE__ ); ?> | ||||
Patch to implement the Config Edit functionality. Had to create a new function in config_api.php to return the 'type' (config_get_type()). It's pretty messy, but I wasn't able to find another way to do it.
|
|
Use the new adm_config_edit2.php file (but rename it to remove the number 2). The original allowed you to edit project, user, and config name. BUT, obviously you shouldn't be able to edit those fields. So this resolves that.
|
|
From IRC: thraxisp: ok. I'm not sure you need config_get_type. The type is determined by the data content (see config_set). |
|
User kaese proposed an alternative patch to fix this issue in 0013382 |
|
Editing of existing config options stored in db should be fixed in https://github.com/dregad/mantisbt/tree/manage-config, testing and feedback would be appreciated. |
|
Marking as 'acknowledged' not resolved/closed to track that change gets ported to master-2.0.x branch |
|
MantisBT: master-1.2.x 8890b218 2012-12-15 02:17 Details Diff |
Make it possible to edit config options in adm_config_report.php Use CONFIG_TYPE_xxx constants instead of magic strings to define the type of config value to process. Added code for FLOAT type which was previously handled through COMPLEX. Improve handling of INT (and FLOAT) by calling constant_replace(), allowing user to specify a defined constant instead of a numeric value. Fixes 0007586 |
Affected Issues 0007586 |
|
mod - adm_config_report.php | Diff File | ||
mod - adm_config_set.php | Diff File | ||
mod - core/constant_inc.php | Diff File | ||
mod - core/print_api.php | Diff File | ||
MantisBT: master 57f57409 2013-03-08 11:01 Details Diff |
Make it possible to edit config options in adm_config_report.php Use CONFIG_TYPE_xxx constants instead of magic strings to define the type of config value to process. Added code for FLOAT type which was previously handled through COMPLEX. Improve handling of INT (and FLOAT) by calling constant_replace(), allowing user to specify a defined constant instead of a numeric value. The 'Username', 'Project Name' and 'Configuration Option' fields in the 'Set Configuration Option' form are preset to the corresponding value from the filter or defaulting to ALL_USERS, ALL_PROJECTS and blank respectively if the filter is not defined or set to '[any]'. This allows easier definition of related config, e.g. for a given project or user. Port of 1.2.x commits - 8890b218892d56947e6ffe300d0186b1450d0481 - 8b426cfc6c6ea7149beeafb352fa390dbf8c4624 - 5858a659efe12743b4360da11e9320c7f6ac6e82 Fixes 0007586, 0015416 |
Affected Issues 0007586, 0015416 |
|
mod - adm_config_report.php | Diff File | ||
mod - adm_config_set.php | Diff File | ||
mod - core/constant_inc.php | Diff File | ||
mod - core/print_api.php | Diff File |