View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0012475 | mantisbt | bugtracker | public | 2010-10-22 08:18 | 2018-07-23 14:33 |
Reporter | jmonin | Assigned To | |||
Priority | normal | Severity | feature | Reproducibility | always |
Status | new | Resolution | open | ||
Product Version | 1.2.3 | ||||
Summary | 0012475: Ability to add a "relationships" column to lists and exports | ||||
Description | It could be very useful to be able to have a column that relates the relationship of the bug, for example for Excel exports to a customer. | ||||
Tags | No tags attached. | ||||
Attached Files | custom_functions_inc.php (5,322 bytes)
<?php /* * Created on 21 oct. 2010 * * Custom functions */ # Print the value of the custom field (if the field is applicable to the project of # the specified issue and the current user has read access to it. # see custom_function_default_print_column_title() for rules about column names. # $p_column: name of field to show in the column. # $p_row: the row from the bug table that belongs to the issue that we should print the values for. # $p_columns_target: see COLUMNS_TARGET_* in constant_inc.php function custom_function_override_print_column_value( $p_column, $p_bug, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE ) { if( COLUMNS_TARGET_CSV_PAGE == $p_columns_target ) { $t_column_start = ''; $t_column_end = ''; $t_column_empty = ''; } else { $t_column_start = '<td>'; $t_column_end = '</td>'; $t_column_empty = ' '; } // Here goes the specific code for the relationships column if ($p_column == "custom_relationships") { echo $t_column_start; $t_issue_id = $p_bug->id; echo overriden_relationship_get_summary_text( $t_issue_id ); echo $t_column_end; } else { // -------------------------------------------------------- $t_custom_field = column_get_custom_field_name( $p_column ); if( $t_custom_field !== null ) { echo $t_column_start; $t_field_id = custom_field_get_id_from_name( $t_custom_field ); if( $t_field_id === false ) { echo '@', $t_custom_field, '@'; } else { $t_issue_id = $p_bug->id; $t_project_id = $p_bug->project_id; if( custom_field_is_linked( $t_field_id, $t_project_id ) ) { $t_def = custom_field_get_definition( $t_field_id ); print_custom_field_value( $t_def, $t_field_id, $t_issue_id ); } else { // field is not linked to project echo $t_column_empty; } } echo $t_column_end; } else { $t_plugin_columns = columns_get_plugin_columns(); if( $p_columns_target != COLUMNS_TARGET_CSV_PAGE ) { $t_function = 'print_column_' . $p_column; } else { $t_function = 'csv_format_' . $p_column; } if( function_exists( $t_function ) ) { if( $p_columns_target != COLUMNS_TARGET_CSV_PAGE ) { $t_function( $p_bug, $p_columns_target ); } else { $t_function( $p_bug->$p_column ); } } else if ( isset( $t_plugin_columns[ $p_column ] ) ) { $t_column_object = $t_plugin_columns[ $p_column ]; print_column_plugin( $t_column_object, $p_bug, $p_columns_target ); } else { if( isset( $p_bug->$p_column ) ) { echo $t_column_start . string_display_line( $p_bug->$p_column ) . $t_column_end; } else { echo $t_column_start . '@' . $p_column . '@' . $t_column_end; } } } } } // ==================================== PRIVATE FUNCTIONS ========================================= /** * print ALL the RELATIONSHIPS OF A SPECIFIC BUG in text format (used by email_api.php * Overridden to use overriden_relationship_get_details * @param int $p_bug_id Bug id * @return string */ function overriden_relationship_get_summary_text( $p_bug_id ) { $t_summary = ''; $t_show_project = false; $t_relationship_all = relationship_get_all( $p_bug_id, $t_show_project ); $t_relationship_all_count = count( $t_relationship_all ); # prepare the relationships table for( $i = 0;$i < $t_relationship_all_count;$i++ ) { if ($i != 0) { $t_summary .= ", "; } $t_summary .= overriden_relationship_get_details( $p_bug_id, $t_relationship_all[$i] ); } return $t_summary; } // Overriden for relationships in plain text function overriden_relationship_get_details( $p_bug_id, $p_relationship ) { $t_summary_wrap_at = utf8_strlen( config_get( 'email_separator2' ) ) - 28; $t_icon_path = config_get( 'icon_path' ); if( $p_bug_id == $p_relationship->src_bug_id ) { # root bug is in the src side, related bug in the dest side $t_related_bug_id = $p_relationship->dest_bug_id; $t_related_project_name = project_get_name( $p_relationship->dest_project_id ); $t_relationship_descr = relationship_get_description_src_side( $p_relationship->type ); } else { # root bug is in the dest side, related bug in the src side $t_related_bug_id = $p_relationship->src_bug_id; $t_related_project_name = project_get_name( $p_relationship->src_project_id ); $t_relationship_descr = relationship_get_description_dest_side( $p_relationship->type ); } # related bug not existing... if( !bug_exists( $t_related_bug_id ) ) { return ''; } # user can access to the related bug at least as a viewer if( !access_has_bug_level( VIEWER, $t_related_bug_id ) ) { return ''; } # get the information from the related bug and prepare the link $t_bug = bug_get( $t_related_bug_id, false ); $t_status = string_attribute( get_enum_element( 'status', $t_bug->status ) ); $t_resolution = string_attribute( get_enum_element( 'resolution', $t_bug->resolution ) ); $t_relationship_info_text = utf8_str_pad( $t_relationship_descr, 10 ); $t_relationship_info_text .= " ".utf8_str_pad( bug_format_id( $t_related_bug_id ), 8 ); # If a customer id exists $t_id_customer = custom_field_get_value( custom_field_get_id_from_name( 'id_customer' ), $t_related_bug_id ); if ( $t_id_customer != "" ) { $t_relationship_info_text .= " (".$t_id_customer.")"; } return $t_relationship_info_text; } ?> | ||||
For your interest, I managed to implement that specific feature, using custom_functions_inc.php and implementing custom_function_override_print_column_value. |
|
I'd be interested to see your solution jmonin if you don't mind sharing it? Thanks. |
|
I asked for this feature too on the forum and was directed here :-/ |
|
OK, I realize I misread your post! |
|
we'd like to see this feature as well. Would be good to display linked related issue IDs as a column. |
|