[ 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_add.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_add.php,v 1.7.4.1 2007-10-13 22:32:44 giallu Exp $
  22      # --------------------------------------------------------
  23  
  24      # ======================================================================
  25      # Author: Marcello Scata' <marcelloscata at users.sourceforge.net> ITALY
  26      # ======================================================================
  27  
  28      require_once ( 'core.php' );
  29      $t_core_path = config_get( 'core_path' );
  30      require_once( $t_core_path . 'relationship_api.php' );
  31  
  32      $f_rel_type = gpc_get_int( 'rel_type' );
  33      $f_src_bug_id = gpc_get_int( 'src_bug_id' );
  34      $f_dest_bug_id_string = gpc_get_string( 'dest_bug_id' );
  35  
  36      # user has access to update the bug...
  37      access_ensure_bug_level( config_get( 'update_bug_threshold' ), $f_src_bug_id );
  38  
  39      $f_dest_bug_id_string = str_replace( ',', '|', $f_dest_bug_id_string );
  40  
  41      $f_dest_bug_id_array = explode( '|', $f_dest_bug_id_string );
  42  
  43      foreach( $f_dest_bug_id_array as $f_dest_bug_id ) {
  44          $f_dest_bug_id = (int)$f_dest_bug_id;
  45  
  46          # source and destination bugs are the same bug...
  47          if ( $f_src_bug_id == $f_dest_bug_id ) {
  48              trigger_error( ERROR_RELATIONSHIP_SAME_BUG, ERROR );
  49          }
  50  
  51          # the related bug exists...
  52          bug_ensure_exists( $f_dest_bug_id );
  53  
  54          # bug is not read-only...
  55          if ( bug_is_readonly( $f_src_bug_id ) ) {
  56              error_parameters( $f_src_bug_id );
  57              trigger_error( ERROR_BUG_READ_ONLY_ACTION_DENIED, ERROR );
  58          }
  59  
  60          # user can access to the related bug at least as viewer...
  61          if ( !access_has_bug_level( VIEWER, $f_dest_bug_id ) ) {
  62              error_parameters( $f_dest_bug_id );
  63              trigger_error( ERROR_RELATIONSHIP_ACCESS_LEVEL_TO_DEST_BUG_TOO_LOW, ERROR );
  64          }
  65  
  66          $t_bug = bug_get( $f_src_bug_id, true );
  67          if( $t_bug->project_id != helper_get_current_project() ) {
  68              # in case the current project is not the same project of the bug we are viewing...
  69              # ... override the current project. This to avoid problems with categories and handlers lists etc.
  70              $g_project_override = $t_bug->project_id;
  71          }
  72  
  73          # check if there is other relationship between the bugs...
  74          $t_old_id_relationship = relationship_same_type_exists( $f_src_bug_id, $f_dest_bug_id, $f_rel_type );
  75  
  76          if ( $t_old_id_relationship == -1 ) {
  77              # the relationship type is exactly the same of the new one. No sense to proceed
  78              trigger_error( ERROR_RELATIONSHIP_ALREADY_EXISTS, ERROR );
  79          }
  80          else if ( $t_old_id_relationship > 0 ) {
  81              # there is already a relationship between them -> we have to update it and not to add a new one
  82              helper_ensure_confirmed( lang_get( 'replace_relationship_sure_msg' ), lang_get( 'replace_relationship_button' ) );
  83  
  84              # Update the relationship
  85              relationship_update( $t_old_id_relationship, $f_src_bug_id, $f_dest_bug_id, $f_rel_type );
  86  
  87              # Add log line to the history (both bugs)
  88              history_log_event_special( $f_src_bug_id, BUG_REPLACE_RELATIONSHIP, $f_rel_type, $f_dest_bug_id );
  89              history_log_event_special( $f_dest_bug_id, BUG_REPLACE_RELATIONSHIP, relationship_get_complementary_type( $f_rel_type ), $f_src_bug_id );
  90          }
  91          else {
  92              # Add the new relationship
  93              relationship_add( $f_src_bug_id, $f_dest_bug_id, $f_rel_type );
  94  
  95              # Add log line to the history (both bugs)
  96              history_log_event_special( $f_src_bug_id, BUG_ADD_RELATIONSHIP, $f_rel_type, $f_dest_bug_id );
  97              history_log_event_special( $f_dest_bug_id, BUG_ADD_RELATIONSHIP, relationship_get_complementary_type( $f_rel_type ), $f_src_bug_id );
  98          }
  99  
 100          # update bug last updated (just for the src bug)
 101          bug_update_date( $f_src_bug_id );
 102  
 103          # send email notification to the users addressed by both the bugs
 104          email_relationship_added( $f_src_bug_id, $f_dest_bug_id, $f_rel_type );
 105          email_relationship_added( $f_dest_bug_id, $f_src_bug_id, relationship_get_complementary_type( $f_rel_type ) );
 106      }
 107  
 108      print_header_redirect_view( $f_src_bug_id );
 109  ?>


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