[ Index ]

PHP Cross Reference of MantisBT

title

Body

[close]

/ -> manage_config_work_threshold_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 config_api.php
  27   * @uses constant_inc.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 user_api.php
  36   */
  37  
  38  /**
  39   * MantisBT Core API's
  40   */
  41  require_once ( 'core.php' );
  42  require_api( 'access_api.php' );
  43  require_api( 'authentication_api.php' );
  44  require_api( 'config_api.php' );
  45  require_api( 'constant_inc.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( 'user_api.php' );
  54  
  55  auth_reauthenticate();
  56  
  57  html_page_top( lang_get( 'manage_threshold_config' ) );
  58  
  59  print_manage_menu( 'adm_permissions_report.php' );
  60  print_manage_config_menu( 'manage_config_work_threshold_page.php' );
  61  
  62  $t_user = auth_get_current_user_id();
  63  $t_project_id = helper_get_current_project();
  64  $t_access = user_get_access_level( $t_user, $t_project_id );
  65  $t_show_submit = false;
  66  
  67  $t_access_levels = MantisEnum::getAssocArrayIndexedByValues( config_get( 'access_levels_enum_string' ) );
  68  
  69  $t_overrides = array();
  70  function set_overrides( $p_config ) {
  71     global $t_overrides;
  72     if ( !in_array( $p_config, $t_overrides ) ) {
  73         $t_overrides[] = $p_config;
  74     }
  75  }
  76  
  77  function get_section_begin_mcwt( $p_section_name ) {
  78      global $t_access_levels;
  79  
  80      echo '<table class="width100">';
  81      echo '<tr><td class="form-title" colspan="' . ( count( $t_access_levels ) + 2 ) . '">' . $p_section_name . '</td></tr>' . "\n";
  82      echo '<tr><td class="form-title" width="40%" rowspan="2">' . lang_get( 'perm_rpt_capability' ) . '</td>';
  83      echo '<td class="form-title" style="text-align:center"  width="40%" colspan="' . count( $t_access_levels ) . '">' . lang_get( 'access_levels' ) . '</td>';
  84      echo '<td class="form-title" style="text-align:center" rowspan="2">&#160;' . lang_get( 'alter_level' ) . '&#160;</td></tr><tr>';
  85      foreach( $t_access_levels as $t_access_level => $t_access_label ) {
  86          echo '<td class="form-title" style="text-align:center">&#160;' . MantisEnum::getLabel( lang_get( 'access_levels_enum_string' ), $t_access_level ) . '&#160;</td>';
  87      }
  88      echo '</tr>' . "\n";
  89  }
  90  
  91  function get_capability_row( $p_caption, $p_threshold, $p_all_projects_only=false ) {
  92      global $t_user, $t_project_id, $t_show_submit, $t_access_levels, $t_colour_project, $t_colour_global;
  93  
  94      $t_file = config_get_global( $p_threshold );
  95      if ( !is_array( $t_file ) ) {
  96          $t_file_exp = array();
  97          foreach( $t_access_levels as $t_access_level => $t_label ) {
  98              if ( $t_access_level >= $t_file ) {
  99                  $t_file_exp[] = $t_access_level;
 100              }
 101          }
 102      } else {
 103          $t_file_exp = $t_file;
 104      }
 105  
 106      $t_global = config_get( $p_threshold, null, null, ALL_PROJECTS );
 107      if ( !is_array( $t_global ) ) {
 108          $t_global_exp = array();
 109          foreach( $t_access_levels as $t_access_level => $t_label ) {
 110              if ( $t_access_level >= $t_global ) {
 111                  $t_global_exp[] = $t_access_level;
 112              }
 113          }
 114      } else {
 115          $t_global_exp = $t_global;
 116      }
 117  
 118      $t_project = config_get( $p_threshold );
 119      if ( !is_array( $t_project ) ) {
 120          $t_project_exp = array();
 121          foreach( $t_access_levels as $t_access_level => $t_label ) {
 122              if ( $t_access_level >= $t_project ) {
 123                  $t_project_exp[] = $t_access_level;
 124              }
 125          }
 126      } else {
 127          $t_project_exp = $t_project;
 128      }
 129  
 130      $t_can_change = access_has_project_level( config_get_access( $p_threshold ), $t_project_id, $t_user )
 131                && ( ( ALL_PROJECTS == $t_project_id ) || !$p_all_projects_only );
 132  
 133      echo '<tr ' . helper_alternate_class() . '><td>' . string_display( $p_caption ) . '</td>';
 134      foreach( $t_access_levels as $t_access_level => $t_access_label ) {
 135          $t_file = in_array( $t_access_level, $t_file_exp );
 136          $t_global = in_array( $t_access_level, $t_global_exp );
 137          $t_project = in_array( $t_access_level, $t_project_exp ) ;
 138  
 139          $t_colour = '';
 140          if ( $t_global != $t_file ) {
 141              $t_colour = ' bgcolor="' . $t_colour_global . '" '; # all projects override
 142              if ( $t_can_change ) {
 143                  set_overrides( $p_threshold );
 144              }
 145          }
 146          if ( $t_project != $t_global ) {
 147              $t_colour = ' bgcolor="' . $t_colour_project . '" '; # project overrides
 148              if ( $t_can_change ) {
 149                  set_overrides( $p_threshold );
 150              }
 151          }
 152  
 153          if ( $t_can_change ) {
 154              $t_checked = $t_project ? "checked=\"checked\"" : "";
 155              $t_value = "<input type=\"checkbox\" name=\"flag_thres_" . $p_threshold . "[]\" value=\"$t_access_level\" $t_checked />";
 156              $t_show_submit = true;
 157          } else {
 158              if ( $t_project ) {
 159                  $t_value = '<img src="images/ok.gif" width="20" height="15" alt="X" title="X" />';
 160              } else {
 161                  $t_value = '&#160;';
 162              }
 163          }
 164          echo '<td class="center"' . $t_colour . '>' . $t_value . '</td>';
 165      }
 166      if ( $t_can_change ) {
 167          echo '<td> <select name="access_' . $p_threshold . '">';
 168          print_enum_string_option_list( 'access_levels', config_get_access( $p_threshold ) );
 169          echo '</select> </td>';
 170      } else {
 171          echo '<td>' . MantisEnum::getLabel( lang_get( 'access_levels_enum_string' ), config_get_access( $p_threshold ) ) . '&#160;</td>';
 172      }
 173  
 174      echo '</tr>' . "\n";
 175  }
 176  
 177  function get_capability_boolean( $p_caption, $p_threshold, $p_all_projects_only=false ) {
 178      global $t_user, $t_project_id, $t_show_submit, $t_access_levels, $t_colour_project, $t_colour_global;
 179  
 180      $t_file = config_get_global( $p_threshold );
 181      $t_global = config_get( $p_threshold, null, null, ALL_PROJECTS );
 182      $t_project = config_get( $p_threshold );
 183  
 184      $t_can_change = access_has_project_level( config_get_access( $p_threshold ), $t_project_id, $t_user )
 185                && ( ( ALL_PROJECTS == $t_project_id ) || !$p_all_projects_only );
 186  
 187      $t_colour = '';
 188      if ( $t_global != $t_file ) {
 189          $t_colour = ' bgcolor="' . $t_colour_global . '" '; # all projects override
 190          if ( $t_can_change ) {
 191              set_overrides( $p_threshold );
 192          }
 193      }
 194      if ( $t_project != $t_global ) {
 195          $t_colour = ' bgcolor="' . $t_colour_project . '" '; # project overrides
 196          if ( $t_can_change ) {
 197              set_overrides( $p_threshold );
 198          }
 199      }
 200  
 201      echo '<tr ' . helper_alternate_class() . '><td>' . string_display( $p_caption ) . '</td>';
 202      if ( $t_can_change ) {
 203          $t_checked = ( ON == config_get( $p_threshold ) ) ? "checked=\"checked\"" : "";
 204          $t_value = "<input type=\"checkbox\" name=\"flag_" . $p_threshold . "\" value=\"1\" $t_checked />";
 205          $t_show_submit = true;
 206      } else {
 207          if ( ON == config_get( $p_threshold ) ) {
 208              $t_value = '<img src="images/ok.gif" width="20" height="15" title="X" alt="X" />';
 209          } else {
 210              $t_value = '&#160;';
 211          }
 212      }
 213      echo '<td' . $t_colour . '>' . $t_value . '</td><td class="left" colspan="' . ( count( $t_access_levels ) - 1 ). '"></td>';
 214  
 215      if ( $t_can_change ) {
 216          echo '<td><select name="access_' . $p_threshold . '">';
 217          print_enum_string_option_list( 'access_levels', config_get_access( $p_threshold ) );
 218          echo '</select> </td>';
 219      } else {
 220          echo '<td>' . MantisEnum::getLabel( lang_get( 'access_levels_enum_string' ), config_get_access( $p_threshold ) ) . '&#160;</td>';
 221      }
 222  
 223      echo '</tr>' . "\n";
 224  }
 225  
 226  function get_capability_enum( $p_caption, $p_threshold, $p_enum, $p_all_projects_only=false ) {
 227      global $t_user, $t_project_id, $t_show_submit, $t_access_levels, $t_colour_project, $t_colour_global;
 228  
 229      $t_file = config_get_global( $p_threshold );
 230      $t_global = config_get( $p_threshold, null, null, ALL_PROJECTS );
 231      $t_project = config_get( $p_threshold );
 232  
 233      $t_can_change = access_has_project_level( config_get_access( $p_threshold ), $t_project_id, $t_user )
 234                && ( ( ALL_PROJECTS == $t_project_id ) || !$p_all_projects_only );
 235  
 236      $t_colour = '';
 237      if ( $t_global != $t_file ) {
 238          $t_colour = ' bgcolor="' . $t_colour_global . '" '; # all projects override
 239          if ( $t_can_change ) {
 240              set_overrides( $p_threshold );
 241          }
 242      }
 243      if ( $t_project != $t_global ) {
 244          $t_colour = ' bgcolor="' . $t_colour_project . '" '; # project overrides
 245          if ( $t_can_change ) {
 246              set_overrides( $p_threshold );
 247          }
 248      }
 249  
 250      echo '<tr ' . helper_alternate_class() . '><td>' . string_display( $p_caption ) . '</td>';
 251      if ( $t_can_change ) {
 252          echo '<td class="left" colspan="3"' . $t_colour . '><select name="flag_' . $p_threshold . '">';
 253          print_enum_string_option_list( $p_enum, config_get( $p_threshold ) );
 254          echo '</select></td><td colspan="' . ( count( $t_access_levels ) - 3 ) . '"></td>';
 255          $t_show_submit = true;
 256      } else {
 257          $t_value = MantisEnum::getLabel( lang_get( $p_enum . '_enum_string' ), config_get( $p_threshold ) ) . '&#160;';
 258          echo '<td class="left" colspan="3"' . $t_colour . '>' . $t_value . '</td><td colspan="' . ( count( $t_access_levels ) - 3 ) . '"></td>';
 259      }
 260  
 261      if ( $t_can_change ) {
 262          echo '<td><select name="access_' . $p_threshold . '">';
 263          print_enum_string_option_list( 'access_levels', config_get_access( $p_threshold ) );
 264          echo '</select> </td>';
 265      } else {
 266          echo '<td>' . MantisEnum::getLabel( lang_get( 'access_levels_enum_string' ), config_get_access( $p_threshold ) ) . '&#160;</td>';
 267      }
 268  
 269      echo '</tr>' . "\n";
 270  }
 271  
 272  function get_section_end() {
 273      echo '</table><br />' . "\n";
 274  }
 275  
 276  $t_colour_project = config_get( 'colour_project');
 277  $t_colour_global = config_get( 'colour_global');
 278  
 279  echo "<br /><br />\n";
 280  
 281  if ( ALL_PROJECTS == $t_project_id ) {
 282      $t_project_title = lang_get( 'config_all_projects' );
 283  } else {
 284      $t_project_title = sprintf( lang_get( 'config_project' ) , string_display( project_get_name( $t_project_id ) ) );
 285  }
 286  echo '<p class="bold">' . $t_project_title . '</p>' . "\n";
 287  echo '<p>' . lang_get( 'colour_coding' ) . '<br />';
 288  if ( ALL_PROJECTS <> $t_project_id ) {
 289      echo '<span style="background-color:' . $t_colour_project . '">' . lang_get( 'colour_project' ) .'</span><br />';
 290  }
 291  echo '<span style="background-color:' . $t_colour_global . '">' . lang_get( 'colour_global' ) . '</span></p>';
 292  
 293  echo "<form name=\"mail_config_action\" method=\"post\" action=\"manage_config_work_threshold_set.php\">\n";
 294  echo form_security_field( 'manage_config_work_threshold_set' );
 295  
 296  # Issues
 297  get_section_begin_mcwt( lang_get( 'issues' ) );
 298  get_capability_row( lang_get( 'report_issue' ), 'report_bug_threshold' );
 299  get_capability_enum( lang_get( 'submit_status' ), 'bug_submit_status', 'status' );
 300  get_capability_row( lang_get( 'update_issue' ), 'update_bug_threshold' );
 301  get_capability_boolean( lang_get( 'allow_reporter_close' ), 'allow_reporter_close' );
 302  get_capability_row( lang_get( 'monitor_issue' ), 'monitor_bug_threshold' );
 303  get_capability_row( lang_get( 'handle_issue' ), 'handle_bug_threshold' );
 304  get_capability_row( lang_get( 'assign_issue' ), 'update_bug_assign_threshold' );
 305  get_capability_row( lang_get( 'move_issue' ), 'move_bug_threshold', true );
 306  get_capability_row( lang_get( 'delete_issue' ), 'delete_bug_threshold' );
 307  get_capability_row( lang_get( 'reopen_issue' ), 'reopen_bug_threshold' );
 308  get_capability_boolean( lang_get( 'allow_reporter_reopen' ), 'allow_reporter_reopen' );
 309  get_capability_enum( lang_get( 'reopen_status' ), 'bug_reopen_status', 'status' );
 310  get_capability_enum( lang_get( 'reopen_resolution' ), 'bug_reopen_resolution', 'resolution' );
 311  get_capability_enum( lang_get( 'resolved_status' ), 'bug_resolved_status_threshold', 'status' );
 312  get_capability_enum( lang_get( 'readonly_status' ), 'bug_readonly_status_threshold', 'status' );
 313  get_capability_row( lang_get( 'update_readonly_issues' ), 'update_readonly_bug_threshold' );
 314  get_capability_row( lang_get( 'update_issue_status' ), 'update_bug_status_threshold' );
 315  get_capability_row( lang_get( 'view_private_issues' ), 'private_bug_threshold' );
 316  get_capability_row( lang_get( 'set_view_status' ), 'set_view_status_threshold' );
 317  get_capability_row( lang_get( 'update_view_status' ), 'change_view_status_threshold' );
 318  get_capability_row( lang_get( 'show_list_of_users_monitoring_issue' ), 'show_monitor_list_threshold' );
 319  get_capability_boolean( lang_get( 'set_status_assigned' ), 'auto_set_status_to_assigned' );
 320  get_capability_enum( lang_get( 'assigned_status' ), 'bug_assigned_status', 'status' );
 321  get_capability_boolean( lang_get( 'limit_access' ), 'limit_reporters', true );
 322  get_section_end();
 323  
 324  # Notes
 325  get_section_begin_mcwt( lang_get( 'notes' ) );
 326  get_capability_row( lang_get( 'add_notes' ), 'add_bugnote_threshold' );
 327  get_capability_row( lang_get( 'edit_others_bugnotes' ), 'update_bugnote_threshold' );
 328  get_capability_row( lang_get( 'edit_own_bugnotes' ), 'bugnote_user_edit_threshold' );
 329  get_capability_row( lang_get( 'delete_others_bugnotes' ), 'delete_bugnote_threshold' );
 330  get_capability_row( lang_get( 'delete_own_bugnotes' ), 'bugnote_user_delete_threshold' );
 331  get_capability_row( lang_get( 'view_private_notes' ), 'private_bugnote_threshold' );
 332  get_capability_row( lang_get( 'change_view_state_own_bugnotes' ), 'bugnote_user_change_view_state_threshold' );
 333  get_section_end();
 334  
 335  # Others
 336  get_section_begin_mcwt( lang_get('others' ) );
 337  get_capability_row( lang_get( 'view' ) . ' ' . lang_get( 'changelog_link' ), 'view_changelog_threshold' );
 338  get_capability_row( lang_get( 'view' ) . ' ' . lang_get( 'assigned_to' ), 'view_handler_threshold' );
 339  get_capability_row( lang_get( 'view' ) . ' ' . lang_get( 'bug_history' ), 'view_history_threshold' );
 340  get_capability_row( lang_get( 'send_reminders' ), 'bug_reminder_threshold' );
 341  get_section_end();
 342  
 343  
 344  if ( $t_show_submit ) {
 345      echo "<input type=\"submit\" class=\"button\" value=\"" . lang_get( 'change_configuration' ) . "\" />\n";
 346  }
 347  
 348  echo "</form>\n";
 349  
 350  if ( $t_show_submit && ( 0 < count( $t_overrides ) ) ) {
 351      echo "<div class=\"right\"><form name=\"threshold_config_action\" method=\"post\" action=\"manage_config_revert.php\">\n";
 352      echo form_security_field( 'manage_config_revert' );
 353      echo "<input name=\"revert\" type=\"hidden\" value=\"" . implode( ',', $t_overrides ) . "\"></input>";
 354      echo "<input name=\"project\" type=\"hidden\" value=\"$t_project_id\"></input>";
 355      echo "<input name=\"return\" type=\"hidden\" value=\"\"></input>";
 356      echo "<input type=\"submit\" class=\"button\" value=\"";
 357      if ( ALL_PROJECTS == $t_project_id ) {
 358          echo lang_get( 'revert_to_system' );
 359      } else {
 360      echo lang_get( 'revert_to_all_project' );
 361      }
 362      echo "\" />\n";
 363      echo "</form></div>\n";
 364  }
 365  
 366  html_page_bottom();


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