[ Index ]

PHP Cross Reference of MantisBT

title

Body

[close]

/ -> changelog_page.php (source)

   1  <?php
   2  # MantisBT - A PHP based bugtracking system
   3  
   4  # MantisBT is free software: you can redistribute it and/or modify
   5  # it under the terms of the GNU General Public License as published by
   6  # the Free Software Foundation, either version 2 of the License, or
   7  # (at your option) any later version.
   8  #
   9  # MantisBT is distributed in the hope that it will be useful,
  10  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  # GNU General Public License for more details.
  13  #
  14  # You should have received a copy of the GNU General Public License
  15  # along with MantisBT.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * @package MantisBT
  19   * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
  20   * @copyright Copyright (C) 2002 - 2011  MantisBT Team - mantisbt-dev@lists.sourceforge.net
  21   * @link http://www.mantisbt.org
  22   *
  23   * @uses core.php
  24   * @uses access_api.php
  25   * @uses authentication_api.php
  26   * @uses bug_api.php
  27   * @uses category_api.php
  28   * @uses config_api.php
  29   * @uses constant_inc.php
  30   * @uses database_api.php
  31   * @uses error_api.php
  32   * @uses filter_api.php
  33   * @uses filter_constants_inc.php
  34   * @uses gpc_api.php
  35   * @uses helper_api.php
  36   * @uses html_api.php
  37   * @uses lang_api.php
  38   * @uses print_api.php
  39   * @uses project_api.php
  40   * @uses string_api.php
  41   * @uses user_api.php
  42   * @uses utility_api.php
  43   * @uses version_api.php
  44   */
  45  
  46  /**
  47   * MantisBT Core API's
  48   */
  49  require_once ( 'core.php' );
  50  require_api( 'access_api.php' );
  51  require_api( 'authentication_api.php' );
  52  require_api( 'bug_api.php' );
  53  require_api( 'category_api.php' );
  54  require_api( 'config_api.php' );
  55  require_api( 'constant_inc.php' );
  56  require_api( 'database_api.php' );
  57  require_api( 'error_api.php' );
  58  require_api( 'filter_api.php' );
  59  require_api( 'filter_constants_inc.php' );
  60  require_api( 'gpc_api.php' );
  61  require_api( 'helper_api.php' );
  62  require_api( 'html_api.php' );
  63  require_api( 'lang_api.php' );
  64  require_api( 'print_api.php' );
  65  require_api( 'project_api.php' );
  66  require_api( 'string_api.php' );
  67  require_api( 'user_api.php' );
  68  require_api( 'utility_api.php' );
  69  require_api( 'version_api.php' );
  70  
  71  /**
  72   * Print header for the specified project version.
  73   * @param int $p_version_id a valid version id
  74   * @return null
  75   */
  76  function print_version_header( $p_version_id ) {
  77      $t_project_id   = version_get_field( $p_version_id, 'project_id' );
  78      $t_version_name = version_get_field( $p_version_id, 'version' );
  79      $t_project_name = project_get_field( $t_project_id, 'name' );
  80  
  81      $t_release_title = '<a href="changelog_page.php?project_id=' . $t_project_id . '">' . string_display_line( $t_project_name ) . '</a> - <a href="changelog_page.php?version_id=' . $p_version_id . '">' . string_display_line( $t_version_name ) . '</a>';
  82  
  83      if ( config_get( 'show_changelog_dates' ) ) {
  84          $t_version_released = version_get_field( $p_version_id, 'released' );
  85          $t_release_timestamp = version_get_field( $p_version_id, 'date_order' );
  86  
  87          if ( (bool) $t_version_released ) {
  88              $t_release_date = ' (' . lang_get('released') . ' ' . string_display_line( date( config_get( 'short_date_format' ), $t_release_timestamp ) ) . ')';
  89          } else {
  90              $t_release_date = ' (' . lang_get( 'not_released' ) . ')';
  91          }
  92      } else {
  93          $t_release_date = '';
  94      }
  95  
  96      echo '<br />', $t_release_title, $t_release_date, lang_get( 'word_separator' ), print_bracket_link( 'view_all_set.php?type=1&temporary=y&' . FILTER_PROPERTY_PROJECT_ID . '=' . $t_project_id . '&' . filter_encode_field_and_value( FILTER_PROPERTY_FIXED_IN_VERSION, $t_version_name ), lang_get( 'view_bugs_link' ) ), '<br />';
  97  
  98      $t_release_title_without_hyperlinks = $t_project_name . ' - ' . $t_version_name . $t_release_date;
  99      echo utf8_str_pad( '', utf8_strlen( $t_release_title_without_hyperlinks ), '=' ), '<br />';
 100  }
 101  
 102  /**
 103   * Print header for the specified project
 104   * @param string $p_project_name project name to display
 105   * @return null
 106   */
 107  function print_project_header_changelog ( $p_project_name ) {
 108      echo '<br /><span class="pagetitle">', string_display_line( $p_project_name ), ' - ', lang_get( 'changelog' ), '</span><br />';
 109      echo '<tt>';
 110  }
 111  
 112  $t_user_id = auth_get_current_user_id();
 113  
 114  $f_project = gpc_get_string( 'project', '' );
 115  if ( is_blank( $f_project ) ) {
 116      $f_project_id = gpc_get_int( 'project_id', -1 );
 117  } else {
 118      $f_project_id = project_get_id_by_name( $f_project );
 119  
 120      if ( $f_project_id === 0 ) {
 121          trigger_error( ERROR_PROJECT_NOT_FOUND, ERROR );
 122      }
 123  }
 124  
 125  $f_version = gpc_get_string( 'version', '' );
 126  
 127  if ( is_blank( $f_version ) ) {
 128      $f_version_id = gpc_get_int( 'version_id', -1 );
 129  
 130      # If both version_id and project_id parameters are supplied, then version_id take precedence.
 131      if ( $f_version_id == -1 ) {
 132          if ( $f_project_id == -1 ) {
 133              $t_project_id = helper_get_current_project();
 134          } else {
 135              $t_project_id = $f_project_id;
 136          }
 137      } else {
 138          $t_project_id = version_get_field( $f_version_id, 'project_id' );
 139      }
 140  } else {
 141      if ( $f_project_id == -1 ) {
 142          $t_project_id = helper_get_current_project();
 143      } else {
 144          $t_project_id = $f_project_id;
 145      }
 146  
 147      $f_version_id = version_get_id( $f_version, $t_project_id );
 148  
 149      if ( $f_version_id === false ) {
 150          error_parameters( $f_version );
 151          trigger_error( ERROR_VERSION_NOT_FOUND, ERROR );
 152      }
 153  }
 154  
 155  if ( ALL_PROJECTS == $t_project_id ) {
 156      $t_topprojects = $t_project_ids = user_get_accessible_projects( $t_user_id );
 157      foreach ( $t_topprojects as $t_project ) {
 158          $t_project_ids = array_merge( $t_project_ids, user_get_all_accessible_subprojects( $t_user_id, $t_project ) );
 159      }
 160  
 161      $t_project_ids_to_check = array_unique( $t_project_ids );
 162      $t_project_ids = array();
 163  
 164      foreach ( $t_project_ids_to_check as $t_project_id ) {
 165          $t_changelog_view_access_level = config_get( 'view_changelog_threshold', null, null, $t_project_id );
 166          if ( access_has_project_level( $t_changelog_view_access_level, $t_project_id ) ) {
 167              $t_project_ids[] = $t_project_id;
 168          }
 169      }
 170  } else {
 171      access_ensure_project_level( config_get( 'view_changelog_threshold' ), $t_project_id );
 172      $t_project_ids = user_get_all_accessible_subprojects( $t_user_id, $t_project_id );
 173      array_unshift( $t_project_ids, $t_project_id );
 174  }
 175  
 176  html_page_top( lang_get( 'changelog' ) );
 177  
 178  $t_project_index = 0;
 179  
 180  version_cache_array_rows( $t_project_ids );
 181  category_cache_array_rows_by_project( $t_project_ids );
 182  
 183  foreach( $t_project_ids as $t_project_id ) {
 184      $t_project_name = project_get_field( $t_project_id, 'name' );
 185      $t_can_view_private = access_has_project_level( config_get( 'private_bug_threshold' ), $t_project_id );
 186  
 187      $t_limit_reporters = config_get( 'limit_reporters' );
 188      $t_user_access_level_is_reporter = ( REPORTER == access_get_project_level( $t_project_id ) );
 189  
 190      $t_resolved = config_get( 'bug_resolved_status_threshold' );
 191      $t_bug_table    = db_get_table( 'bug' );
 192      $t_relation_table = db_get_table( 'bug_relationship' );
 193  
 194      # grab version info for later use
 195      $t_version_rows = version_get_all_rows( $t_project_id, /* released */ null, /* obsolete */ false );
 196  
 197      # cache category info, but ignore the results for now
 198      category_get_all_rows( $t_project_id );
 199  
 200      $t_project_header_printed = false;
 201  
 202      foreach( $t_version_rows as $t_version_row ) {
 203          $t_issues_planned = 0;
 204          $t_issues_resolved = 0;
 205  
 206          $t_version_header_printed = false;
 207  
 208          $t_version = $t_version_row['version'];
 209  
 210          $t_version_id = $t_version_row['id'];
 211  
 212          # Skip all versions except the specified one (if any).
 213          if ( $f_version_id != -1 && $f_version_id != $t_version_id ) {
 214              continue;
 215          }
 216  
 217          $query = "SELECT sbt.*, dbt.target_version AS parent_version, $t_relation_table.source_bug_id FROM $t_bug_table sbt
 218                  LEFT JOIN $t_relation_table ON sbt.id=$t_relation_table.destination_bug_id AND $t_relation_table.relationship_type=2
 219                  LEFT JOIN $t_bug_table dbt ON dbt.id=$t_relation_table.source_bug_id
 220                  WHERE sbt.project_id=" . db_param() . " AND sbt.fixed_in_version=" . db_param() . " ORDER BY sbt.status ASC, sbt.last_updated DESC";
 221  
 222          $t_description = version_get_field( $t_version_id, 'description' );
 223  
 224          $t_first_entry = true;
 225          $t_issue_ids = array();
 226          $t_issue_parents = array();
 227          $t_issue_handlers = array();
 228  
 229          $t_result = db_query_bound( $query, Array( $t_project_id, $t_version ) );
 230  
 231          while ( $t_row = db_fetch_array( $t_result ) ) {
 232              # hide private bugs if user doesn't have access to view them.
 233              if ( !$t_can_view_private && ( $t_row['view_state'] == VS_PRIVATE ) ) {
 234                  continue;
 235              }
 236  
 237              bug_cache_database_result( $t_row );
 238  
 239              # check limit_Reporter (Issue #4770)
 240              # reporters can view just issues they reported
 241              if ( ON === $t_limit_reporters && $t_user_access_level_is_reporter &&
 242                              !bug_is_user_reporter( $t_row['id'], $t_user_id )) {
 243                  continue;
 244              }
 245  
 246              $t_issue_id = $t_row['id'];
 247              $t_issue_parent = $t_row['source_bug_id'];
 248              $t_parent_version = $t_row['parent_version'];
 249  
 250              if ( !helper_call_custom_function( 'changelog_include_issue', array( $t_issue_id ) ) ) {
 251                  continue;
 252              }
 253  
 254              $t_issues_resolved++;
 255  
 256              if ( 0 === strcasecmp( $t_parent_version, $t_version ) ) {
 257                  $t_issue_ids[] = $t_issue_id;
 258                  $t_issue_parents[] = $t_issue_parent;
 259              } else if ( !in_array( $t_issue_id, $t_issue_ids ) ) {
 260                  $t_issue_ids[] = $t_issue_id;
 261                  $t_issue_parents[] = null;
 262              }
 263  
 264              $t_issue_handlers[] = $t_row['handler_id'];
 265          }
 266  
 267          user_cache_array_rows( array_unique( $t_issue_handlers ) );
 268  
 269          if ( $t_issues_resolved > 0 ) {
 270              if ( !$t_project_header_printed ) {
 271                  print_project_header_changelog( $t_project_name );
 272                  $t_project_header_printed = true;
 273              }
 274  
 275              if ( !$t_version_header_printed ) {
 276                  print_version_header( $t_version_id );
 277                  $t_version_header_printed = true;
 278              }
 279  
 280              if ( !is_blank( $t_description ) ) {
 281                  echo string_display( "<br />$t_description<br /><br />" );
 282              }
 283          }
 284  
 285          $t_issue_set_ids = array();
 286          $t_issue_set_levels = array();
 287          $k = 0;
 288  
 289          $t_cycle = false;
 290          $t_cycle_ids = array();
 291  
 292          while ( !empty( $t_issue_ids ) ) {
 293              $t_issue_id = $t_issue_ids[$k];
 294              $t_issue_parent = $t_issue_parents[$k];
 295  
 296              if ( in_array( $t_issue_id, $t_cycle_ids ) && in_array( $t_issue_parent, $t_cycle_ids ) ) {
 297                  $t_cycle = true;
 298              } else {
 299                  $t_cycle = false;
 300                  $t_cycle_ids[] = $t_issue_id;
 301              }
 302  
 303              if ( $t_cycle || !in_array( $t_issue_parent, $t_issue_ids ) ) {
 304                  $l = array_search( $t_issue_parent, $t_issue_set_ids );
 305                  if ( $l !== false ) {
 306                      for ( $m = $l+1; $m < count( $t_issue_set_ids ) && $t_issue_set_levels[$m] > $t_issue_set_levels[$l]; $m++ ) {
 307                          #do nothing
 308                      }
 309                      $t_issue_set_ids_end = array_splice( $t_issue_set_ids, $m );
 310                      $t_issue_set_levels_end = array_splice( $t_issue_set_levels, $m );
 311                      $t_issue_set_ids[] = $t_issue_id;
 312                      $t_issue_set_levels[] = $t_issue_set_levels[$l] + 1;
 313                      $t_issue_set_ids = array_merge( $t_issue_set_ids, $t_issue_set_ids_end );
 314                      $t_issue_set_levels = array_merge( $t_issue_set_levels, $t_issue_set_levels_end );
 315                  } else {
 316                      $t_issue_set_ids[] = $t_issue_id;
 317                      $t_issue_set_levels[] = 0;
 318                  }
 319                  array_splice( $t_issue_ids, $k, 1 );
 320                  array_splice( $t_issue_parents, $k, 1 );
 321  
 322                  $t_cycle_ids = array();
 323              } else {
 324                  $k++;
 325              }
 326              if ( count( $t_issue_ids ) <= $k ) {
 327                  $k = 0;
 328              }
 329          }
 330  
 331          for ( $j = 0; $j < count( $t_issue_set_ids ); $j++ ) {
 332              $t_issue_set_id = $t_issue_set_ids[$j];
 333              $t_issue_set_level = $t_issue_set_levels[$j];
 334  
 335              helper_call_custom_function( 'changelog_print_issue', array( $t_issue_set_id, $t_issue_set_level ) );
 336          }
 337  
 338          if ( $t_issues_resolved == 1 ) {
 339              echo "[{$t_issues_resolved} " . lang_get( 'bug' ) . ']';
 340              echo "<br />";
 341          } else if ( $t_issues_resolved > 1 ) {
 342              echo "[{$t_issues_resolved} " . lang_get( 'bugs' ) . ']';
 343              echo "<br />";
 344          }
 345  
 346      }
 347      if ( $t_project_header_printed ) {
 348          echo '</tt>';
 349      }
 350  
 351      $t_project_index++;
 352  }
 353  
 354  if ( $t_project_index == 0 ) {
 355      echo '<br /><span class="pagetitle">' . lang_get('changelog_empty') . '</span>';
 356  }
 357  html_page_bottom();


Generated: Thu Jul 28 15:48:31 2011 Cross-referenced by PHPXref 0.7