Skip to content

Commit

Permalink
Implement columns in csv and excel export
Browse files Browse the repository at this point in the history
In CSV and Excel export, there were columns that are
not implemented, and were silently removed from user
column selection: bugnotes_count, attachment_count

With this commit they are now implemented

Fixes #0019284
  • Loading branch information
cproensa authored and dregad committed Sep 9, 2016
1 parent 6e0801d commit 1279ac3
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 15 deletions.
32 changes: 32 additions & 0 deletions core/csv_api.php
Expand Up @@ -480,3 +480,35 @@ function csv_format_due_date( BugData $p_bug ) {
function csv_format_sponsorship_total( BugData $p_bug ) {
return csv_escape_string( $p_bug->sponsorship_total );
}

/**
* return the attachment count for an issue
* @param BugData $p_bug A BugData object.
* @return string
* @access public
*/
function csv_format_attachment_count( BugData $p_bug ) {
# Check for attachments
$t_attachment_count = 0;
if( file_can_view_bug_attachments( $p_bug->id, null ) ) {
$t_attachment_count = file_bug_attachment_count( $p_bug->id );
}
return csv_escape_string( $t_attachment_count );
}

/**
* return the bug note count for an issue
* @param BugData $p_bug A BugData object.
* @return string
* @access public
*/
function csv_format_bugnotes_count( BugData $p_bug ) {
# grab the bugnote count
$t_bugnote_stats = bug_get_bugnote_stats( $p_bug->id );
if( $t_bugnote_stats ) {
$t_bugnote_count = $t_bugnote_stats['count'];
} else {
$t_bugnote_count = 0;
}
return csv_escape_string( $t_bugnote_count );
}
41 changes: 32 additions & 9 deletions core/excel_api.php
Expand Up @@ -251,15 +251,6 @@ function excel_format_reporter_id( BugData $p_bug ) {
return excel_prepare_string( user_get_name( $p_bug->reporter_id ) );
}

/**
* Gets the formatted number of bug notes.
* @param BugData $p_bug A bug object.
* @return string The number of bug notes.
*/
function excel_format_bugnotes_count( BugData $p_bug ) {
return excel_prepare_number( $p_bug->bugnotes_count );
}

/**
* Gets the formatted handler id.
* @param BugData $p_bug A bug object.
Expand Down Expand Up @@ -576,6 +567,38 @@ function excel_format_sponsorship_total( BugData $p_bug ) {
return excel_prepare_string( $p_bug->sponsorship_total );
}

/**
* Gets the attachment count for an issue
* @param BugData $p_bug A bug object.
* @return string
* @access public
*/
function excel_format_attachment_count( BugData $p_bug ) {
# Check for attachments
$t_attachment_count = 0;
if( file_can_view_bug_attachments( $p_bug->id, null ) ) {
$t_attachment_count = file_bug_attachment_count( $p_bug->id );
}
return excel_prepare_number( $t_attachment_count );
}

/**
* Gets the bug note count for an issue
* @param BugData $p_bug A bug object.
* @return string
* @access public
*/
function excel_format_bugnotes_count( BugData $p_bug ) {
# grab the bugnote count
$t_bugnote_stats = bug_get_bugnote_stats( $p_bug->id );
if( null !== $t_bugnote_stats ) {
$t_bugnote_count = $t_bugnote_stats['count'];
} else {
$t_bugnote_count = 0;
}
return excel_prepare_number( $t_bugnote_count );
}

/**
* The <tt>ExcelStyle</tt> class is able to render style information
*
Expand Down
6 changes: 0 additions & 6 deletions core/helper_api.php
Expand Up @@ -506,15 +506,9 @@ function helper_get_columns_to_view( $p_columns_target = COLUMNS_TARGET_VIEW_PAG
if( $p_columns_target == COLUMNS_TARGET_CSV_PAGE || $p_columns_target == COLUMNS_TARGET_EXCEL_PAGE ) {
$t_keys_to_remove[] = 'selection';
$t_keys_to_remove[] = 'edit';
$t_keys_to_remove[] = 'bugnotes_count';
$t_keys_to_remove[] = 'attachment_count';
$t_keys_to_remove[] = 'overdue';
}

if( $p_columns_target == COLUMNS_TARGET_CSV_PAGE || $p_columns_target == COLUMNS_TARGET_EXCEL_PAGE ) {
$t_keys_to_remove[] = 'attachment_count';
}

$t_current_project_id = helper_get_current_project();

if( $t_current_project_id != ALL_PROJECTS && !access_has_project_level( config_get( 'view_handler_threshold' ), $t_current_project_id ) ) {
Expand Down

0 comments on commit 1279ac3

Please sign in to comment.