[ Index ]
 

Code source de Mantis 1.1.0rc3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/admin/ -> copy_field.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      # This upgrade moves attachments from the database to the disk
  21  
  22      # --------------------------------------------------------
  23      # $Id: copy_field.php,v 1.6.2.1 2007-10-13 22:34:53 giallu Exp $
  24      # --------------------------------------------------------
  25  ?>
  26  <?php
  27      require_once ( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' );
  28  
  29      $f_source_field_id = gpc_get_int( 'source_id' );
  30      $f_dest_field = gpc_get( 'dest_id' );
  31  ?>
  32  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  33  <html>
  34  <head>
  35  <title> Mantis Administration - Copy Custom Fields to Built-in </title>
  36  <link rel="stylesheet" type="text/css" href="admin.css" />
  37  </head>
  38  <body>
  39  
  40  <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffff">
  41      <tr class="top-bar">
  42          <td class="links">
  43              [ <a href="system_utils.php">Back to System Utilities</a> ]
  44              [ <a href="copy_field.php?source_id=<?php echo $f_source_field_id ?>&amp;dest_id=<?php echo $f_dest_field ?>">Refresh view</a> ]
  45          </td>
  46          <td class="title">
  47              Mantis Administration - Copy Custom Fields to Built-in
  48          </td>
  49      </tr>
  50  </table>
  51  <br /><br />
  52  
  53  <?php
  54      #checks on validity
  55      $t_valid_fields = array( 'fixed_in_version' );
  56      if ( ! in_array( $f_dest_field, $t_valid_fields ) ) {
  57          echo '<p>Invalid destination field (' . $f_dest_field . ') specified.</p>';
  58          echo '</body></html>';
  59          exit;
  60      }
  61      #@@@ check that source and destination are compatible
  62  
  63      $t_string_table = config_get_global( 'mantis_custom_field_string_table' );
  64      $t_bug_table = config_get_global( 'mantis_bug_table' );
  65      $query = 'SELECT * FROM ' . $t_string_table . ' WHERE field_id = ' . $f_source_field_id . ' and value <> \'\'';
  66  
  67      $result = @db_query( $query );
  68      if ( FALSE == $result ) {
  69          echo '<p>No fields need to be updated.</p>';
  70      } else {
  71  
  72          $count = db_num_rows( $result );
  73          echo '<p>Found ' . $count . ' fields to be updated.</p>';
  74          $t_failures = 0;
  75  
  76          if ( $count > 0 ) {
  77              echo '<table width="80%" bgcolor="#222222" border="0" cellpadding="10" cellspacing="1">';
  78              # Headings
  79              echo '<tr bgcolor="#ffffff"><th width="10%">Bug Id</th><th width="20%">Field Value</th><th width="70%">Status</th></tr>';
  80          }
  81  
  82          for ( $i=0 ; $i < $count ; $i++ ) {
  83              $row = db_fetch_array( $result );
  84              extract( $row, EXTR_PREFIX_ALL, 'v' );
  85  
  86              # trace bug id back to project
  87              $t_project_id = bug_get_field( $v_bug_id, 'project_id' );
  88              $t_cust_value = $v_value;
  89              printf("\n<tr %s><td><a href=\"../view.php?id=%d\">%07d</a></td><td>%s</td><td>",
  90                      helper_alternate_class(), $v_bug_id, $v_bug_id, $v_value);
  91  
  92              # validate field contents
  93              switch ( $f_dest_field ) {
  94                  case 'fixed_in_version':
  95                      $t_valid = ( version_get_id( $t_cust_value, $t_project_id ) == FALSE ) ? FALSE : TRUE;
  96                      break;
  97                  default:
  98                      $t_valid = FALSE;
  99              }
 100              if ( $t_valid ) {
 101                  # value was valid, update value
 102                  if ( ! bug_set_field( $v_bug_id, $f_dest_field, $t_cust_value ) ) {
 103                      echo 'database update failed';
 104                      $t_failures++;
 105                  } else {
 106                      echo 'applied';
 107                  }
 108              } else {
 109                  echo 'field value was not valid or previously defined';
 110                  $t_failures++;
 111              }
 112              echo '</td></tr>';
 113          }
 114  
 115          echo '</table><br />' . $count . ' fields processed, ' . $t_failures . ' failures';
 116      }
 117      echo '<p> Completed...<p>';
 118  ?>
 119  </body>
 120  </html>


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