[ Index ]

PHP Cross Reference of MantisBT

title

Body

[close]

/ -> adm_config_report.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 database_api.php
  29   * @uses form_api.php
  30   * @uses helper_api.php
  31   * @uses html_api.php
  32   * @uses lang_api.php
  33   * @uses print_api.php
  34   * @uses project_api.php
  35   * @uses string_api.php
  36   * @uses user_api.php
  37   */
  38  
  39  /**
  40   * MantisBT Core API's
  41   */
  42  require_once ( 'core.php' );
  43  require_api( 'access_api.php' );
  44  require_api( 'authentication_api.php' );
  45  require_api( 'config_api.php' );
  46  require_api( 'constant_inc.php' );
  47  require_api( 'database_api.php' );
  48  require_api( 'form_api.php' );
  49  require_api( 'helper_api.php' );
  50  require_api( 'html_api.php' );
  51  require_api( 'lang_api.php' );
  52  require_api( 'print_api.php' );
  53  require_api( 'project_api.php' );
  54  require_api( 'string_api.php' );
  55  require_api( 'user_api.php' );
  56  
  57  access_ensure_global_level( config_get( 'view_configuration_threshold' ) );
  58  
  59  $t_read_write_access = access_has_global_level( config_get('set_configuration_threshold' ) );
  60  
  61  html_page_top( lang_get( 'configuration_report' ) );
  62  
  63  print_manage_menu( 'adm_config_report.php' );
  64  print_manage_config_menu( 'adm_config_report.php' );
  65  
  66  function get_config_type( $p_type ) {
  67      switch( $p_type ) {
  68          case CONFIG_TYPE_INT:
  69              return "integer";
  70          case CONFIG_TYPE_FLOAT:
  71              return "float";
  72          case CONFIG_TYPE_COMPLEX:
  73              return "complex";
  74          case CONFIG_TYPE_STRING:
  75          default:
  76              return "string";
  77      }
  78  }
  79  
  80  function print_config_value_as_string( $p_type, $p_value ) {
  81      $t_corrupted = false;
  82  
  83      switch( $p_type ) {
  84          case CONFIG_TYPE_FLOAT:
  85              $t_value = (float)$p_value;
  86              echo $t_value;
  87              return;
  88          case CONFIG_TYPE_INT:
  89              $t_value = (integer)$p_value;
  90              echo $t_value;
  91              return;
  92          case CONFIG_TYPE_STRING:
  93              $t_value = config_eval( $p_value );
  94              echo string_nl2br( string_html_specialchars( $t_value ) );
  95              return;
  96          case CONFIG_TYPE_COMPLEX:
  97              $t_value = @unserialize( $p_value );
  98              if ( $t_value === false ) {
  99                  $t_corrupted = true;
 100              }
 101              break;
 102          default:
 103              $t_value = config_eval( $p_value );
 104              break;
 105      }
 106  
 107      echo '<pre>';
 108  
 109      if ( $t_corrupted ) {
 110          echo lang_get( 'configuration_corrupted' );
 111      } else {
 112          if ( function_exists( 'var_export' ) ) {
 113              var_export( $t_value );
 114          } else {
 115              print_r( $t_value );
 116          }
 117      }
 118  
 119      echo '</pre>';
 120  }
 121  
 122  $t_config_table = db_get_table( 'config' );
 123  $query = "SELECT config_id, user_id, project_id, type, value, access_reqd FROM $t_config_table ORDER BY user_id, project_id, config_id";
 124  $result = db_query_bound( $query );
 125  ?>
 126  <div id="adm-config-div" class="table-container">
 127      <h2><?php echo lang_get( 'database_configuration' ) ?></h2>
 128      <table cellspacing="1" cellpadding="5" border="1">
 129          <tr class="row-category">
 130              <th class="center"><?php echo lang_get( 'username' ) ?></th>
 131              <th class="center"><?php echo lang_get( 'project_name' ) ?></th>
 132              <th><?php echo lang_get( 'configuration_option' ) ?></th>
 133              <th class="center"><?php echo lang_get( 'configuration_option_type' ) ?></th>
 134              <th class="center"><?php echo lang_get( 'configuration_option_value' ) ?></th>
 135              <th class="center"><?php echo lang_get( 'access_level' ) ?></th>
 136              <?php if ( $t_read_write_access ): ?>
 137              <th class="center"><?php echo lang_get( 'actions' ) ?></th>
 138              <?php endif; ?>
 139          </tr><?php
 140          while ( $row = db_fetch_array( $result ) ) {
 141              extract( $row, EXTR_PREFIX_ALL, 'v' ); ?>
 142          <tr <?php echo helper_alternate_class() ?>>
 143              <td class="center">
 144                  <?php echo ($v_user_id == 0) ? lang_get( 'all_users' ) : string_display_line( user_get_name( $v_user_id ) ) ?>
 145              </td>
 146              <td class="center"><?php echo string_display_line( project_get_name( $v_project_id, false ) ) ?></td>
 147              <td><?php echo string_display_line( $v_config_id ) ?></td>
 148              <td class="center"><?php echo string_display_line( get_config_type( $v_type ) ) ?></td>
 149              <td class="left"><?php print_config_value_as_string( $v_type, $v_value ) ?></td>
 150              <td class="center"><?php echo get_enum_element( 'access_levels', $v_access_reqd ) ?></td>
 151              <?php if ( $t_read_write_access ): ?>
 152              <td class="center">
 153                  <?php
 154                      if ( config_can_delete( $v_config_id ) ) {
 155                          print_button( "adm_config_delete.php?user_id=$v_user_id&project_id=$v_project_id&config_option=$v_config_id", lang_get( 'delete_link' ) );
 156                      } else {
 157                          echo '&#160;';
 158                      }
 159                  ?>
 160              </td>
 161              <?php endif; ?>
 162          </tr><?php
 163          } # end for loop ?>
 164      </table>
 165  </div><?php
 166  
 167  if ( $t_read_write_access ) { ?>
 168  <div class="form-container">
 169      <form method="post" action="adm_config_set.php">
 170          <fieldset>
 171              <legend><span><?php echo lang_get( 'set_configuration_option' ) ?></span></legend>
 172              <?php echo form_security_field( 'adm_config_set' ) ?>
 173              <div class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
 174                  <label for="config-user-id"><span><?php echo lang_get( 'username' ) ?></span></label>
 175                  <span class="select">
 176                      <select id="config-user-id" name="user_id">
 177                          <option value="0" selected="selected"><?php echo lang_get( 'all_users' ); ?></option>
 178                          <?php print_user_option_list( 0 ) ?>
 179                      </select>
 180                  </span>
 181                  <span class="label-style"></span>
 182              </div>
 183              <div class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
 184                  <label for="config-project-id"><span><?php echo lang_get( 'project_name' ) ?></span></label>
 185                  <span class="select">
 186                      <select id="config-project-id" name="project_id">
 187                          <option value="0" selected="selected"><?php echo lang_get( 'all_projects' ); ?></option>
 188                          <?php print_project_option_list( ALL_PROJECTS, false ) ?>
 189                      </select>
 190                  </span>
 191                  <span class="label-style"></span>
 192              </div>
 193              <div class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
 194                  <label for="config-option"><span><?php echo lang_get( 'configuration_option' ) ?></span></label>
 195                  <span class="input"><input type="text" id="config-option" name="config_option" value="" size="64" maxlength="64" /></span>
 196                  <span class="label-style"></span>
 197              </div>
 198              <div class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
 199                  <label for="config-type"><span><?php echo lang_get( 'configuration_option_type' ) ?></span></label>
 200                  <span class="select">
 201                      <select id="config-type" name="type">
 202                          <option value="default" selected="selected">default</option>
 203                          <option value="string">string</option>
 204                          <option value="integer">integer</option>
 205                          <option value="complex">complex</option>
 206                      </select>
 207                  </span>
 208                  <span class="label-style"></span>
 209              </div>
 210              <div class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
 211                  <label for="config-value"><span><?php echo lang_get( 'configuration_option_value' ) ?></span></label>
 212                  <span class="textarea"><textarea id="config-value" name="value" cols="80" rows="10"></textarea></span>
 213                  <span class="label-style"></span>
 214              </div>
 215              <span class="submit-button"><input type="submit" name="config_set" class="button" value="<?php echo lang_get( 'set_configuration_option' ) ?>" /></span>
 216          </fieldset>
 217      </form>
 218  </div><?php
 219  } # end user can change config
 220  
 221  html_page_bottom();


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