[ Index ]
 

Code source de Mantis 1.1.0rc3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/ -> roadmap_page.php (source)

   1  <?php
   2  # Mantis - a php based bugtracking system
   3  
   4  # Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
   5  # Copyright (C) 2002 - 2007  Mantis Team   - mantisbt-dev@lists.sourceforge.net
   6  
   7  # Mantis is free software: you can redistribute it and/or modify
   8  # it under the terms of the GNU General Public License as published by
   9  # the Free Software Foundation, either version 2 of the License, or
  10  # (at your option) any later version.
  11  #
  12  # Mantis is distributed in the hope that it will be useful,
  13  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15  # GNU General Public License for more details.
  16  #
  17  # You should have received a copy of the GNU General Public License
  18  # along with Mantis.  If not, see <http://www.gnu.org/licenses/>.
  19  
  20      # --------------------------------------------------------
  21      # $Id: roadmap_page.php,v 1.8.2.1 2007-10-13 22:34:29 giallu Exp $
  22      # --------------------------------------------------------
  23  
  24      require_once ( 'core.php' );
  25  
  26      $t_core_path = config_get( 'core_path' );
  27  
  28      require_once( $t_core_path.'bug_api.php' );
  29  
  30      # Print header for the specified project version.
  31  	function print_version_header( $p_version_row ) {
  32          $t_project_id   = $p_version_row['project_id'];
  33          $t_version_name = $p_version_row['version'];
  34          $t_project_name = project_get_field( $t_project_id, 'name' );
  35  
  36          $t_release_title = string_display( $t_project_name ) . ' - ' . string_display( $t_version_name );
  37          echo '<tt>';
  38          echo '<br />', $t_release_title, '<br />';
  39          echo str_pad( '', strlen( $t_release_title ), '=' ), '<br />';
  40      }
  41  
  42      # print project header
  43  	function print_project_header( $p_project_name ) {
  44          echo '<br /><span class="pagetitle">', string_display( $p_project_name ), ' - ', lang_get( 'roadmap' ), '</span><br />';
  45      }
  46      
  47      $t_user_id = auth_get_current_user_id();
  48      $f_project_id = gpc_get_int( 'project_id', helper_get_current_project() );
  49          
  50      if ( ALL_PROJECTS == $f_project_id ) {
  51          $t_topprojects = $t_project_ids = user_get_accessible_projects( $t_user_id );
  52          foreach ( $t_topprojects as $t_project ) {
  53              $t_project_ids = array_merge( $t_project_ids, user_get_all_accessible_subprojects( $t_user_id, $t_project ) );
  54          }
  55  
  56          $t_project_ids_to_check = array_unique( $t_project_ids );
  57          $t_project_ids = array();
  58  
  59          foreach ( $t_project_ids_to_check as $t_project_id ) {
  60              $t_roadmap_view_access_level = config_get( 'roadmap_view_threshold', null, null, $t_project_id );
  61              if ( access_has_project_level( $t_roadmap_view_access_level, $t_project_id ) ) {
  62                  $t_project_ids[] = $t_project_id;
  63              }
  64          }
  65      } else {
  66          access_ensure_project_level( config_get( 'roadmap_view_threshold' ), $f_project_id );
  67          $t_project_ids = user_get_all_accessible_subprojects( $t_user_id, $f_project_id );
  68          array_unshift( $t_project_ids, $f_project_id );
  69      }
  70  
  71      html_page_top1( lang_get( 'roadmap' ) );  // title
  72      html_page_top2();
  73  
  74      $t_project_index = 0;
  75  
  76      foreach( $t_project_ids as $t_project_id ) {
  77          $c_project_id   = db_prepare_int( $t_project_id );
  78          $t_project_name = project_get_field( $t_project_id, 'name' );
  79          $t_can_view_private = access_has_project_level( config_get( 'private_bug_threshold' ), $t_project_id );
  80  
  81          $t_limit_reporters = config_get( 'limit_reporters' );
  82          $t_user_access_level_is_reporter = ( REPORTER == access_get_project_level( $t_project_id ) );
  83  
  84          $t_resolved = config_get( 'bug_resolved_status_threshold' );
  85          $t_bug_table    = config_get( 'mantis_bug_table' );
  86          $t_relation_table = config_get( 'mantis_bug_relationship_table' );
  87          
  88          $t_version_rows = array_reverse( version_get_all_rows( $t_project_id ) );
  89  
  90          $t_project_header_printed = false;
  91          
  92          foreach( $t_version_rows as $t_version_row ) {
  93              if ( $t_version_row['released'] == 1 ) {
  94                  continue;
  95              }
  96              
  97              $t_issues_planned = 0;
  98              $t_issues_resolved = 0;
  99  
 100              $t_version_header_printed = false;
 101  
 102              $t_version = $t_version_row['version'];
 103              $c_version = db_prepare_string( $t_version );
 104  
 105              $query = "SELECT $t_bug_table.*, $t_relation_table.source_bug_id FROM $t_bug_table
 106                          LEFT JOIN $t_relation_table ON $t_bug_table.id=$t_relation_table.destination_bug_id AND $t_relation_table.relationship_type=2
 107                          WHERE project_id='$c_project_id' AND target_version='$c_version' ORDER BY status ASC, last_updated DESC";
 108  
 109              $t_description = $t_version_row['description'];
 110  
 111              $t_first_entry = true;
 112  
 113              $t_result = db_query( $query );
 114  
 115              $t_issue_ids = array();
 116              $t_issue_parents = array();
 117  
 118              while ( $t_row = db_fetch_array( $t_result ) ) {
 119                  # hide private bugs if user doesn't have access to view them.
 120                  if ( !$t_can_view_private && ( $t_row['view_state'] == VS_PRIVATE ) ) {
 121                      continue;
 122                  }
 123  
 124                  bug_cache_database_result( $t_row );
 125  
 126                  # check limit_Reporter (Issue #4770)
 127                  # reporters can view just issues they reported
 128                  if ( ON === $t_limit_reporters && $t_user_access_level_is_reporter &&
 129                       !bug_is_user_reporter( $t_row['id'], $t_user_id )) {
 130                      continue;
 131                  }
 132  
 133                  $t_issue_id = $t_row['id'];
 134                  $t_issue_parent = $t_row['source_bug_id'];
 135  
 136                  if ( !helper_call_custom_function( 'roadmap_include_issue', array( $t_issue_id ) ) ) {
 137                      continue;
 138                  }
 139                  
 140                  $t_issues_planned++;
 141                  
 142                  if ( bug_is_resolved( $t_issue_id ) ) {
 143                      $t_issues_resolved++;
 144                  }
 145  
 146                  $t_issue_ids[] = $t_issue_id;
 147                  $t_issue_parents[] = $t_issue_parent;
 148              }
 149  
 150              $t_progress = $t_issues_planned > 0 ? ( (integer) ( $t_issues_resolved * 100 / $t_issues_planned ) ) : 0;
 151  
 152              if ( $t_issues_planned > 0 ) {
 153                  $t_progress = (integer) ( $t_issues_resolved * 100 / $t_issues_planned );
 154                  
 155                   if ( !$t_project_header_printed ) {
 156                      print_project_header( $t_project_name );
 157                      $t_project_header_printed = true;
 158                  }
 159                  
 160                  if ( !$t_version_header_printed ) {
 161                      print_version_header( $t_version_row );
 162                      $t_version_header_printed = true;
 163                  }
 164  
 165                  if ( !is_blank( $t_description ) ) {
 166                      echo string_display( '<br />' .$t_description . '<br />' );
 167                  }
 168  
 169                  // show progress bar
 170                  echo '<div class="progress400">';
 171                  echo '  <span class="bar" style="width: ' . $t_progress . '%;">' . $t_progress . '%</span>';
 172                  echo '</div>';
 173              } 
 174  
 175              $t_issue_set_ids = array();
 176              $t_issue_set_levels = array();
 177              $k = 0;
 178              
 179              while ( 0 < count( $t_issue_ids ) ) {
 180                  $t_issue_id = $t_issue_ids[$k];
 181                  $t_issue_parent = $t_issue_parents[$k];
 182                  
 183                  if ( !in_array( $t_issue_parent, $t_issue_ids ) ) {
 184                      $l = array_search( $t_issue_parent, $t_issue_set_ids );
 185                      if ( $l !== false ) {
 186                          for ( $m = $l+1; $m < count( $t_issue_set_ids ) && $t_issue_set_levels[$m] > $t_issue_set_levels[$l]; $m++ ) {
 187                              #do nothing
 188                          }
 189                          $t_issue_set_ids_end = array_splice( $t_issue_set_ids, $m );
 190                          $t_issue_set_levels_end = array_splice( $t_issue_set_levels, $m );
 191                          $t_issue_set_ids[] = $t_issue_id;
 192                          $t_issue_set_levels[] = $t_issue_set_levels[$l] + 1;
 193                          $t_issue_set_ids = array_merge( $t_issue_set_ids, $t_issue_set_ids_end );
 194                          $t_issue_set_levels = array_merge( $t_issue_set_levels, $t_issue_set_levels_end );
 195                      }
 196                      else {
 197                          $t_issue_set_ids[] = $t_issue_id;
 198                          $t_issue_set_levels[] = 0;
 199                      }
 200                      array_splice( $t_issue_ids, $k, 1 );
 201                      array_splice( $t_issue_parents, $k, 1 );
 202                  }
 203                  else {
 204                      $k++;
 205                  }
 206                  if ( count( $t_issue_ids ) <= $k ) {
 207                      $k = 0;
 208                  }
 209              }
 210  
 211              for ( $j = 0; $j < count( $t_issue_set_ids ); $j++ ) {
 212                  $t_issue_set_id = $t_issue_set_ids[$j];
 213                  $t_issue_set_level = $t_issue_set_levels[$j];
 214                   
 215                  helper_call_custom_function( 'roadmap_print_issue', array( $t_issue_set_id, $t_issue_set_level ) );
 216              }
 217  
 218              if ( $t_issues_planned > 0 ) {
 219                  echo '<br />';
 220                  echo sprintf( lang_get( 'resolved_progress' ), $t_issues_resolved, $t_issues_planned, $t_progress );
 221                  echo '<br /></tt>';
 222              }
 223          }
 224          
 225          $t_project_index++;
 226      }
 227  
 228      html_page_bottom1( __FILE__ );
 229  ?>


Généré le : Thu Nov 29 09:42:17 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics