[ 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_relationship_delete.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_relationship_delete.php,v 1.10.14.1 2007-10-13 22:32:46 giallu Exp $
  22      # --------------------------------------------------------
  23  
  24      # ======================================================================
  25      # Author: Marcello Scata' <marcelloscata at users.sourceforge.net> ITALY
  26      # ======================================================================
  27      # To delete a relationship we need to ensure that:
  28      # - User not anomymous
  29      # - Source bug exists and is not in read-only state (peer bug could not exist...)
  30      # - User that update the source bug and at least view the destination bug
  31      # - Relationship must exist
  32      # ----------------------------------------------------------------------
  33  
  34      require_once ( 'core.php' );
  35  
  36      $t_core_path = config_get( 'core_path' );
  37      require_once( $t_core_path . 'relationship_api.php' );
  38  
  39      $f_rel_id = gpc_get_int( 'rel_id' );
  40      $f_bug_id = gpc_get_int( 'bug_id' );
  41  
  42      # user has access to update the bug...
  43      access_ensure_bug_level( config_get( 'update_bug_threshold' ), $f_bug_id );
  44  
  45      # bug is not read-only...
  46      if ( bug_is_readonly( $f_bug_id ) ) {
  47          error_parameters( $f_bug_id );
  48          trigger_error( ERROR_BUG_READ_ONLY_ACTION_DENIED, ERROR );
  49      }
  50  
  51      $t_bug = bug_get( $f_bug_id, true );
  52      if( $t_bug->project_id != helper_get_current_project() ) {
  53          # in case the current project is not the same project of the bug we are viewing...
  54          # ... override the current project. This to avoid problems with categories and handlers lists etc.
  55          $g_project_override = $t_bug->project_id;
  56      }
  57  
  58      # retrieve the destination bug of the relationship
  59      $t_dest_bug_id = relationship_get_linked_bug_id( $f_rel_id, $f_bug_id );
  60  
  61      # user can access to the related bug at least as viewer, if it's exist...
  62      if ( bug_exists( $t_dest_bug_id )) {
  63          if ( !access_has_bug_level( VIEWER, $t_dest_bug_id ) ) {
  64              error_parameters( $t_dest_bug_id );
  65              trigger_error( ERROR_RELATIONSHIP_ACCESS_LEVEL_TO_DEST_BUG_TOO_LOW, ERROR );
  66          }
  67      }
  68  
  69      helper_ensure_confirmed( lang_get( 'delete_relationship_sure_msg' ), lang_get( 'delete_relationship_button' ) );
  70  
  71      $t_bug_relationship_data = relationship_get( $f_rel_id );
  72      $t_rel_type = $t_bug_relationship_data->type;
  73  
  74      # delete relationship from the DB
  75      relationship_delete( $f_rel_id );
  76  
  77      # update bug last updated (just for the src bug)
  78      bug_update_date( $f_bug_id );
  79  
  80      # set the rel_type for both bug and dest_bug based on $t_rel_type and on who is the dest bug
  81      if ($f_bug_id == $t_bug_relationship_data->src_bug_id) {
  82          $t_bug_rel_type = $t_rel_type;
  83          $t_dest_bug_rel_type = relationship_get_complementary_type( $t_rel_type );
  84      }
  85      else {
  86          $t_bug_rel_type = relationship_get_complementary_type( $t_rel_type );
  87          $t_dest_bug_rel_type = $t_rel_type;
  88      }
  89  
  90      # send email and update the history for the src issue
  91      history_log_event_special( $f_bug_id, BUG_DEL_RELATIONSHIP, $t_bug_rel_type, $t_dest_bug_id );
  92      email_relationship_deleted( $f_bug_id, $t_dest_bug_id, $t_bug_rel_type );
  93  
  94      if ( bug_exists( $t_dest_bug_id )) {
  95          # send email and update the history for the dest issue
  96          history_log_event_special( $t_dest_bug_id, BUG_DEL_RELATIONSHIP, $t_dest_bug_rel_type, $f_bug_id );
  97          email_relationship_deleted( $t_dest_bug_id, $f_bug_id, $t_dest_bug_rel_type );
  98      }
  99  
 100      print_header_redirect_view( $f_bug_id );
 101  ?>


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