[ Index ]
 

Code source de Mantis 1.1.0rc3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/ -> adm_config_set.php (source)

   1  <?php
   2  # Mantis - a php based bugtracking system
   3  
   4  # Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
   5  # Copyright (C) 2002 - 2007  Mantis Team   - mantisbt-dev@lists.sourceforge.net
   6  
   7  # Mantis is free software: you can redistribute it and/or modify
   8  # it under the terms of the GNU General Public License as published by
   9  # the Free Software Foundation, either version 2 of the License, or
  10  # (at your option) any later version.
  11  #
  12  # Mantis is distributed in the hope that it will be useful,
  13  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15  # GNU General Public License for more details.
  16  #
  17  # You should have received a copy of the GNU General Public License
  18  # along with Mantis.  If not, see <http://www.gnu.org/licenses/>.
  19  
  20      # --------------------------------------------------------
  21      # $Id: adm_config_set.php,v 1.4.2.1 2007-10-13 22:32:27 giallu Exp $
  22      # --------------------------------------------------------
  23  
  24      # This page stores the reported bug
  25  
  26      require_once ( 'core.php' );
  27  
  28      $t_core_path = config_get( 'core_path' );
  29  
  30      $f_user_id = gpc_get_int( 'user_id' );
  31      $f_project_id = gpc_get_int( 'project_id' );
  32      $f_config_option = gpc_get_string( 'config_option' );
  33      $f_type = gpc_get_string( 'type' );
  34      $f_value = gpc_get_string( 'value' );
  35      
  36      if ( is_blank( $f_config_option ) ) {
  37          error_parameters( 'config_option' );
  38          trigger_error( ERROR_EMPTY_FIELD, ERROR );
  39      }
  40  
  41      if ( $f_project_id == ALL_PROJECTS ) {
  42          access_ensure_global_level( config_get('set_configuration_threshold' ) );
  43      } else {
  44          access_ensure_project_level( config_get('set_configuration_threshold' ), $f_project_id );
  45      }
  46      
  47      # make sure that configuration option specified is a valid one.
  48      $t_not_found_value = '***CONFIG OPTION NOT FOUND***';
  49      if ( config_get_global( $f_config_option, $t_not_found_value ) === $t_not_found_value ) {
  50          error_parameters( $f_config_option );
  51          trigger_error( ERROR_CONFIG_OPT_NOT_FOUND, ERROR );
  52      }
  53  
  54      # make sure that configuration option specified can be stored in the database
  55      if ( !config_can_set_in_database( $f_config_option ) ) {
  56          error_parameters( $f_config_option );
  57          trigger_error( ERROR_CONFIG_OPT_CANT_BE_SET_IN_DB, ERROR );
  58      }
  59      
  60      if ( $f_type === 'default' ) {
  61          $t_config_global_value = config_get_global( $f_config_option );
  62          if ( is_string( $t_config_global_value ) ) {
  63              $t_type = 'string';
  64          } else if ( is_int( $t_config_global_value ) ) {
  65              $t_type = 'integer';
  66          } else { # note that we consider bool and float as complex.  We use ON/OFF for bools which map to numeric.
  67              $t_type = 'complex';
  68          }
  69      } else {
  70          $t_type = $f_type;
  71      }
  72  
  73      if ( $t_type === 'string' ) {
  74          $t_value = $f_value;
  75      } else if ( $t_type === 'integer' ) {
  76          $t_value = (integer)$f_value;
  77      } else {
  78          eval( '$t_value = ' . $f_value . ';' );
  79      }
  80  
  81      config_set( $f_config_option, $t_value, $f_user_id, $f_project_id );
  82  
  83      print_successful_redirect( 'adm_config_report.php' );
  84  ?>


Généré le : Thu Nov 29 09:42:17 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics