diff --git a/admin/schema.php b/admin/schema.php index efd1b1f302..c613974ea8 100644 --- a/admin/schema.php +++ b/admin/schema.php @@ -609,3 +609,5 @@ function installer_db_now() { $upgrade[] = Array( 'CreateIndexSQL', Array( 'idx_email_id', db_get_table( 'email' ), 'email_id', array( 'DROP' ) ), Array( 'db_index_exists', Array( db_get_table( 'email' ), 'idx_email_id') ) ); $upgrade[] = Array( 'UpdateFunction', 'correct_multiselect_custom_fields_db_format' ); $upgrade[] = Array( 'UpdateFunction', "stored_filter_migrate" ); +$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'custom_field_string' ), " + text XL NULL DEFAULT NULL " ) ); diff --git a/config_defaults_inc.php b/config_defaults_inc.php index 2fd16a51c5..cce161ffaf 100644 --- a/config_defaults_inc.php +++ b/config_defaults_inc.php @@ -3041,7 +3041,7 @@ * * @global string $g_custom_field_type_enum_string */ -$g_custom_field_type_enum_string = '0:string,1:numeric,2:float,3:enum,4:email,5:checkbox,6:list,7:multiselection list,8:date,9:radio'; +$g_custom_field_type_enum_string = '0:string,1:numeric,2:float,3:enum,4:email,5:checkbox,6:list,7:multiselection list,8:date,9:radio,10:textarea'; /********************************* * MantisBT Javascript Variables * diff --git a/core/cfdefs/cfdef_standard.php b/core/cfdefs/cfdef_standard.php index 5f278b3cc5..3e181871b6 100644 --- a/core/cfdefs/cfdef_standard.php +++ b/core/cfdefs/cfdef_standard.php @@ -31,6 +31,20 @@ '#function_string_value_for_email' => null, ); +$g_custom_field_type_definition[ CUSTOM_FIELD_TYPE_TEXTAREA] = array ( + '#display_possible_values' => TRUE, + '#display_valid_regexp' => TRUE, + '#display_length_min' => TRUE, + '#display_length_max' => TRUE, + '#display_default_value' => TRUE, + '#function_return_distinct_values' => null, + '#function_value_to_database' => null, + '#function_database_to_value' => null, + '#function_print_input' => 'cfdef_input_textarea', + '#function_string_value' => null, + '#function_string_value_for_email' => null, +); + $g_custom_field_type_definition[ CUSTOM_FIELD_TYPE_NUMERIC ] = array ( '#display_possible_values' => TRUE, '#display_valid_regexp' => TRUE, @@ -300,6 +314,16 @@ function cfdef_input_textbox($p_field_def, $t_custom_field_value) { echo ' value="' . string_attribute( $t_custom_field_value ) .'">'; } +function cfdef_input_textarea($p_field_def, $t_custom_field_value) { + echo ''; +} + /** * Prints the controls for the date selector. * diff --git a/core/constant_inc.php b/core/constant_inc.php index 57e16bfa94..f5cdf08050 100644 --- a/core/constant_inc.php +++ b/core/constant_inc.php @@ -419,6 +419,7 @@ define( 'CUSTOM_FIELD_TYPE_MULTILIST', 7 ); define( 'CUSTOM_FIELD_TYPE_DATE', 8 ); define( 'CUSTOM_FIELD_TYPE_RADIO', 9 ); +define( 'CUSTOM_FIELD_TYPE_TEXTAREA', 10 ); # Meta filter values define( 'META_FILTER_MYSELF', -1 ); diff --git a/core/custom_field_api.php b/core/custom_field_api.php index 4307d12d35..570b677498 100644 --- a/core/custom_field_api.php +++ b/core/custom_field_api.php @@ -62,6 +62,7 @@ # ******************************************* $g_custom_field_types[CUSTOM_FIELD_TYPE_STRING] = 'standard'; +$g_custom_field_types[CUSTOM_FIELD_TYPE_TEXTAREA] = 'standard'; $g_custom_field_types[CUSTOM_FIELD_TYPE_NUMERIC] = 'standard'; $g_custom_field_types[CUSTOM_FIELD_TYPE_FLOAT] = 'standard'; $g_custom_field_types[CUSTOM_FIELD_TYPE_ENUM] = 'standard'; @@ -1008,8 +1009,10 @@ function custom_field_get_value( $p_field_id, $p_bug_id ) { return false; } + $t_value_field = ( $row['type'] == CUSTOM_FIELD_TYPE_TEXTAREA ? 'text' : 'value' ); + $t_custom_field_string_table = db_get_table( 'custom_field_string' ); - $query = "SELECT value + $query = "SELECT $t_value_field FROM $t_custom_field_string_table WHERE bug_id=" . db_param() . " AND field_id=" . db_param(); @@ -1351,8 +1354,10 @@ function custom_field_set_value( $p_field_id, $p_bug_id, $p_value, $p_log_insert $t_type = custom_field_get_field( $p_field_id, 'type' ); $t_custom_field_string_table = db_get_table( 'custom_field_string' ); + $t_value_field = ( $t_type == CUSTOM_FIELD_TYPE_TEXTAREA ) ? 'text' : 'value'; + # Determine whether an existing value needs to be updated or a new value inserted - $query = "SELECT value + $query = "SELECT $t_value_field FROM $t_custom_field_string_table WHERE field_id=" . db_param() . " AND bug_id=" . db_param(); @@ -1360,16 +1365,16 @@ function custom_field_set_value( $p_field_id, $p_bug_id, $p_value, $p_log_insert if( db_num_rows( $result ) > 0 ) { $query = "UPDATE $t_custom_field_string_table - SET value=" . db_param() . " + SET $t_value_field=" . db_param() . " WHERE field_id=" . db_param() . " AND bug_id=" . db_param(); db_query_bound( $query, Array( custom_field_value_to_database( $p_value, $t_type ), $c_field_id, $c_bug_id ) ); $row = db_fetch_array( $result ); - history_log_event_direct( $c_bug_id, $t_name, custom_field_database_to_value( $row['value'], $t_type ), $p_value ); + history_log_event_direct( $c_bug_id, $t_name, custom_field_database_to_value( $row[$t_value_field], $t_type ), $p_value ); } else { $query = "INSERT INTO $t_custom_field_string_table - ( field_id, bug_id, value ) + ( field_id, bug_id, $t_value_field ) VALUES ( " . db_param() . ', ' . db_param() . ', ' . db_param() . ')'; db_query_bound( $query, Array( $c_field_id, $c_bug_id, custom_field_value_to_database( $p_value, $t_type ) ) ); diff --git a/core/filter_api.php b/core/filter_api.php index 857fb957a2..bc581db0ae 100644 --- a/core/filter_api.php +++ b/core/filter_api.php @@ -938,10 +938,11 @@ function filter_get_query_sort_data( &$p_filter, $p_show_sticky, $p_query_clause if( strpos( $c_sort, 'custom_' ) === 0 ) { $t_custom_field = utf8_substr( $c_sort, utf8_strlen( 'custom_' ) ); $t_custom_field_id = custom_field_get_id_from_name( $t_custom_field ); - + $t_def = custom_field_get_definition( $t_custom_field_id ); + $t_value_field = ( $t_def['type'] == CUSTOM_FIELD_TYPE_TEXTAREA ? 'text' : 'value' ); $c_cf_alias = str_replace( ' ', '_', $t_custom_field ); $t_cf_table_alias = $t_custom_field_string_table . '_' . $t_custom_field_id; - $t_cf_select = "$t_cf_table_alias.value $c_cf_alias"; + $t_cf_select = "$t_cf_table_alias.$t_value_field $c_cf_alias"; # check to be sure this field wasn't already added to the query. if( !in_array( $t_cf_select, $p_query_clauses['select'] ) ) { @@ -1924,6 +1925,10 @@ function filter_get_bug_rows( &$p_page_number, &$p_per_page, &$p_page_count, &$p $t_where_params[] = '%|' . $t_filter_member . '|%'; array_push( $t_filter_array, db_helper_like( "$t_table_name.value" ) ); break; + case CUSTOM_FIELD_TYPE_TEXTAREA: + $t_where_params[] = '%' . $t_filter_member . '%'; + array_push( $t_filter_array, db_helper_like( "$t_table_name.text" ) ); + break; default: array_push( $t_filter_array, "$t_table_name.value = '" . db_prepare_string( $t_filter_member ) . "'" ); } @@ -4029,6 +4034,8 @@ function print_filter_custom_field( $p_field_id ) { } else if( isset( $t_accessible_custom_fields_names[$j] ) ) { if( $t_accessible_custom_fields_types[$j] == CUSTOM_FIELD_TYPE_DATE ) { print_filter_custom_field_date( $j, $p_field_id ); + } else if( $t_accessible_custom_fields_types[$j] == CUSTOM_FIELD_TYPE_TEXTAREA ) { + echo ''; } else { echo '