Skip to content

Commit

Permalink
0008194: Roadmap and Changelog list nesting for parent/child issues
Browse files Browse the repository at this point in the history
git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@4497 f5dc347c-c33d-0410-90a0-b07cc1902cb9
  • Loading branch information
mantis committed Jul 27, 2007
1 parent 6e37528 commit 1d2dc20
Show file tree
Hide file tree
Showing 3 changed files with 168 additions and 122 deletions.
154 changes: 95 additions & 59 deletions changelog_page.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: changelog_page.php,v 1.20 2007-05-07 23:03:13 prichards Exp $
# $Id: changelog_page.php,v 1.21 2007-07-27 20:04:30 prichards Exp $
# --------------------------------------------------------

require_once( 'core.php' );
Expand All @@ -22,18 +22,13 @@ function print_version_header( $p_version_id ) {
$t_project_name = project_get_field( $t_project_id, 'name' );

$t_release_title = string_display( $t_project_name ) . ' - ' . string_display( $t_version_name );
echo $t_release_title, '<br />';
echo '<tt>';
echo '<br />', $t_release_title, '<br />';
echo str_pad( '', strlen( $t_release_title ), '=' ), '<br />';

$t_description = version_get_field( $p_version_id, 'description' );
if ( ( $t_description !== false ) && !is_blank( $t_description ) ) {
echo string_display( "<br />$t_description<br /><br />" );
}
}

function print_project_header ( $p_project_name ) {
echo '<br /><span class="pagetitle">', string_display( $p_project_name ), ' - ', lang_get( 'changelog' ), '</span><br /><br />';
echo '<tt>';
echo '<br /><span class="pagetitle">', string_display( $p_project_name ), ' - ', lang_get( 'changelog' ), '</span><br />';
}

$t_user_id = auth_get_current_user_id();
Expand All @@ -45,28 +40,27 @@ function print_project_header ( $p_project_name ) {
$t_project_ids = array_merge( $t_project_ids, user_get_all_accessible_subprojects( $t_user_id, $t_project ) );
}

$t_project_ids = array_unique( $t_project_ids );
$t_project_ids_to_check = array_unique( $t_project_ids );
$t_project_ids = array();

foreach ( $t_project_ids_to_check as $t_project_id ) {
$t_changelog_view_access_level = config_get( 'view_changelog_threshold', null, null, $t_project_id );
if ( access_has_project_level( $t_changelog_view_access_level, $t_project_id ) ) {
$t_project_ids[] = $t_project_id;
}
}
} else {
access_ensure_project_level( config_get( 'view_changelog_threshold' ), $f_project_id );
$t_project_ids = user_get_all_accessible_subprojects( $t_user_id, $f_project_id );
array_unshift( $t_project_ids, $f_project_id );
}

# this page is invalid for the 'All Project' selection
#if ( ALL_PROJECTS == $f_project_id ) {
# print_header_redirect( 'login_select_proj_page.php?ref=changelog_page.php' );
#}

html_page_top1( lang_get( 'changelog' ) ); // title
html_page_top2();

$t_project_index = 0;

foreach( $t_project_ids as $t_project_id ) {
if ( $t_project_index > 0 ) {
echo '<br />';
}

$c_project_id = db_prepare_int( $t_project_id );
$t_project_name = project_get_field( $t_project_id, 'name' );
$t_can_view_private = access_has_project_level( config_get( 'private_bug_threshold' ), $t_project_id );
Expand All @@ -76,42 +70,37 @@ function print_project_header ( $p_project_name ) {

$t_resolved = config_get( 'bug_resolved_status_threshold' );
$t_bug_table = config_get( 'mantis_bug_table' );
$t_relation_table = config_get( 'mantis_bug_relationship_table' );

$t_version_rows = version_get_all_rows( $t_project_id );

# skip projects with no versions
if (sizeof($t_version_rows) == 0) {
continue;
}


$t_project_header_printed = false;
$i = 0;

foreach( $t_version_rows as $t_version_row ) {
if ( $t_version_row['released'] == 1 ) {
continue;
}

$t_issues_planned = 0;
$t_issues_resolved = 0;

$t_version_header_printed = false;

$t_version = $t_version_row['version'];
$c_version = db_prepare_string( $t_version );

$t_version_id = version_get_id( $t_version, $t_project_id );

$query = "SELECT * FROM $t_bug_table WHERE project_id='$c_project_id' AND fixed_in_version='$c_version' ORDER BY last_updated DESC";
$query = "SELECT $t_bug_table.*, $t_relation_table.source_bug_id FROM $t_bug_table
LEFT JOIN $t_relation_table ON $t_bug_table.id=$t_relation_table.destination_bug_id AND $t_relation_table.relationship_type=2
WHERE project_id='$c_project_id' AND target_version='$c_version' ORDER BY status ASC, last_updated DESC";

$t_description = version_get_field( $t_version_id, 'description' );
if ( !is_blank( $t_description ) ) {
if ( !$t_project_header_printed ) {
print_project_header ($t_project_name);
}
$t_project_header_printed = true;

if ( $i > 0 ) {
echo '<br />';
}

print_version_header( $t_version_id );
$t_version_header_printed = true;
} else {
$t_version_header_printed = false;
}

$t_first_entry = true;
$t_issue_ids = array();
$t_issue_parents = array();

$t_result = db_query( $query );

Expand All @@ -131,38 +120,85 @@ function print_project_header ( $p_project_name ) {
}

$t_issue_id = $t_row['id'];
$t_issue_parent = $t_row['source_bug_id'];

if ( !helper_call_custom_function( 'changelog_include_issue', array( $t_issue_id ) ) ) {
continue;
}

$t_issues_resolved++;

$t_issue_ids[] = $t_issue_id;
$t_issue_parents[] = $t_issue_parent;

# Print the header for the version with the first changelog entry to be added.
if ( $t_first_entry && !$t_version_header_printed ) {
$i++;

if ( $t_issues_resolved > 0 ) {
if ( !$t_project_header_printed ) {
print_project_header ($t_project_name);
print_project_header( $t_project_name );
$t_project_header_printed = true;
}
$t_project_header_printed = true;

if ( $i > 0 ) {
echo '<br />';

if ( !$t_version_header_printed ) {
print_version_header( $t_version_id );
$t_version_header_printed = true;
}

print_version_header( $t_version_id );

$t_version_header_printed = true;
$t_first_entry = false;
}

helper_call_custom_function( 'changelog_print_issue', array( $t_issue_id ) );
if ( !is_blank( $t_description ) ) {
echo string_display( "<br />$t_description<br />" );
}
}

$t_issue_set_ids = array();
$t_issue_set_levels = array();
$k = 0;

while ( 0 < count( $t_issue_ids ) ) {
$t_issue_id = $t_issue_ids[$k];
$t_issue_parent = $t_issue_parents[$k];

if ( !in_array( $t_issue_parent, $t_issue_ids ) ) {
$l = array_search( $t_issue_parent, $t_issue_set_ids );
if ( $l !== false ) {
for ( $m = $l+1; $m < count( $t_issue_set_ids ) && $t_issue_set_levels[$m] > $t_issue_set_levels[$l]; $m++ ) {
#do nothing
}
$t_issue_set_ids_end = array_splice( $t_issue_set_ids, $m );
$t_issue_set_levels_end = array_splice( $t_issue_set_levels, $m );
$t_issue_set_ids[] = $t_issue_id;
$t_issue_set_levels[] = $t_issue_set_levels[$l] + 1;
$t_issue_set_ids = array_merge( $t_issue_set_ids, $t_issue_set_ids_end );
$t_issue_set_levels = array_merge( $t_issue_set_levels, $t_issue_set_levels_end );
}
else {
$t_issue_set_ids[] = $t_issue_id;
$t_issue_set_levels[] = 0;
}
array_splice( $t_issue_ids, $k, 1 );
array_splice( $t_issue_parents, $k, 1 );
}
else {
$k++;
}
if ( count( $t_issue_ids ) <= $k ) {
$k = 0;
}
}

for ( $j = 0; $j < count( $t_issue_set_ids ); $j++ ) {
$t_issue_set_id = $t_issue_set_ids[$j];
$t_issue_set_level = $t_issue_set_levels[$j];

helper_call_custom_function( 'changelog_print_issue', array( $t_issue_set_id, $t_issue_set_level ) );
}

$i++;
}

if ( $t_project_header_printed ) {
echo '</tt>';
$t_project_index++;
}
}


$t_project_index++;
}

if ( $t_project_index == 0 ) {
Expand Down
12 changes: 6 additions & 6 deletions core/custom_function_api.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: custom_function_api.php,v 1.31 2007-04-04 06:45:22 vboctor Exp $
# $Id: custom_function_api.php,v 1.32 2007-07-27 20:04:31 prichards Exp $
# --------------------------------------------------------

$t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
Expand All @@ -29,17 +29,17 @@ function custom_function_default_changelog_include_issue( $p_issue_id ) {

# --------------------
# Prints one entry in the changelog.
function custom_function_default_changelog_print_issue( $p_issue_id ) {
function custom_function_default_changelog_print_issue( $p_issue_id, $p_issue_level = 0 ) {
$t_bug = bug_get( $p_issue_id );

$t_category = is_blank( $t_bug->category ) ? '' : '<b>[' . $t_bug->category . ']</b> ';
echo '- ', string_get_bug_view_link( $p_issue_id ), ': ', $t_category, string_display_line_links( $t_bug->summary );
echo str_pad( '', $p_issue_level * 6, '&nbsp;' ), '- ', string_get_bug_view_link( $p_issue_id ), ': ', $t_category, string_display_line_links( $t_bug->summary );

if ( $t_bug->handler_id != 0 ) {
echo ' (', prepare_user_name( $t_bug->handler_id ), ')';
}

echo '<br />';
echo ' - ', get_enum_element( 'status', $t_bug->status ), '.<br />';
}

# --------------------
Expand All @@ -53,7 +53,7 @@ function custom_function_default_roadmap_include_issue( $p_issue_id ) {

# --------------------
# Prints one entry in the roadmap.
function custom_function_default_roadmap_print_issue( $p_issue_id ) {
function custom_function_default_roadmap_print_issue( $p_issue_id, $p_issue_level = 0 ) {
$t_bug = bug_get( $p_issue_id );

if ( bug_is_resolved( $p_issue_id ) ) {
Expand All @@ -64,7 +64,7 @@ function custom_function_default_roadmap_print_issue( $p_issue_id ) {
}

$t_category = is_blank( $t_bug->category ) ? '' : '<b>[' . $t_bug->category . ']</b> ';
echo '- ', $t_strike_start, string_get_bug_view_link( $p_issue_id ), ': ', $t_category, string_display_line_links( $t_bug->summary );
echo str_pad( '', $p_issue_level * 6, '&nbsp;' ), '- ', $t_strike_start, string_get_bug_view_link( $p_issue_id ), ': ', $t_category, string_display_line_links( $t_bug->summary );

if ( $t_bug->handler_id != 0 ) {
echo ' (', prepare_user_name( $t_bug->handler_id ), ')';
Expand Down

0 comments on commit 1d2dc20

Please sign in to comment.