function custom_field_create($p_name) { if (string_contains_scripting_chars($p_name)) { trigger_error(ERROR_CUSTOM_FIELD_INVALID_DEFINITION, ERROR); } $c_name = db_prepare_string(trim($p_name)); if (is_blank($c_name)) { error_parameters('name'); trigger_error(ERROR_EMPTY_FIELD, ERROR); } custom_field_ensure_name_unique($c_name); $t_custom_field_table = config_get('mantis_custom_field_table'); $query = "INSERT INTO {$t_custom_field_table}\r\n\t\t\t\t\t( name )\r\n\t\t\t\t VALUES\r\n\t\t\t\t\t( '{$c_name}' )"; db_query($query); return db_insert_id($t_custom_field_table); }
/** * create a new custom field with the name $p_name * the definition are the default values and can be changes later * return the ID of the new definition * @param string $p_name Custom field name. * @return integer custom field id * @access public */ function custom_field_create($p_name) { $c_name = trim($p_name); if (is_blank($c_name)) { error_parameters('name'); trigger_error(ERROR_EMPTY_FIELD, ERROR); } custom_field_ensure_name_unique($c_name); $t_query = 'INSERT INTO {custom_field} ( name, possible_values ) VALUES ( ' . db_param() . ',' . db_param() . ')'; db_query($t_query, array($c_name, '')); return db_insert_id(db_get_table('custom_field')); }
/** * create a new custom field with the name $p_name * the definition are the default values and can be changes later * return the ID of the new definition * @param string $p_name custom field name * @return int custom field id * @access public */ function custom_field_create($p_name) { if (string_contains_scripting_chars($p_name)) { trigger_error(ERROR_CUSTOM_FIELD_INVALID_DEFINITION, ERROR); } $c_name = trim($p_name); if (is_blank($c_name)) { error_parameters('name'); trigger_error(ERROR_EMPTY_FIELD, ERROR); } custom_field_ensure_name_unique($c_name); $t_custom_field_table = db_get_table('mantis_custom_field_table'); $query = "INSERT INTO {$t_custom_field_table}\n\t\t\t\t\t( name, possible_values )\n\t\t\t\t VALUES\n\t\t\t\t\t( " . db_param() . ',' . db_param() . ')'; db_query_bound($query, array($c_name, '')); return db_insert_id($t_custom_field_table); }