Skip to content

Commit

Permalink
Support tags column in View, Print, Csv, Excel
Browse files Browse the repository at this point in the history
Fixes #9096
  • Loading branch information
Luke authored and vboctor committed Mar 25, 2016
1 parent f67ec45 commit 272624e
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 2 deletions.
35 changes: 33 additions & 2 deletions core/columns_api.php
Expand Up @@ -124,6 +124,8 @@ function columns_get_standard( $p_enabled_columns_only = true ) {

$t_columns['selection'] = null;
$t_columns['edit'] = null;
$t_columns['notes'] = null;
$t_columns['tags'] = null;

# Overdue icon column (icons appears if an issue is beyond due_date)
$t_columns['overdue'] = null;
Expand Down Expand Up @@ -159,8 +161,6 @@ function columns_get_standard( $p_enabled_columns_only = true ) {
# legacy field
unset( $t_columns['duplicate_id'] );

$t_columns['notes'] = null;

return array_keys( $t_columns );
}

Expand Down Expand Up @@ -611,6 +611,19 @@ function print_column_title_fixed_in_version( $p_sort, $p_dir, $p_columns_target
echo '</th>';
}

/**
* Print table header for column tags
*
* @param string $p_sort Sort.
* @param string $p_dir Direction.
* @param integer $p_columns_target See COLUMNS_TARGET_* in constant_inc.php.
* @return void
* @access public
*/
function print_column_title_tags( $p_sort, $p_dir, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE ) {
echo '<th class="column-tags">' . lang_get('tags') . '</th>';
}

/**
* Print table header for column target version
*
Expand Down Expand Up @@ -1512,6 +1525,24 @@ function print_column_view_state( BugData $p_bug, $p_columns_target = COLUMNS_TA
echo '</td>';
}

/**
* Print column content for column tags
*
* @param BugData $p_bug BugData object.
* @param integer $p_columns_target See COLUMNS_TARGET_* in constant_inc.php.
* @return void
* @access public
*/
function print_column_tags( BugData $p_bug, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE ) {
echo '<td class="column-view-state">';

if( access_has_bug_level( config_get( 'tag_view_threshold' ), $p_bug->id ) ) {
echo string_display_line( tag_bug_get_all( $p_bug->id ) );
}

echo '</td>';
}

/**
* Print column content for column due date
*
Expand Down
16 changes: 16 additions & 0 deletions core/csv_api.php
Expand Up @@ -237,6 +237,22 @@ function csv_format_target_version( BugData $p_bug ) {
return csv_escape_string( $p_bug->target_version );
}

/**
* return the tags
* @param BugData $p_bug A BugData object.
* @return string formatted tags string
* @access public
*/
function csv_format_tags( BugData $p_bug ) {
$t_value = '';

if( access_has_bug_level( config_get( 'tag_view_threshold' ), $p_bug->id ) ) {
$t_value = tag_bug_get_all( $p_bug->id );
}

return csv_escape_string( $t_value );
}

/**
* return the projection
* @param BugData $p_bug A BugData object.
Expand Down
15 changes: 15 additions & 0 deletions core/excel_api.php
Expand Up @@ -363,6 +363,21 @@ function excel_format_fixed_in_version( BugData $p_bug ) {
return excel_prepare_string( $p_bug->fixed_in_version );
}

/**
* Gets the formatted tags.
* @param BugData $p_bug A bug object.
* @return string the tags.
*/
function excel_format_tags( BugData $p_bug ) {
$t_value = '';

if( access_has_bug_level( config_get( 'tag_view_threshold' ), $p_bug->id ) ) {
$t_value = tag_bug_get_all( $p_bug->id );
}

return excel_prepare_string( $t_value );
}

/**
* Gets the formatted target version.
* @param BugData $p_bug A bug object.
Expand Down
19 changes: 19 additions & 0 deletions core/tag_api.php
Expand Up @@ -791,6 +791,25 @@ function tag_display_attached( $p_bug_id ) {
return true;
}

/**
* Get all attached tags separated by the Tag Separator.
* @param integer $p_bug_id The bug ID to display.
* @return string tags separated by the configured Tag Separator
*/
function tag_bug_get_all( $p_bug_id ) {
$t_tag_rows = tag_bug_get_attached( $p_bug_id );
$t_value = '';

$i = 0;
foreach( $t_tag_rows as $t_tag ) {
$t_value .= ( $i > 0 ? config_get( 'tag_separator' ) . ' ' : '' );
$t_value .= $t_tag['name'];
$i++;
}

return $t_value;
}

/**
* Get the number of bugs a given tag is attached to.
* @param integer $p_tag_id The tag ID to retrieve statistics on.
Expand Down
16 changes: 16 additions & 0 deletions print_all_bug_page_word.php
Expand Up @@ -151,6 +151,12 @@
$t_lang_bug_notes_title = lang_get( 'bug_notes_title' );
$t_lang_system_profile = lang_get( 'system_profile' );
$t_lang_attached_files = lang_get( 'attached_files' );
$t_lang_tags = lang_get( 'tags' );

$t_fields = config_get( 'bug_view_page_fields' );
$t_fields = columns_filter_disabled( $t_fields );

$t_show_tags = in_array( 'tags', $t_fields ) && access_has_global_level( config_get( 'tag_view_threshold' ) );

$t_current_user_id = auth_get_current_user_id();
$t_user_bugnote_order = user_pref_get_pref( $t_current_user_id, 'bugnote_order' );
Expand Down Expand Up @@ -423,6 +429,16 @@
<?php echo string_display_links( $t_bug->description ) ?>
</td>
</tr>
<?php if( $t_show_tags ) { ?>
<tr class="print">
<td class="print-category">
<?php echo sprintf( lang_get( 'label' ), $t_lang_tags ) ?>
</td>
<td class="print" colspan="5">
<?php echo string_display_links( tag_bug_get_all( $t_bug->id ) ) ?>
</td>
</tr>
<?php }?>
<tr class="print">
<td class="print-category">
<?php echo sprintf( lang_get( 'label' ), $t_lang_steps_to_reproduce ) ?>
Expand Down

0 comments on commit 272624e

Please sign in to comment.