From: Jeroen L. <jl...@us...> - 2005-02-27 15:33:11
|
Update of /cvsroot/mantisbt/mantisbt/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25028/core Modified Files: config_api.php constant_inc.php custom_field_api.php helper_api.php Log Message: Enh #5286: Copy user permissions from one project to another Index: constant_inc.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/constant_inc.php,v retrieving revision 1.42 retrieving revision 1.43 diff -u -d -r1.42 -r1.43 --- constant_inc.php 26 Feb 2005 15:16:46 -0000 1.42 +++ constant_inc.php 27 Feb 2005 15:33:01 -0000 1.43 @@ -313,12 +313,12 @@ define( 'TOKEN_UNKNOWN', 0 ); define( 'TOKEN_FILTER', 1 ); define( 'TOKEN_GRAPH', 2 ); - + # config types define( 'CONFIG_TYPE_INT', 1 ); define( 'CONFIG_TYPE_STRING', 2 ); define( 'CONFIG_TYPE_COMPLEX', 3 ); - + # Control types for date custom fields. define( 'CUSTOM_FIELD_DATE_ANY', 0 ) ; define( 'CUSTOM_FIELD_DATE_NONE', 1 ) ; Index: config_api.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/config_api.php,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- config_api.php 27 Feb 2005 14:45:00 -0000 1.17 +++ config_api.php 27 Feb 2005 15:33:01 -0000 1.18 @@ -8,7 +8,7 @@ # -------------------------------------------------------- # $Id$ # -------------------------------------------------------- - + # cache for config variables $g_cache_config = array(); $g_cache_config_access = array(); @@ -24,26 +24,26 @@ # if not found, config_id + current user + all_project # if not found, config_id + default user + current project # if not found, config_id + default user + all_project. - # 3.use GLOBAL[config_id] + # 3.use GLOBAL[config_id] function config_get( $p_option, $p_default = null, $p_user = null, $p_project = null ) { global $g_cache_config, $g_cache_config_access; - + if ( isset( $g_cache_config[$p_option] ) ) { return $g_cache_config[$p_option]; } - + # bypass table lookup for certain options $t_match_pattern = '/' . implode( '|', config_get_global( 'global_settings' ) ) . '/'; $t_bypass_lookup = ( 0 < preg_match( $t_match_pattern, $p_option ) ); # @@ debug @@ if ($t_bypass_lookup) { echo "bp=$p_option match=$t_match_pattern <br />"; } # @@ debug @@ if ( ! db_is_connected() ) { echo "no db"; } - if ( ( ! $t_bypass_lookup ) && ( TRUE === db_is_connected() ) + if ( ( ! $t_bypass_lookup ) && ( TRUE === db_is_connected() ) && ( db_table_exists( config_get_global( 'mantis_config_table' ) ) ) ) { $t_config_table = config_get_global( 'mantis_config_table' ); # @@ debug @@ echo "lu table=" . ( db_table_exists( $t_config_table ) ? "yes" : "no" ); # @@ debug @@ error_print_stack_trace(); - + # prepare the user's list $t_users = array( ALL_USERS ); if ( ( null == $p_user ) && ( auth_is_user_authenticated() ) ) { @@ -56,7 +56,7 @@ } else { $t_user_clause = "user_id=$t_users[0]"; } - + # prepare the projects list $t_projects = array( ALL_PROJECTS ); if ( ( null == $p_project ) && ( auth_is_user_authenticated() ) ) { @@ -72,13 +72,13 @@ } else { $t_project_clause = "project_id=$t_projects[0]"; } - + $c_option = db_prepare_string( $p_option ); - # @@@ (thraxisp) if performance is a problem, we could fetch all of the configs at - # once here. we need to reverse the sort, so that the last value overwrites the + # @@@ (thraxisp) if performance is a problem, we could fetch all of the configs at + # once here. we need to reverse the sort, so that the last value overwrites the # config table $query = "SELECT type, value, access FROM $t_config_table - WHERE config_id = '$p_option' AND + WHERE config_id = '$p_option' AND $t_project_clause AND $t_user_clause ORDER BY user_id DESC, project_id DESC"; @@ -89,7 +89,7 @@ $row = db_fetch_array( $result ); $t_type = $row['type']; $t_raw_value = $row['value']; - + switch ( $t_type ) { case CONFIG_TYPE_INT: $t_value = (int) $t_raw_value; @@ -113,7 +113,7 @@ # force config variable from a global to avoid recursion function config_get_global( $p_option, $p_default = null ) { global $g_cache_config, $g_cache_config_access; - + if ( isset( $GLOBALS['g_' . $p_option] ) ) { $t_value = config_eval( $GLOBALS['g_' . $p_option] ); $g_cache_config[$p_option] = $t_value; @@ -134,11 +134,11 @@ # Retrieves the access level needed to change a config value function config_get_access( $p_option ) { global $g_cache_config, $g_cache_config_access; - + if ( ! isset( $g_cache_config[$p_option] ) ) { $t_value = config_get( $p_option ); } - + return $g_cache_config_access[$p_option]; } @@ -151,7 +151,7 @@ return true; } else { $t_config_table = config_get_global( 'mantis_config_table' ); - + # prepare the user's list $t_users = array( ALL_USERS ); if ( ( null == $p_user ) && ( auth_is_user_authenticated() ) ) { @@ -164,7 +164,7 @@ } else { $t_user_clause = "user_id=$t_users[0]"; } - + # prepare the projects list $t_projects = array( ALL_PROJECTS ); if ( ( null == $p_project ) && ( auth_is_user_authenticated() ) ) { @@ -180,13 +180,13 @@ } else { $t_project_clause = "project_id=$t_projects[0]"; } - + $c_option = db_prepare_string( $p_option ); - # @@@ (thraxisp) if performance is a problem, we could fetch all of the configs at - # once here. we need to reverse the sort, so that the last value overwrites the + # @@@ (thraxisp) if performance is a problem, we could fetch all of the configs at + # once here. we need to reverse the sort, so that the last value overwrites the # config table $query = "SELECT COUNT(*) FROM $t_config_table - WHERE config_id = '$p_option' AND + WHERE config_id = '$p_option' AND $t_project_clause AND $t_user_clause"; @@ -195,7 +195,7 @@ if ( 0 < db_result( $result ) ) { return true; } - + return false; } } @@ -218,28 +218,28 @@ $c_user = db_prepare_int( $p_user ); $c_project = db_prepare_int( $p_project ); $c_access = db_prepare_int( $p_access ); - + $t_config_table = config_get_global( 'mantis_config_table' ); $query = "SELECT * from $t_config_table - WHERE config_id = '$c_option' AND + WHERE config_id = '$c_option' AND project_id = $c_project AND user_id = $c_user"; $result = db_query( $query ); if ( 0 < db_num_rows( $result ) ) { - $t_set_query = "UPDATE $t_config_table + $t_set_query = "UPDATE $t_config_table SET value='$c_value', type=$t_type, access=$c_access - WHERE config_id = '$c_option' AND + WHERE config_id = '$c_option' AND project_id = $c_project AND user_id = $c_user"; } else { - $t_set_query = "INSERT INTO $t_config_table + $t_set_query = "INSERT INTO $t_config_table SET value='$c_value', type=$t_type, access=$c_access, config_id = '$c_option', project_id = $c_project, user_id = $c_user"; } - + $result = db_query( $t_set_query ); return true; @@ -266,7 +266,7 @@ PRINT '</p>'; } } - + # ------------------ # check for recursion in defining config variables # If there is a %text% in the returned value, re-evaluate the "text" part and replace @@ -277,7 +277,7 @@ if ( 0 < preg_match_all( '/%(.*)%/', $t_value, $t_matches ) ) { for ($i=0; $i< count($t_matches[0]); $i++) { # $t_matches[0][$i] is the matched string including the delimiters - # $t_matches[1][$i] is the target parameter string + # $t_matches[1][$i] is the target parameter string $t_repl = config_get( $t_matches[1][$i] ); $t_value = str_replace( $t_matches[0][$i], $t_repl, $t_value ); } Index: helper_api.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/helper_api.php,v retrieving revision 1.55 retrieving revision 1.56 diff -u -d -r1.55 -r1.56 --- helper_api.php 26 Feb 2005 15:16:46 -0000 1.55 +++ helper_api.php 27 Feb 2005 15:33:01 -0000 1.56 @@ -171,7 +171,7 @@ !access_has_project_level( VIEWER, $t_project_id ) ) { $t_project_id = ALL_PROJECTS; } - + return (int)$t_project_id; } Index: custom_field_api.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/custom_field_api.php,v retrieving revision 1.48 retrieving revision 1.49 diff -u -d -r1.48 -r1.49 --- custom_field_api.php 26 Feb 2005 01:00:39 -0000 1.48 +++ custom_field_api.php 27 Feb 2005 15:33:01 -0000 1.49 @@ -138,7 +138,7 @@ return $t_field[ 'type' ] ; } } - + # -------------------- # Check to see whether the field id is defined # return true if the field is defined, error otherwise |