[ Index ]

PHP Cross Reference of MantisBT

title

Body

[close]

/ -> manage_config_workflow_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 authentication_api.php
  25   * @uses config_api.php
  26   * @uses constant_inc.php
  27   * @uses current_user_api.php
  28   * @uses form_api.php
  29   * @uses helper_api.php
  30   * @uses html_api.php
  31   * @uses lang_api.php
  32   * @uses print_api.php
  33   * @uses project_api.php
  34   * @uses string_api.php
  35   * @uses workflow_api.php
  36   */
  37  
  38  /**
  39   * MantisBT Core API's
  40   */
  41  require_once ( 'core.php' );
  42  require_api( 'authentication_api.php' );
  43  require_api( 'config_api.php' );
  44  require_api( 'constant_inc.php' );
  45  require_api( 'current_user_api.php' );
  46  require_api( 'form_api.php' );
  47  require_api( 'helper_api.php' );
  48  require_api( 'html_api.php' );
  49  require_api( 'lang_api.php' );
  50  require_api( 'print_api.php' );
  51  require_api( 'project_api.php' );
  52  require_api( 'string_api.php' );
  53  require_api( 'workflow_api.php' );
  54  
  55  auth_reauthenticate();
  56  
  57  html_page_top( lang_get( 'manage_workflow_config' ) );
  58  
  59  print_manage_menu( 'adm_permissions_report.php' );
  60  print_manage_config_menu( 'manage_config_workflow_page.php' );
  61  
  62  $t_access = current_user_get_access_level();
  63  $t_project = helper_get_current_project();
  64  $t_can_change_workflow = $t_access >= config_get_access( 'status_enum_workflow' );
  65  $t_can_change_flags = $t_can_change_workflow;
  66  $t_overrides = array();
  67  
  68  function set_overrides( $p_config ) {
  69     global $t_overrides;
  70     if ( !in_array( $p_config, $t_overrides ) ) {
  71         $t_overrides[] = $p_config;
  72     }
  73  }
  74  
  75  # Get the value associated with the specific action and flag.
  76  function show_flag( $p_from_status_id, $p_to_status_id ) {
  77      global $t_can_change_workflow, $t_overrides, $t_file_workflow, $t_global_workflow, $t_project_workflow, $t_colour_global, $t_colour_project;
  78      if ( $p_from_status_id <> $p_to_status_id ) {
  79          $t_file = isset( $t_file_workflow['exit'][$p_from_status_id][$p_to_status_id] ) ? 1 : 0 ;
  80          $t_global = isset( $t_global_workflow['exit'][$p_from_status_id][$p_to_status_id] ) ? 1 : 0 ;
  81          $t_project = isset( $t_project_workflow['exit'][$p_from_status_id][$p_to_status_id] ) ? 1 : 0;
  82  
  83          $t_colour = '';
  84          if ( $t_global != $t_file ) {
  85              $t_colour = ' bgcolor="' . $t_colour_global . '" '; # all projects override
  86              if ( $t_can_change_workflow ) {
  87                  set_overrides( 'status_enum_workflow' );
  88              }
  89          }
  90          if ( $t_project != $t_global ) {
  91              $t_colour = ' bgcolor="' . $t_colour_project . '" '; # project overrides
  92              if ( $t_can_change_workflow ) {
  93                  set_overrides( 'status_enum_workflow' );
  94              }
  95          }
  96          $t_value = '<td class="center"' . $t_colour . '>';
  97  
  98          $t_flag = ( 1 == $t_project );
  99          $t_label = $t_flag ? $t_project_workflow['exit'][$p_from_status_id][$p_to_status_id] : '';
 100  
 101          if ( $t_can_change_workflow ) {
 102              $t_flag_name = $p_from_status_id . ':' . $p_to_status_id;
 103              $t_set = $t_flag ? "checked=\"checked\"" : "";
 104              $t_value .= "<input type=\"checkbox\" name=\"flag[]\" value=\"$t_flag_name\" $t_set />";
 105          } else {
 106              $t_value .= $t_flag ? '<img src="images/ok.gif" width="20" height="15" title="X" alt="X" />' : '&#160;';
 107          }
 108  
 109          if ( $t_flag && ( '' != $t_label ) ) {
 110              $t_value .= '<br />(' . $t_label . ')';
 111          }
 112      } else {
 113          $t_value = '<td>&#160;';
 114      }
 115  
 116      $t_value .= '</td>';
 117  
 118      return $t_value;
 119  }
 120  
 121  function section_begin( $p_section_name ) {
 122      $t_enum_statuses = MantisEnum::getValues( config_get( 'status_enum_string' ) );
 123      echo '<table class="width100">';
 124      echo '<tr><td class="form-title-caps" colspan="' . ( count( $t_enum_statuses ) + 2 ) . '">'
 125          . $p_section_name . '</td></tr>' . "\n";
 126      echo '<tr><td class="form-title" width="30%" rowspan="2">' . lang_get( 'current_status' ) . '</td>';
 127      echo '<td class="form-title" style="text-align:center" colspan="' . ( count( $t_enum_statuses ) + 1 ) . '">'
 128          . lang_get( 'next_status' ) . '</td></tr>';
 129      echo "\n<tr>";
 130  
 131      foreach( $t_enum_statuses as $t_status ) {
 132          echo '<td class="form-title" style="text-align:center">&#160;' . string_no_break( MantisEnum::getLabel( lang_get( 'status_enum_string' ), $t_status ) ) . '&#160;</td>';
 133      }
 134  
 135      echo '<td class="form-title" style="text-align:center">' . lang_get( 'custom_field_default_value' ) . '</td>';
 136      echo '</tr>' . "\n";
 137  }
 138  
 139  function capability_row( $p_from_status ) {
 140      global $t_file_workflow, $t_global_workflow, $t_project_workflow, $t_colour_global, $t_colour_project, $t_can_change_workflow;
 141      $t_enum_status = MantisEnum::getAssocArrayIndexedByValues( config_get( 'status_enum_string' ) );
 142      echo '<tr ' . helper_alternate_class() . '><td>' . string_no_break( MantisEnum::getLabel( lang_get( 'status_enum_string' ), $p_from_status ) ) . '</td>';
 143      foreach ( $t_enum_status as $t_to_status_id => $t_to_status_label ) {
 144          echo show_flag( $p_from_status, $t_to_status_id );
 145      }
 146  
 147      $t_file = isset( $t_file_workflow['default'][$p_from_status] ) ? $t_file_workflow['default'][$p_from_status] : 0 ;
 148      $t_global = isset( $t_global_workflow['default'][$p_from_status] ) ? $t_global_workflow['default'][$p_from_status] : 0 ;
 149      $t_project = isset( $t_project_workflow['default'][$p_from_status] ) ? $t_project_workflow['default'][$p_from_status] : 0;
 150  
 151      $t_colour = '';
 152      if ( $t_global != $t_file ) {
 153          $t_colour = ' bgcolor="' . $t_colour_global . '" '; # all projects override
 154          if ( $t_can_change_workflow ) {
 155              set_overrides( 'status_enum_workflow' );
 156          }
 157      }
 158      if ( $t_project != $t_global ) {
 159          $t_colour = ' bgcolor="' . $t_colour_project . '" '; # project overrides
 160          if ( $t_can_change_workflow ) {
 161              set_overrides( 'status_enum_workflow' );
 162          }
 163      }
 164      echo '<td class="center"' . $t_colour . '>';
 165      if ( $t_can_change_workflow ) {
 166          echo '<select name="default_' . $p_from_status . '">';
 167          print_enum_string_option_list( 'status', $t_project );
 168          echo '</select>';
 169      } else {
 170          echo MantisEnum::getLabel( lang_get( 'status_enum_string' ), $t_project );
 171      }
 172      echo ' </td>';
 173      echo '</tr>' . "\n";
 174  }
 175  
 176  function section_end() {
 177      echo '</table><br />' . "\n";
 178  }
 179  
 180  function threshold_begin( $p_section_name ) {
 181      echo '<table class="width100">';
 182      echo '<tr><td class="form-title" colspan="3">' . $p_section_name . '</td></tr>' . "\n";
 183      echo '<tr><td class="form-title" width="30%">' . lang_get( 'threshold' ) . '</td>';
 184      echo '<td class="form-title" >' . lang_get( 'status_level' ) . '</td>';
 185      echo '<td class="form-title" >' . lang_get( 'alter_level' ) . '</td></tr>';
 186      echo "\n";
 187  }
 188  
 189  function threshold_row( $p_threshold ) {
 190      global $t_access, $t_can_change_flags, $t_colour_project, $t_colour_global;
 191  
 192      $t_file = config_get_global( $p_threshold );
 193      $t_global = config_get( $p_threshold, null, null, ALL_PROJECTS );
 194      $t_project = config_get( $p_threshold );
 195      $t_can_change_threshold = $t_access >= config_get_access( $p_threshold );
 196      $t_colour = '';
 197      if ( $t_global != $t_file ) {
 198          $t_colour = ' bgcolor="' . $t_colour_global . '" '; # all projects override
 199          if ( $t_can_change_threshold ) {
 200              set_overrides( $p_threshold );
 201          }
 202      }
 203      if ( $t_project != $t_global ) {
 204          $t_colour = ' bgcolor="' . $t_colour_project . '" '; # project overrides
 205          if ( $t_can_change_threshold ) {
 206              set_overrides( $p_threshold );
 207          }
 208      }
 209  
 210      echo '<tr ' . helper_alternate_class() . '><td>' . lang_get( 'desc_' . $p_threshold ) . '</td>';
 211      if ( $t_can_change_threshold ) {
 212          echo '<td' . $t_colour . '><select name="threshold_' . $p_threshold . '">';
 213          print_enum_string_option_list( 'status', $t_project );
 214          echo '</select> </td>';
 215          echo '<td><select name="access_' . $p_threshold . '">';
 216          print_enum_string_option_list( 'access_levels', config_get_access( $p_threshold ) );
 217          echo '</select> </td>';
 218          $t_can_change_flags = true;
 219      } else {
 220          echo '<td' . $t_colour . '>' . MantisEnum::getLabel( lang_get( 'status_enum_string' ), $t_project ) . '&#160;</td>';
 221          echo '<td>' . MantisEnum::getLabel( lang_get( 'access_levels_enum_string' ), config_get_access( $p_threshold ) ) . '&#160;</td>';
 222      }
 223  
 224      echo '</tr>' . "\n";
 225  }
 226  
 227  function threshold_end() {
 228      echo '</table><br />' . "\n";
 229  }
 230  
 231  function access_begin( $p_section_name ) {
 232      echo '<table class="width100">';
 233      echo '<tr><td class="form-title" colspan="2">'
 234          . $p_section_name . '</td></tr>' . "\n";
 235      echo '<tr><td class="form-title" colspan="2">' . lang_get( 'access_change' ) . '</td></tr>';
 236  }
 237  
 238  function access_row() {
 239      global $t_access, $t_can_change_flags, $t_colour_project, $t_colour_global;
 240  
 241      $t_enum_status = MantisEnum::getAssocArrayIndexedByValues( config_get( 'status_enum_string' ) );
 242  
 243      $t_file_new = config_get_global( 'report_bug_threshold' );
 244      $t_global_new = config_get( 'report_bug_threshold', null, null, ALL_PROJECTS );
 245      $t_project_new = config_get( 'report_bug_threshold' );
 246  
 247      $t_file_set = config_get_global( 'set_status_threshold' );
 248      foreach ( $t_enum_status as $t_status => $t_status_label) {
 249          if ( !isset( $t_file_set[$t_status] ) ) {
 250              $t_file_set[$t_status] = config_get_global('update_bug_status_threshold');
 251          }
 252      }
 253  
 254      $t_global_set = config_get( 'set_status_threshold', null, null, ALL_PROJECTS );
 255      foreach ( $t_enum_status as $t_status => $t_status_label) {
 256          if ( !isset( $t_file_set[$t_status] ) ) {
 257              $t_file_set[$t_status] = config_get('update_bug_status_threshold', null, null, ALL_PROJECTS );
 258          }
 259      }
 260  
 261      $t_project_set = config_get( 'set_status_threshold' );
 262      foreach ( $t_enum_status as $t_status => $t_status_label) {
 263          if ( !isset( $t_file_set[$t_status] ) ) {
 264              $t_file_set[$t_status] = config_get('update_bug_status_threshold' );
 265          }
 266      }
 267  
 268      foreach ( $t_enum_status as $t_status => $t_status_label) {
 269          echo '<tr ' . helper_alternate_class() . '><td width="30%">' . string_no_break( MantisEnum::getLabel( lang_get( 'status_enum_string' ), $t_status ) ) . '</td>';
 270          if ( config_get( 'bug_submit_status' ) == $t_status ) {
 271              $t_level = $t_project_new;
 272              $t_can_change = ( $t_access >= config_get_access( 'report_bug_threshold' ) );
 273              $t_colour = '';
 274              if ( $t_global_new != $t_file_new ) {
 275                  $t_colour = ' bgcolor="' . $t_colour_global . '" '; # all projects override
 276                  if ( $t_can_change ) {
 277                      set_overrides( 'report_bug_threshold' );
 278                  }
 279              }
 280              if ( $t_project_new != $t_global_new ) {
 281                  $t_colour = ' bgcolor="' . $t_colour_project . '" '; # project overrides
 282                  if ( $t_can_change ) {
 283                      set_overrides( 'report_bug_threshold' );
 284                  }
 285              }
 286          } else {
 287              $t_level = ( isset( $t_project_set[$t_status] ) ? $t_project_set[$t_status] : false );
 288              $t_level_global = ( isset( $t_global_set[$t_status] ) ? $t_global_set[$t_status] : false );
 289              $t_level_file = ( isset( $t_file_set[$t_status] ) ? $t_file_set[$t_status] : false );
 290              $t_can_change = ( $t_access >= config_get_access( 'set_status_threshold' ) );
 291              $t_colour = '';
 292              if ( $t_level_global != $t_level_file ) {
 293                  $t_colour = ' bgcolor="' . $t_colour_global . '" '; # all projects override
 294                  if ( $t_can_change ) {
 295                      set_overrides( 'set_status_threshold' );
 296                  }
 297              }
 298              if ( $t_level != $t_level_global ) {
 299                  $t_colour = ' bgcolor="' . $t_colour_project . '" '; # project overrides
 300                  if ( $t_can_change ) {
 301                      set_overrides( 'set_status_threshold' );
 302                  }
 303              }
 304          }
 305          if ( $t_can_change ) {
 306              echo '<td' . $t_colour . '><select name="access_change_' . $t_status . '">';
 307              print_enum_string_option_list( 'access_levels', $t_level );
 308              echo '</select> </td>';
 309              $t_can_change_flags = true;
 310          } else {
 311              echo '<td class="center"' . $t_colour . '>' . MantisEnum::getLabel( lang_get( 'access_levels_enum_string' ), $t_level ) . '</td>';
 312          }
 313          echo '</tr>' . "\n";
 314      }
 315  }
 316  
 317  echo '<br /><br />';
 318  
 319  # count arcs in and out of each status
 320  $t_enum_status = config_get( 'status_enum_string' );
 321  $t_status_arr  = MantisEnum::getAssocArrayIndexedByValues( $t_enum_status );
 322  
 323  $t_extra_enum_status = '0:non-existent,' . $t_enum_status;
 324  $t_lang_enum_status = '0:' . lang_get( 'non_existent' ) . ',' . lang_get( 'status_enum_string' );
 325  $t_all_status = explode( ',', $t_extra_enum_status);
 326  
 327  # gather all versions of the workflow
 328  $t_file_workflow = workflow_parse( config_get_global( 'status_enum_workflow' ) );
 329  $t_global_workflow = workflow_parse( config_get( 'status_enum_workflow', null, null, ALL_PROJECTS ) );
 330  $t_project_workflow = workflow_parse( config_get( 'status_enum_workflow' ) );
 331  
 332  # validate the project workflow
 333  $t_validation_result = '';
 334  foreach ( $t_status_arr as $t_status => $t_label ) {
 335      if ( isset( $t_project_workflow['exit'][$t_status][$t_status] ) ) {
 336          $t_validation_result .= '<tr ' . helper_alternate_class() . '><td>'
 337                          . MantisEnum::getLabel( $t_lang_enum_status, $t_status )
 338                          . '</td><td bgcolor="#FFED4F">' . lang_get( 'superfluous' ) . '</td>';
 339      }
 340  }
 341  
 342  # check for entry == 0 without exit == 0, unreachable state
 343  foreach ( $t_status_arr as $t_status => $t_status_label) {
 344      if ( ( 0 == count( $t_project_workflow['entry'][$t_status] ) ) && ( 0 < count( $t_project_workflow['exit'][$t_status] ) ) ){
 345          $t_validation_result .= '<tr ' . helper_alternate_class() . '><td>'
 346                          . MantisEnum::getLabel( $t_lang_enum_status, $t_status )
 347                          . '</td><td bgcolor="#FF0088">' . lang_get( 'unreachable' ) . '</td>';
 348      }
 349  }
 350  
 351  # check for exit == 0 without entry == 0, unleaveable state
 352  foreach ( $t_status_arr as $t_status => $t_status_label ) {
 353      if ( ( 0 == count( $t_project_workflow['exit'][$t_status] ) ) && ( 0 < count( $t_project_workflow['entry'][$t_status] ) ) ){
 354          $t_validation_result .= '<tr ' . helper_alternate_class() . '><td>'
 355                          . MantisEnum::getLabel( $t_lang_enum_status, $t_status )
 356                          . '</td><td bgcolor="#FF0088">' . lang_get( 'no_exit' ) . '</td>';
 357      }
 358  }
 359  
 360  # check for exit == 0 and entry == 0, isolated state
 361  foreach ( $t_status_arr as $t_status => $t_status_label ) {
 362      if ( ( 0 == count( $t_project_workflow['exit'][$t_status] ) ) && ( 0 == count( $t_project_workflow['entry'][$t_status] ) ) ){
 363          $t_validation_result .= '<tr ' . helper_alternate_class() . '><td>'
 364                          . MantisEnum::getLabel( $t_lang_enum_status, $t_status )
 365                          . '</td><td bgcolor="#FF0088">' . lang_get( 'unreachable' ) . '<br />' . lang_get( 'no_exit' ) . '</td>';
 366      }
 367  }
 368  
 369  $t_colour_project = config_get( 'colour_project');
 370  $t_colour_global = config_get( 'colour_global');
 371  
 372  echo "<form name=\"workflow_config_action\" method=\"post\" action=\"manage_config_workflow_set.php\">\n";
 373  echo form_security_field( 'manage_config_workflow_set' );
 374  
 375  if ( ALL_PROJECTS == $t_project ) {
 376      $t_project_title = lang_get( 'config_all_projects' );
 377  } else {
 378      $t_project_title = sprintf( lang_get( 'config_project' ) , string_display( project_get_name( $t_project ) ) );
 379  }
 380  echo '<p class="bold">' . $t_project_title . '</p>' . "\n";
 381  echo '<p>' . lang_get( 'colour_coding' ) . '<br />';
 382  if ( ALL_PROJECTS <> $t_project ) {
 383      echo '<span style="background-color:' . $t_colour_project . '">' . lang_get( 'colour_project' ) .'</span><br />';
 384  }
 385  echo '<span style="background-color:' . $t_colour_global . '">' . lang_get( 'colour_global' ) . '</span></p>';
 386  
 387  # show the settings used to derive the table
 388  threshold_begin( lang_get( 'workflow_thresholds' ) );
 389  if ( !is_array( config_get( 'bug_submit_status' ) ) ) {
 390      threshold_row( 'bug_submit_status' );
 391  }
 392  threshold_row( 'bug_resolved_status_threshold' );
 393  threshold_row( 'bug_reopen_status' );
 394  threshold_end();
 395  echo '<br />';
 396  
 397  if ( '' <> $t_validation_result ) {
 398      echo '<table class="width100">';
 399      echo '<tr><td class="form-title" colspan="3">' . lang_get( 'validation' ) . '</td></tr>' . "\n";
 400      echo '<tr><td class="form-title" width="30%">' . lang_get( 'status' ) . '</td>';
 401      echo '<td class="form-title" >' . lang_get( 'comment' ) . '</td></tr>';
 402      echo "\n";
 403      echo $t_validation_result;
 404      echo '</table><br /><br />';
 405  }
 406  
 407  # display the graph as a matrix
 408  section_begin( lang_get( 'workflow' ) );
 409  foreach ( $t_status_arr as $t_from_status => $t_from_label) {
 410      capability_row( $t_from_status );
 411  }
 412  section_end();
 413  
 414  if ( $t_can_change_workflow ) {
 415      echo '<p>' . lang_get( 'workflow_change_access_label' );
 416      echo '<select name="workflow_access">';
 417      print_enum_string_option_list( 'access_levels', config_get_access( 'status_enum_workflow' ) );
 418      echo '</select> </p><br />';
 419  }
 420  
 421  # display the access levels required to move an issue
 422  access_begin( lang_get( 'access_levels' ) );
 423  access_row();
 424  section_end();
 425  
 426  if ( $t_access >= config_get_access( 'set_status_threshold' ) ) {
 427      echo '<p>' . lang_get( 'access_change_access_label' );
 428      echo '<select name="status_access">';
 429      print_enum_string_option_list( 'access_levels', config_get_access( 'set_status_threshold' ) );
 430      echo '</select> </p><br />';
 431  }
 432  
 433  if ( $t_can_change_flags ) {
 434      echo "<input type=\"submit\" class=\"button\" value=\"" . lang_get( 'change_configuration' ) . "\" />\n";
 435      echo "</form>\n";
 436  
 437      if ( 0 < count( $t_overrides ) ) {
 438          echo "<div class=\"right\"><form name=\"mail_config_action\" method=\"post\" action=\"manage_config_revert.php\">\n";
 439          echo form_security_field( 'manage_config_revert' );
 440          echo "<input name=\"revert\" type=\"hidden\" value=\"" . implode( ',', $t_overrides ) . "\"></input>";
 441          echo "<input name=\"project\" type=\"hidden\" value=\"$t_project\"></input>";
 442          echo "<input name=\"return\" type=\"hidden\" value=\"\"></input>";
 443          echo "<input type=\"submit\" class=\"button\" value=\"";
 444          if ( ALL_PROJECTS == $t_project ) {
 445              echo lang_get( 'revert_to_system' );
 446          } else {
 447              echo lang_get( 'revert_to_all_project' );
 448          }
 449          echo "\" />\n";
 450          echo "</form></div>\n";
 451      }
 452  
 453  } else {
 454      echo "</form>\n";
 455  }
 456  
 457  html_page_bottom();


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