예제 #1
0
    error_parameters('config_option');
    trigger_error(ERROR_EMPTY_FIELD, ERROR);
}
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);
}
# make sure that configuration option specified is a valid one.
$t_not_found_value = '***CONFIG OPTION NOT FOUND***';
if (config_get_global($f_config_option, $t_not_found_value) === $t_not_found_value) {
    error_parameters($f_config_option);
    trigger_error(ERROR_CONFIG_OPT_NOT_FOUND, ERROR);
}
# make sure that configuration option specified can be stored in the database
if (!config_can_set_in_database($f_config_option)) {
    error_parameters($f_config_option);
    trigger_error(ERROR_CONFIG_OPT_CANT_BE_SET_IN_DB, ERROR);
}
if ($f_type === 'default') {
    $t_config_global_value = config_get_global($f_config_option);
    if (is_string($t_config_global_value)) {
        $t_type = 'string';
    } else {
        if (is_int($t_config_global_value)) {
            $t_type = 'integer';
        } else {
            # note that we consider bool and float as complex.  We use ON/OFF for bools which map to numeric.
            $t_type = 'complex';
        }
    }
예제 #2
0
/**
 * delete the configuration entry
 *
 * @param string  $p_option  Configuration option.
 * @param integer $p_user    A user identifier.
 * @param integer $p_project A project identifier.
 * @return void
 */
function config_delete($p_option, $p_user = ALL_USERS, $p_project = ALL_PROJECTS)
{
    # bypass table lookup for certain options
    $t_bypass_lookup = !config_can_set_in_database($p_option);
    if (!$t_bypass_lookup && true === db_is_connected() && db_table_exists(db_get_table('config'))) {
        if (!config_can_delete($p_option)) {
            return;
        }
        $t_query = 'DELETE FROM {config}
				WHERE config_id = ' . db_param() . ' AND
					project_id=' . db_param() . ' AND
					user_id=' . db_param();
        db_query($t_query, array($p_option, $p_project, $p_user));
    }
    config_flush_cache($p_option, $p_user, $p_project);
}
예제 #3
0
function config_delete($p_option, $p_user = ALL_USERS, $p_project = ALL_PROJECTS)
{
    global $g_cache_config, $g_cache_config_access;
    # bypass table lookup for certain options
    $t_bypass_lookup = !config_can_set_in_database($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() && db_table_exists(config_get_global('mantis_config_table'))) {
        if (!config_can_delete($p_option)) {
            return;
        }
        $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();
        $c_option = db_prepare_string($p_option);
        $c_user = db_prepare_int($p_user);
        $c_project = db_prepare_int($p_project);
        $query = "DELETE FROM {$t_config_table}\r\n\t\t\t\tWHERE config_id = '{$c_option}' AND\r\n\t\t\t\t\tproject_id={$c_project} AND\r\n\t\t\t\t\tuser_id={$c_user}";
        $result = @db_query($query);
    }
    config_flush_cache($p_option, $p_user, $p_project);
}
예제 #4
0
function config_delete( $p_option, $p_user = ALL_USERS, $p_project = ALL_PROJECTS ) {
	global $g_cache_config, $g_cache_config_access;

	# bypass table lookup for certain options
	$t_bypass_lookup = !config_can_set_in_database( $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() ) && ( db_table_exists( db_get_table( 'config' ) ) ) ) {
		if( !config_can_delete( $p_option ) ) {
			return;
		}

		$t_config_table = db_get_table( 'config' );

		# @@ debug @@ echo "lu table=" . ( db_table_exists( $t_config_table ) ? "yes" : "no" );
		# @@ debug @@ error_print_stack_trace();

		$c_user = db_prepare_int( $p_user );
		$c_project = db_prepare_int( $p_project );
		$query = "DELETE FROM $t_config_table
				WHERE config_id = " . db_param() . " AND
					project_id=" . db_param() . " AND
					user_id=" . db_param();

		$result = @db_query_bound( $query, Array( $p_option, $c_project, $c_user ) );
	}

	config_flush_cache( $p_option, $p_user, $p_project );
}
예제 #5
0
/**
 * delete the config entry
 *
 * @param string $p_option config option
 * @param int $p_user user id
 * @param int $p_project project id
 */
function config_delete($p_option, $p_user = ALL_USERS, $p_project = ALL_PROJECTS)
{
    global $g_cache_config, $g_cache_config_access;
    # bypass table lookup for certain options
    $t_bypass_lookup = !config_can_set_in_database($p_option);
    if (!$t_bypass_lookup && TRUE === db_is_connected() && db_table_exists(db_get_table('config'))) {
        if (!config_can_delete($p_option)) {
            return;
        }
        $t_config_table = db_get_table('config');
        $query = "DELETE FROM {$t_config_table}\n\t\t\t\tWHERE config_id = " . db_param() . " AND\n\t\t\t\t\tproject_id=" . db_param() . " AND\n\t\t\t\t\tuser_id=" . db_param();
        $result = db_query_bound($query, array($p_option, $p_project, $p_user));
    }
    config_flush_cache($p_option, $p_user, $p_project);
}