[ Index ]
 

Code source de Mantis 1.1.0rc3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/ -> bug_actiongroup.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: bug_actiongroup.php,v 1.52.2.1 2007-10-13 22:32:30 giallu Exp $
  22      # --------------------------------------------------------
  23  ?>
  24  <?php
  25      # This page allows actions to be performed an an array of bugs
  26  ?>
  27  <?php
  28      require_once ( 'core.php' );
  29  
  30      $t_core_path = config_get( 'core_path' );
  31  
  32      require_once( $t_core_path.'bug_api.php' );
  33  ?>
  34  <?php auth_ensure_user_authenticated() ?>
  35  <?php
  36      helper_begin_long_process();
  37  
  38      $f_action    = gpc_get_string( 'action' );
  39      $f_custom_field_id = gpc_get_int( 'custom_field_id', 0 );
  40      $f_bug_arr    = gpc_get_int_array( 'bug_arr', array() );
  41  
  42      $t_custom_group_actions = config_get( 'custom_group_actions' );
  43  
  44      foreach( $t_custom_group_actions as $t_custom_group_action ) {
  45          if ( $f_action == $t_custom_group_action['action'] ) {
  46              require_once( $t_custom_group_action['action_page'] );
  47              exit;
  48          }
  49      }
  50  
  51      $t_failed_ids = array();
  52  
  53      if ( 0 != $f_custom_field_id ) {
  54          $t_custom_field_def = custom_field_get_definition( $f_custom_field_id );
  55      }
  56  
  57      foreach( $f_bug_arr as $t_bug_id ) {
  58          bug_ensure_exists( $t_bug_id );
  59          $t_bug = bug_get( $t_bug_id, true );
  60  
  61          if( $t_bug->project_id != helper_get_current_project() ) {
  62              # in case the current project is not the same project of the bug we are viewing...
  63              # ... override the current project. This to avoid problems with categories and handlers lists etc.
  64              $g_project_override = $t_bug->project_id;
  65              # @@@ (thraxisp) the next line goes away if the cache was smarter and used project
  66              config_flush_cache(); # flush the config cache so that configs are refetched
  67          }
  68  
  69          $t_status = $t_bug->status;
  70  
  71          switch ( $f_action ) {
  72  
  73          case 'CLOSE':
  74              if ( access_can_close_bug( $t_bug_id ) &&
  75                      ( $t_status < CLOSED ) &&
  76                      bug_check_workflow($t_status, CLOSED) ) {
  77  
  78                  # @@@ we need to issue a helper_call_custom_function( 'issue_update_validate', array( $f_bug_id, $t_bug_data, $f_bugnote_text ) );
  79                  bug_close( $t_bug_id );
  80                  helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
  81              } else {
  82                  if ( ! access_can_close_bug( $t_bug_id ) ) {
  83                      $t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
  84                  } else {
  85                      $t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_status' );
  86                  }
  87              }
  88              break;
  89  
  90          case 'DELETE':
  91              if ( access_has_bug_level( config_get( 'delete_bug_threshold' ), $t_bug_id ) ) {
  92                  bug_delete( $t_bug_id );
  93              } else {
  94                  $t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
  95              }
  96              break;
  97  
  98          case 'MOVE':
  99              if ( access_has_bug_level( config_get( 'move_bug_threshold' ), $t_bug_id ) ) {
 100                  # @@@ we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) );
 101                  $f_project_id = gpc_get_int( 'project_id' );
 102                  bug_set_field( $t_bug_id, 'project_id', $f_project_id );
 103                  helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
 104              } else {
 105                  $t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
 106              }
 107              break;
 108  
 109          case 'COPY':
 110              $f_project_id = gpc_get_int( 'project_id' );
 111  
 112              if ( access_has_project_level( config_get( 'report_bug_threshold' ), $f_project_id ) ) {
 113                  bug_copy( $t_bug_id, $f_project_id, true, true, true, true, true, true );
 114              } else {
 115                  $t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
 116              }
 117              break;
 118  
 119          case 'ASSIGN':
 120              $f_assign = gpc_get_int( 'assign' );
 121              if ( ON == config_get( 'auto_set_status_to_assigned' ) ) {
 122                  $t_assign_status = config_get( 'bug_assigned_status' );
 123              } else {
 124                  $t_assign_status = $t_status;
 125              }
 126              # check that new handler has rights to handle the issue, and
 127              #  that current user has rights to assign the issue
 128              $t_threshold = access_get_status_threshold( $t_assign_status, bug_get_field( $t_bug_id, 'project_id' ) );
 129              if ( access_has_bug_level( $t_threshold , $t_bug_id, $f_assign ) &&
 130                   access_has_bug_level( config_get( 'update_bug_assign_threshold', config_get( 'update_bug_threshold' ) ), $t_bug_id ) &&
 131                      bug_check_workflow($t_status, $t_assign_status )    ) {
 132                  # @@@ we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) );
 133                  bug_assign( $t_bug_id, $f_assign );
 134                  helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
 135              } else {
 136                  if ( bug_check_workflow($t_status, $t_assign_status ) ) {
 137                      $t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
 138                  } else {
 139                      $t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_status' );
 140                  }
 141              }
 142              break;
 143  
 144          case 'RESOLVE':
 145              $t_resolved_status = config_get( 'bug_resolved_status_threshold' );
 146              if ( access_has_bug_level( access_get_status_threshold( $t_resolved_status, bug_get_field( $t_bug_id, 'project_id' ) ), $t_bug_id ) &&
 147                           ( $t_status < $t_resolved_status ) &&
 148                          bug_check_workflow($t_status, $t_resolved_status ) ) {
 149                  $f_resolution = gpc_get_int( 'resolution' );
 150                  $f_fixed_in_version = gpc_get_string( 'fixed_in_version', '' );
 151                  # @@@ we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) );
 152                  bug_resolve( $t_bug_id, $f_resolution, $f_fixed_in_version );
 153                  helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
 154              } else {
 155                  if ( ( $t_status < $t_resolved_status ) &&
 156                          bug_check_workflow($t_status, $t_resolved_status ) ) {
 157                      $t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
 158                  } else {
 159                      $t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_status' );
 160                  }
 161              }
 162              break;
 163  
 164          case 'UP_PRIOR':
 165              if ( access_has_bug_level( config_get( 'update_bug_threshold' ), $t_bug_id ) ) {
 166                  $f_priority = gpc_get_int( 'priority' );
 167                  # @@@ we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) );
 168                  bug_set_field( $t_bug_id, 'priority', $f_priority );
 169                  helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
 170              } else {
 171                  $t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
 172              }
 173              break;
 174  
 175          case 'UP_STATUS':
 176              $f_status = gpc_get_int( 'status' );
 177              $t_project = bug_get_field( $t_bug_id, 'project_id' );
 178              if ( access_has_bug_level( access_get_status_threshold( $f_status, $t_project ), $t_bug_id ) ) {
 179                  if ( TRUE == bug_check_workflow($t_status, $f_status ) ) {
 180                      # @@@ we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) );
 181                      bug_set_field( $t_bug_id, 'status', $f_status );
 182                      helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
 183                  } else {
 184                      $t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_status' );
 185                  }
 186              } else {
 187                  $t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
 188              }
 189              break;
 190  
 191          case 'UP_CATEGORY':
 192              $f_category = gpc_get_string( 'category' );
 193              $t_project = bug_get_field( $t_bug_id, 'project_id' );
 194              if ( access_has_bug_level( config_get( 'update_bug_threshold' ), $t_bug_id ) ) {
 195                  if ( category_exists( $t_project, $f_category ) ) {
 196                      # @@@ we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) );
 197                      bug_set_field( $t_bug_id, 'category', $f_category );
 198                      helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
 199                  } else {
 200                      $t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_category' );
 201                  }
 202              } else {
 203                  $t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
 204              }
 205              break;
 206          
 207          case 'UP_FIXED_IN_VERSION':
 208              $f_fixed_in_version = gpc_get_string( 'fixed_in_version' );
 209              $t_project_id = bug_get_field( $t_bug_id, 'project_id' );
 210              $t_success = false;
 211  
 212              if ( access_has_bug_level( config_get( 'update_bug_threshold' ), $t_bug_id ) ) {
 213                  if ( version_get_id( $f_fixed_in_version, $t_project_id ) !== false ) {
 214                      # @@@ we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) );
 215                      bug_set_field( $t_bug_id, 'fixed_in_version', $f_fixed_in_version );
 216                      helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
 217                      $t_success = true;
 218                  }
 219              }
 220  
 221              if ( !$t_success ) {
 222                  $t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
 223              }
 224              break;
 225  
 226          case 'UP_TARGET_VERSION':
 227              $f_target_version = gpc_get_string( 'target_version' );
 228              $t_project_id = bug_get_field( $t_bug_id, 'project_id' );
 229              $t_success = false;
 230  
 231              if ( access_has_bug_level( config_get( 'roadmap_update_threshold' ), $t_bug_id ) ) {
 232                  if ( version_get_id( $f_target_version, $t_project_id ) !== false ) {
 233                      # @@@ we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) );
 234                      bug_set_field( $t_bug_id, 'target_version', $f_target_version );
 235                      helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
 236                      $t_success = true;
 237                  }
 238              }
 239  
 240              if ( !$t_success ) {
 241                  $t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
 242              }
 243              break;
 244  
 245          case 'VIEW_STATUS':
 246              if ( access_has_bug_level( config_get( 'change_view_status_threshold' ), $t_bug_id ) ) {
 247                  $f_view_status = gpc_get_int( 'view_status' );
 248                  # @@@ we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) );
 249                  bug_set_field( $t_bug_id, 'view_state', $f_view_status );
 250                  helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
 251              } else {
 252                  $t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
 253              }
 254              break;
 255  
 256          case 'SET_STICKY':
 257              if ( access_has_bug_level( config_get( 'set_bug_sticky_threshold' ), $t_bug_id ) ) {
 258                  $f_sticky = bug_get_field( $t_bug_id, 'sticky' );
 259                  // The new value is the inverted old value
 260                  # @@@ we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) );
 261                  bug_set_field( $t_bug_id, 'sticky', intval( !$f_sticky ) );
 262                  helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
 263              } else {
 264                  $t_failed_ids[$t_bug_id] = lang_get( 'bug_actiongroup_access' );
 265              }
 266              break;
 267  
 268          case 'CUSTOM':
 269              if ( 0 === $f_custom_field_id ) {
 270                  trigger_error( ERROR_GENERIC, ERROR );
 271              }
 272  
 273              # @@@ we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) );
 274              $t_form_var = "custom_field_$f_custom_field_id";
 275              $t_custom_field_value = gpc_get_custom_field( $t_form_var, $t_custom_field_def['type'], null );
 276              custom_field_set_value( $f_custom_field_id, $t_bug_id, $t_custom_field_value );
 277              helper_call_custom_function( 'issue_update_notify', array( $t_bug_id ) );
 278              break;
 279  
 280          default:
 281              trigger_error( ERROR_GENERIC, ERROR );
 282          }
 283      }
 284  
 285      $t_redirect_url = 'view_all_bug_page.php';
 286  
 287      if ( count( $t_failed_ids ) > 0 ) {
 288          html_page_top1();
 289          html_page_top2();
 290  
 291          echo '<div align="center"><br />';
 292          echo '<table class="width75">';
 293          foreach( $t_failed_ids as $t_id => $t_reason ) {
 294              printf( "<tr><td width=\"50%%\">%s: %s</td><td>%s</td></tr>\n", string_get_bug_view_link( $t_id ), bug_get_field( $t_id, 'summary' ), $t_reason );
 295          }
 296          echo '</table><br />';
 297          print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
 298          echo '</div>';
 299  
 300          html_page_bottom1( __FILE__ );
 301      } else {
 302          print_header_redirect( $t_redirect_url );
 303      }
 304  ?>


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