logo       


mantisbt changelog_page.php, 1.20, 1.21 roadmap_page.php, 1.6, 1.7: msg#00133

Subject: mantisbt changelog_page.php, 1.20, 1.21 roadmap_page.php, 1.6, 1.7
Update of /cvsroot/mantisbt/mantisbt
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv3240

Modified Files:
        changelog_page.php roadmap_page.php 
Log Message:
0008194: Roadmap and Changelog list nesting for parent/child issues 

Index: roadmap_page.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/roadmap_page.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- roadmap_page.php    24 Mar 2007 17:20:51 -0000      1.6
+++ roadmap_page.php    27 Jul 2007 20:04:30 -0000      1.7
@@ -22,21 +22,19 @@
                $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 />';
        }
 
        # print project header
        function print_project_header( $p_project_name ) {
-               echo '<br /><span class="pagetitle">', string_display( 
$p_project_name ), ' - ', lang_get( 'roadmap' ), '</span><br /><br />';
-               echo '<tt>';
+               echo '<br /><span class="pagetitle">', string_display( 
$p_project_name ), ' - ', lang_get( 'roadmap' ), '</span><br />';
        }
        
        $t_user_id = auth_get_current_user_id();
        $f_project_id = gpc_get_int( 'project_id', helper_get_current_project() 
);
-       
-       $t_roadmap_view_access_level = config_get( 'roadmap_view_threshold' );
-
+               
        if ( ALL_PROJECTS == $f_project_id ) {
                $t_topprojects = $t_project_ids = user_get_accessible_projects( 
$t_user_id );
                foreach ( $t_topprojects as $t_project ) {
@@ -47,12 +45,13 @@
                $t_project_ids = array();
 
                foreach ( $t_project_ids_to_check as $t_project_id ) {
+                       $t_roadmap_view_access_level = config_get( 
'roadmap_view_threshold', null, null, $t_project_id );
                        if ( access_has_project_level( 
$t_roadmap_view_access_level, $t_project_id ) ) {
                                $t_project_ids[] = $t_project_id;
                        }
                }
        } else {
-               access_ensure_project_level( $t_roadmap_view_access_level, 
$f_project_id );
+               access_ensure_project_level( config_get( 
'roadmap_view_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 );
        }
@@ -63,10 +62,6 @@
        $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 );
@@ -76,8 +71,9 @@
 
                $t_resolved = config_get( 'bug_resolved_status_threshold' );
                $t_bug_table    = config_get( 'mantis_bug_table' );
-
-               $t_version_rows = version_get_all_rows( $t_project_id );
+               $t_relation_table = config_get( 'mantis_bug_relationship_table' 
);
+               
+               $t_version_rows = array_reverse( version_get_all_rows( 
$t_project_id ) );
 
                $t_project_header_printed = false;
                
@@ -91,11 +87,14 @@
                        $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 );
 
-                       $query = "SELECT * FROM $t_bug_table WHERE 
project_id='$c_project_id' AND target_version='$c_version' ORDER BY status ASC, 
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 = $t_version_row['description'];
 
@@ -104,6 +103,7 @@
                        $t_result = db_query( $query );
 
                        $t_issue_ids = array();
+                       $t_issue_parents = array();
 
                        while ( $t_row = db_fetch_array( $t_result ) ) {
                                # hide private bugs if user doesn't have access 
to view them.
@@ -121,6 +121,7 @@
                                }
 
                                $t_issue_id = $t_row['id'];
+                               $t_issue_parent = $t_row['source_bug_id'];
 
                                if ( !helper_call_custom_function( 
'roadmap_include_issue', array( $t_issue_id ) ) ) {
                                        continue;
@@ -132,69 +133,78 @@
                                        $t_issues_resolved++;
                                }
 
-
                                $t_issue_ids[] = $t_issue_id;
+                               $t_issue_parents[] = $t_issue_parent;
                        }
 
                        $i++;
 
+                       $t_progress = $t_issues_planned > 0 ? ( (integer) ( 
$t_issues_resolved * 100 / $t_issues_planned ) ) : 0;
+
                        if ( $t_issues_planned > 0 ) {
                                $t_progress = (integer) ( $t_issues_resolved * 
100 / $t_issues_planned );
-
-                               print_project_header( $t_project_name );
-                               $t_project_header_printed = true;
-
-                               print_version_header( $t_version_row );
-                               $t_version_header_printed = true;
-
-                               // show progress bar
-                               echo '<div class="progress400">';
-                               echo '  <span class="bar" style="width: ' . 
$t_progress . '%;">' . $t_progress . '%</span>';
-                               echo '</div>';
-                       } else {
-                               $t_project_header_printed = false;
-                               $t_version_header_printed = false;
-                       }
-
-                       if ( !is_blank( $t_description ) ) {
-                               echo string_display( "<br />$t_description<br 
/><br />" );
-
-                               #if ( $i > 0 ) {
-                               #       echo '<br />';
-                               #}
                                
-                               if ( !$t_project_header_printed ) {
+                               if ( !$t_project_header_printed ) {
                                        print_project_header( $t_project_name );
                                        $t_project_header_printed = true;
                                }
-
+                               
                                if ( !$t_version_header_printed ) {
                                        print_version_header( $t_version_row );
                                        $t_version_header_printed = true;
                                }
-                       }
 
-                       foreach ( $t_issue_ids as $t_issue_id ) {
-                               # Print the header for the version with the 
first roadmap entry to be added.
-                               if ( $t_first_entry && 
!$t_version_header_printed ) {
-                                       if ( $i > 0 ) {
-                                               echo '<br />';
-                                       }
+                               if ( !is_blank( $t_description ) ) {
+                                       echo string_display( '<br />' 
.$t_description . '<br />' );
+                               }
 
-                                       if ( !$t_project_header_printed ) {
-                                               print_project_header( 
$t_project_name );
-                                               $t_project_header_printed = 
true;
-                                       }
+                               // show progress bar
+                               echo '<div class="progress400">';
+                               echo '  <span class="bar" style="width: ' . 
$t_progress . '%;">' . $t_progress . '%</span>';
+                               echo '</div>';
+                       } 
 
-                                       if ( !$t_version_header_printed ) {
-                                               print_version_header( 
$t_version_row );
-                                               $t_version_header_printed = 
true;
+                       $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 );
                                        }
-
-                                       $t_first_entry = false;
+                                       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;
                                }
+                       }
 
-                               helper_call_custom_function( 
'roadmap_print_issue', array( $t_issue_id ) );
+                       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( 
'roadmap_print_issue', array( $t_issue_set_id, $t_issue_set_level ) );
                        }
 
                        if ( $t_issues_planned > 0 ) {

Index: changelog_page.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/changelog_page.php,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- changelog_page.php  7 May 2007 23:03:13 -0000       1.20
+++ changelog_page.php  27 Jul 2007 20:04:30 -0000      1.21
@@ -22,18 +22,13 @@
                $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();
@@ -45,28 +40,27 @@
                        $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 );
@@ -76,42 +70,37 @@
 
                $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 );
 
@@ -131,38 +120,85 @@
                                }
 
                                $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;
+                               if ( !is_blank( $t_description ) ) {
+                                       echo string_display( "<br 
/>$t_description<br />" );
                                }
+                       } 
 
-                               helper_call_custom_function( 
'changelog_print_issue', array( $t_issue_id ) );
+                       $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 ) {


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/


Ruby Jobs
Java Jobs
Jobs in California
more...
what
job title, keywords
where
city, state, zip
jobs by job search
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
encryption.gpg....    ietf.rfc822/199...    freebsd.devel.i...    lang.haskell.li...    mail.squirrelma...    web.zope.plone....    yellowdog.gener...    text.xml.xalan....    recreation.phot...    kde.devel.educa...    hardware.bus.ca...    printing.ghosts...    voip.peering/20...    assembly/2006-0...    org.user-groups...    culture.interne...    network.i2p/200...    boot-loaders.ya...    xfree86.render/...    qnx.openqnx.dev...    jakarta.velocit...    user-groups.pal...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe