[ Index ]

PHP Cross Reference of MantisBT

title

Body

[close]

/ -> bug_change_status_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 - 2010  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 config_api.php
  28   * @uses constant_inc.php
  29   * @uses custom_field_api.php
  30   * @uses date_api.php
  31   * @uses event_api.php
  32   * @uses form_api.php
  33   * @uses gpc_api.php
  34   * @uses helper_api.php
  35   * @uses html_api.php
  36   * @uses lang_api.php
  37   * @uses print_api.php
  38   * @uses relationship_api.php
  39   * @uses sponsorship_api.php
  40   * @uses version_api.php
  41   */
  42  
  43  require_once ( 'core.php' );
  44  require_api( 'access_api.php' );
  45  require_api( 'authentication_api.php' );
  46  require_api( 'bug_api.php' );
  47  require_api( 'config_api.php' );
  48  require_api( 'constant_inc.php' );
  49  require_api( 'custom_field_api.php' );
  50  require_api( 'date_api.php' );
  51  require_api( 'event_api.php' );
  52  require_api( 'form_api.php' );
  53  require_api( 'gpc_api.php' );
  54  require_api( 'helper_api.php' );
  55  require_api( 'html_api.php' );
  56  require_api( 'lang_api.php' );
  57  require_api( 'print_api.php' );
  58  require_api( 'relationship_api.php' );
  59  require_api( 'sponsorship_api.php' );
  60  require_api( 'version_api.php' );
  61  
  62  $g_allow_browser_cache = 1;
  63  
  64  $f_bug_id = gpc_get_int( 'id' );
  65  $t_bug = bug_get( $f_bug_id );
  66  
  67  $tpl_file = __FILE__;
  68  $tpl_mantis_dir = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
  69  $tpl_show_page_header = false;
  70  $tpl_force_readonly = true;
  71  $tpl_fields_config_option = 'bug_change_status_page_fields';
  72  
  73  if( $t_bug->project_id != helper_get_current_project() ) {
  74      # in case the current project is not the same project of the bug we are viewing...
  75      # ... override the current project. This to avoid problems with categories and handlers lists etc.
  76      $g_project_override = $t_bug->project_id;
  77  }
  78  
  79  $f_new_status = gpc_get_int( 'new_status' );
  80  $f_reopen_flag = gpc_get_int( 'reopen_flag', OFF );
  81  
  82  $t_current_user_id = auth_get_current_user_id();
  83  
  84  if ( !( ( access_has_bug_level( access_get_status_threshold( $f_new_status, bug_get_field( $f_bug_id, 'project_id' ) ), $f_bug_id ) ) ||
  85              ( ( bug_get_field( $f_bug_id, 'reporter_id' ) == $t_current_user_id ) &&
  86                      ( ( ON == config_get( 'allow_reporter_reopen' ) ) ||
  87                              ( ON == config_get( 'allow_reporter_close' ) ) ) ) ||
  88              ( ( ON == $f_reopen_flag ) && ( access_has_bug_level( config_get( 'reopen_bug_threshold' ), $f_bug_id ) ) )
  89          ) ) {
  90      access_denied();
  91  }
  92  $t_can_update_due_date = access_has_bug_level( config_get( 'due_date_update_threshold' ), $f_bug_id );
  93  # get new issue handler if set, otherwise default to original handler
  94  $f_handler_id = gpc_get_int( 'handler_id', bug_get_field( $f_bug_id, 'handler_id' ) );
  95  
  96  if ( config_get( 'bug_assigned_status' ) == $f_new_status ) {
  97      $t_bug_sponsored = sponsorship_get_amount( sponsorship_get_all_ids( $f_bug_id ) ) > 0;
  98      if ( $t_bug_sponsored ) {
  99          if ( !access_has_bug_level( config_get( 'assign_sponsored_bugs_threshold' ), $f_bug_id ) ) {
 100              trigger_error( ERROR_SPONSORSHIP_ASSIGNER_ACCESS_LEVEL_TOO_LOW, ERROR );
 101          }
 102      }
 103  
 104      if ( $f_handler_id != NO_USER ) {
 105          if ( !access_has_bug_level( config_get( 'handle_bug_threshold' ), $f_bug_id, $f_handler_id ) ) {
 106              trigger_error( ERROR_HANDLER_ACCESS_TOO_LOW, ERROR );
 107          }
 108  
 109          if ( $t_bug_sponsored ) {
 110              if ( !access_has_bug_level( config_get( 'handle_sponsored_bugs_threshold' ), $f_bug_id, $f_handler_id ) ) {
 111                  trigger_error( ERROR_SPONSORSHIP_HANDLER_ACCESS_LEVEL_TOO_LOW, ERROR );
 112              }
 113          }
 114      }
 115  }
 116  
 117  $t_status_label = str_replace( " ", "_", MantisEnum::getLabel( config_get( 'status_enum_string' ), $f_new_status ) );
 118  $t_resolved = config_get( 'bug_resolved_status_threshold' );
 119  $t_closed = config_get( 'bug_closed_status_threshold' );
 120  
 121  $t_bug = bug_get( $f_bug_id );
 122  
 123  html_page_top( bug_format_summary( $f_bug_id, SUMMARY_CAPTION ) );
 124  
 125  print_recently_visited();
 126  ?>
 127  
 128  <br />
 129  <div align="center">
 130  <form method="post" action="bug_update.php">
 131  <?php echo form_security_field( 'bug_update' ) ?>
 132  <table class="width75" cellspacing="1">
 133  
 134  <!-- Title -->
 135  <tr>
 136      <td class="form-title" colspan="2">
 137          <input type="hidden" name="bug_id" value="<?php echo $f_bug_id ?>" />
 138          <input type="hidden" name="status" value="<?php echo $f_new_status ?>" />
 139          <?php echo lang_get( $t_status_label . '_bug_title' ) ?>
 140      </td>
 141  </tr>
 142  
 143  <?php
 144      if ( $f_new_status >= $t_resolved ) {
 145          if ( relationship_can_resolve_bug( $f_bug_id ) == false ) {
 146              echo "<tr><td colspan=\"2\">" . lang_get( 'relationship_warning_blocking_bugs_not_resolved_2' ) . "</td></tr>";
 147          }
 148      }
 149  ?>
 150  
 151  <?php
 152  $t_current_resolution = $t_bug->resolution;
 153  $t_bug_is_open = $t_current_resolution < $t_resolved;
 154  if ( ( $f_new_status >= $t_resolved ) && ( ( $f_new_status < $t_closed ) || ( $t_bug_is_open ) ) ) { ?>
 155  <!-- Resolution -->
 156  <tr <?php echo helper_alternate_class() ?>>
 157      <td class="category">
 158          <?php echo lang_get( 'resolution' ) ?>
 159      </td>
 160      <td>
 161          <select name="resolution">
 162              <?php
 163                  $t_resolution = $t_bug_is_open ? config_get( 'bug_resolution_fixed_threshold' ) : $t_current_resolution;
 164  
 165                  $t_relationships = relationship_get_all_src( $f_bug_id );
 166                  foreach( $t_relationships as $t_relationship ) {
 167                      if ( $t_relationship->type == BUG_DUPLICATE ) {
 168                          $t_resolution = config_get( 'bug_duplicate_resolution' );
 169                          break;
 170                      }
 171                  }
 172  
 173                  print_enum_string_option_list( 'resolution', $t_resolution );
 174              ?>
 175          </select>
 176      </td>
 177  </tr>
 178  <?php } ?>
 179  
 180  <?php
 181  if ( $f_new_status >= $t_resolved
 182      && $f_new_status < $t_closed
 183      && $t_resolution != config_get( 'bug_duplicate_resolution' ) ) { ?>
 184  <!-- Duplicate ID -->
 185  <tr <?php echo helper_alternate_class() ?>>
 186      <td class="category">
 187          <?php echo lang_get( 'duplicate_id' ) ?>
 188      </td>
 189      <td>
 190          <input type="text" name="duplicate_id" maxlength="10" />
 191      </td>
 192  </tr>
 193  <?php } ?>
 194  
 195  <?php
 196  if ( access_has_bug_level( config_get( 'update_bug_assign_threshold', config_get( 'update_bug_threshold' ) ), $f_bug_id ) ) {
 197      $t_suggested_handler_id = $t_bug->handler_id;
 198  
 199      if ( $t_suggested_handler_id == NO_USER && access_has_bug_level( config_get( 'handle_bug_threshold' ), $f_bug_id ) ) {
 200          $t_suggested_handler_id = $t_current_user_id;
 201      }
 202  ?>
 203  <!-- Assigned To -->
 204  <tr <?php echo helper_alternate_class() ?>>
 205      <td class="category">
 206          <?php echo lang_get( 'assigned_to' ) ?>
 207      </td>
 208      <td>
 209          <select name="handler_id">
 210              <option value="0"></option>
 211              <?php print_assign_to_option_list( $t_suggested_handler_id, $t_bug->project_id ) ?>
 212          </select>
 213      </td>
 214  </tr>
 215  <?php } ?>
 216  
 217  <!-- Due date -->
 218  <?php if ( $t_can_update_due_date ) {
 219      $t_date_to_display = '';
 220      if ( !date_is_null( $t_bug->due_date ) ) {
 221              $t_date_to_display = date( config_get( 'calendar_date_format' ), $t_bug->due_date );
 222      }
 223  ?>
 224  <tr <?php echo helper_alternate_class() ?>>
 225      <td class="category">
 226          <?php print_documentation_link( 'due_date' ) ?>
 227      </td>
 228      <td>
 229      <?php
 230          print "<input ".helper_get_tab_index()." type=\"text\" id=\"due_date\" name=\"due_date\" size=\"20\" maxlength=\"10\" value=\"".$t_date_to_display."\" />";
 231          date_print_calendar();
 232      ?>
 233      </td>
 234  </tr>
 235  <?php } ?>
 236  
 237  <!-- Custom Fields -->
 238  <?php
 239  /** @todo thraxisp - I undid part of the change for #5068 for #5527
 240   * We really need to say what fields are shown in which statusses. For now,
 241   * this page will show required custom fields in update mode, or
 242   *  display or required fields on resolve or close
 243   */
 244  $t_custom_status_label = "update"; # Don't show custom fields by default
 245  if ( ( $f_new_status == $t_resolved ) &&
 246              ( $f_new_status < $t_closed ) ) {
 247      $t_custom_status_label = "resolved";
 248  }
 249  if ( $t_closed == $f_new_status ) {
 250      $t_custom_status_label = "closed";
 251  }
 252  
 253  $t_related_custom_field_ids = custom_field_get_linked_ids( bug_get_field( $f_bug_id, 'project_id' ) );
 254  
 255  foreach( $t_related_custom_field_ids as $t_id ) {
 256      $t_def = custom_field_get_definition( $t_id );
 257      $t_display = $t_def['display_' . $t_custom_status_label];
 258      $t_require = $t_def['require_' . $t_custom_status_label];
 259  
 260      if ( ( "update" == $t_custom_status_label ) && ( !$t_require ) ) {
 261          continue;
 262      }
 263      if ( in_array( $t_custom_status_label, array( "resolved", "closed" ) ) && !( $t_display || $t_require ) ) {
 264          continue;
 265      }
 266      if ( custom_field_has_write_access( $t_id, $f_bug_id ) ) {
 267  ?>
 268  <tr <?php echo helper_alternate_class() ?>>
 269      <td class="category">
 270          <?php if ( $t_require ) {?><span class="required">*</span><?php } echo lang_get_defaulted( $t_def['name'] ) ?>
 271      </td>
 272      <td>
 273          <?php
 274              print_custom_field_input( $t_def, $f_bug_id );
 275          ?>
 276      </td>
 277  </tr>
 278  <?php
 279      } #  custom_field_has_write_access( $t_id, $f_bug_id ) )
 280      else if ( custom_field_has_read_access( $t_id, $f_bug_id ) ) {
 281  ?>
 282      <tr <?php echo helper_alternate_class() ?>>
 283          <td class="category">
 284              <?php echo lang_get_defaulted( $t_def['name'] ) ?>
 285          </td>
 286          <td>
 287              <?php print_custom_field_value( $t_def, $t_id, $f_bug_id );            ?>
 288          </td>
 289      </tr>
 290  <?php
 291      } # custom_field_has_read_access( $t_id, $f_bug_id ) )
 292  } # foreach( $t_related_custom_field_ids as $t_id )
 293  ?>
 294  
 295  <?php
 296  if ( ( $t_resolved <= $f_new_status ) ) {
 297      $t_show_product_version = ( ON == config_get( 'show_product_version' ) )
 298          || ( ( AUTO == config_get( 'show_product_version' ) )
 299                      && ( count( version_get_all_rows( $t_bug->project_id ) ) > 0 ) );
 300      if ( $t_show_product_version ) {
 301  ?>
 302  <!-- Fixed in Version -->
 303  <tr <?php echo helper_alternate_class() ?>>
 304      <td class="category">
 305          <?php echo lang_get( 'fixed_in_version' ) ?>
 306      </td>
 307      <td>
 308          <select name="fixed_in_version">
 309              <?php print_version_option_list( bug_get_field( $f_bug_id, 'fixed_in_version' ),
 310                              bug_get_field( $f_bug_id, 'project_id' ), VERSION_ALL ) ?>
 311          </select>
 312      </td>
 313  </tr>
 314  <?php }
 315      } ?>
 316  
 317  <?php
 318  if ( ( $t_resolved <= $f_new_status ) && ( $f_new_status < $t_closed ) ) { ?>
 319  <!-- Close Immediately (if enabled) -->
 320  <?php if ( ( ON == config_get( 'allow_close_immediately' ) )
 321                  && ( access_has_bug_level( access_get_status_threshold( $t_closed, bug_get_field( $f_bug_id, 'project_id' ) ), $f_bug_id ) ) ) { ?>
 322  <tr <?php echo helper_alternate_class() ?>>
 323      <td class="category">
 324          <?php echo lang_get( 'close_immediately' ) ?>
 325      </td>
 326      <td>
 327          <input type="checkbox" name="close_now" />
 328      </td>
 329  </tr>
 330  <?php } ?>
 331  <?php } ?>
 332  
 333  <?php
 334      if ( ON == $f_reopen_flag ) {
 335          # bug was re-opened
 336          printf("    <input type=\"hidden\" name=\"resolution\" value=\"%s\" />\n",  config_get( 'bug_reopen_resolution' ) );
 337      }
 338  ?>
 339  
 340  <!-- Bugnote -->
 341  <tr <?php echo helper_alternate_class() ?>>
 342      <td class="category">
 343          <?php echo lang_get( 'add_bugnote_title' ) ?>
 344      </td>
 345      <td class="center">
 346          <textarea name="bugnote_text" cols="80" rows="10"></textarea>
 347      </td>
 348  </tr>
 349  <?php if ( access_has_bug_level( config_get( 'private_bugnote_threshold' ), $f_bug_id ) ) { ?>
 350  <tr <?php echo helper_alternate_class() ?>>
 351      <td class="category">
 352          <?php echo lang_get( 'view_status' ) ?>
 353      </td>
 354      <td>
 355  <?php
 356          $t_default_bugnote_view_status = config_get( 'default_bugnote_view_status' );
 357          if ( access_has_bug_level( config_get( 'set_view_status_threshold' ), $f_bug_id ) ) {
 358  ?>
 359              <input type="checkbox" name="private" <?php check_checked( $t_default_bugnote_view_status, VS_PRIVATE ); ?> />
 360  <?php
 361              echo lang_get( 'private' );
 362          } else {
 363              echo get_enum_element( 'project_view_state', $t_default_bugnote_view_status );
 364          }
 365  ?>
 366      </td>
 367  </tr>
 368  <?php } ?>
 369  
 370  <?php if ( config_get('time_tracking_enabled') ) { ?>
 371  <?php if ( access_has_bug_level( config_get( 'private_bugnote_threshold' ), $f_bug_id ) ) { ?>
 372  <?php if ( access_has_bug_level( config_get( 'time_tracking_edit_threshold' ), $f_bug_id ) ) { ?>
 373  <tr <?php echo helper_alternate_class() ?>>
 374      <td class="category">
 375          <?php echo lang_get( 'time_tracking' ) ?> (HH:MM)
 376      </td>
 377      <td>
 378          <input type="text" name="time_tracking" size="5" value="0:00" />
 379      </td>
 380  </tr>
 381  <?php } ?>
 382  <?php } ?>
 383  <?php } ?>
 384  
 385  <?php event_signal( 'EVENT_BUGNOTE_ADD_FORM', array( $f_bug_id ) ); ?>
 386  
 387  <!-- Submit Button -->
 388  <tr>
 389      <td class="center" colspan="2">
 390          <input type="submit" class="button" value="<?php echo lang_get( $t_status_label . '_bug_button' ) ?>" />
 391      </td>
 392  </tr>
 393  
 394  
 395  </table>
 396  </form>
 397  </div>
 398  
 399  <?php
 400  if ( $t_can_update_due_date ) {
 401      date_finish_calendar( 'due_date', 'trigger');
 402  }
 403  
 404  echo '<br />';
 405  
 406  define( 'BUG_VIEW_INC_ALLOW', true );
 407  include( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'bug_view_inc.php' );


Generated: Sat Mar 6 17:17:35 2010 Cross-referenced by PHPXref 0.7