1<?php 2# MantisBT - A PHP based bugtracking system 3 4# MantisBT is free software: you can redistribute it and/or modify 5# it under the terms of the GNU General Public License as published by 6# the Free Software Foundation, either version 2 of the License, or 7# (at your option) any later version. 8# 9# MantisBT is distributed in the hope that it will be useful, 10# but WITHOUT ANY WARRANTY; without even the implied warranty of 11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12# GNU General Public License for more details. 13# 14# You should have received a copy of the GNU General Public License 15# along with MantisBT. If not, see <http://www.gnu.org/licenses/>. 16 17/** 18 * Add bug relationships 19 * 20 * @package MantisBT 21 * @copyright Copyright 2000 - 2002 Kenzaburo Ito - kenito@300baud.org 22 * @copyright Copyright 2002 MantisBT Team - mantisbt-dev@lists.sourceforge.net 23 * @author Marcello Scata' <marcelloscata at users.sourceforge.net> ITALY 24 * @link http://www.mantisbt.org 25 * 26 * @uses core.php 27 * @uses form_api.php 28 * @uses gpc_api.php 29 * @uses helper_api.php 30 * @uses history_api.php 31 * @uses lang_api.php 32 * @uses print_api.php 33 */ 34 35require_once( 'core.php' ); 36require_api( 'form_api.php' ); 37require_api( 'gpc_api.php' ); 38require_api( 'helper_api.php' ); 39require_api( 'history_api.php' ); 40require_api( 'lang_api.php' ); 41require_api( 'print_api.php' ); 42 43form_security_validate( 'bug_relationship_add' ); 44 45$f_rel_type = gpc_get_int( 'rel_type' ); 46$f_src_bug_id = gpc_get_int( 'src_bug_id' ); 47$f_dest_bug_id_string = gpc_get_string( 'dest_bug_id' ); 48 49$t_dest_bug_id_string = str_replace( ',', '|', $f_dest_bug_id_string ); 50$t_dest_bug_id_array = explode( '|', $t_dest_bug_id_string ); 51 52foreach( $t_dest_bug_id_array as $t_dest_bug_id ) { 53 # Skip empty bug ids and ignore source bug when processing multiple targets 54 if( count( $t_dest_bug_id_array ) > 1 55 && ( is_blank( $t_dest_bug_id ) || $f_src_bug_id == $t_dest_bug_id ) 56 ) { 57 continue; 58 } 59 60 $t_data = array( 61 'query' => array( 'issue_id' => $f_src_bug_id ), 62 'payload' => array( 63 'type' => array( 'id' => $f_rel_type ), 64 'issue' => array( 'id' => $t_dest_bug_id ) 65 ) 66 ); 67 68 $t_command = new IssueRelationshipAddCommand( $t_data ); 69 $t_command->execute(); 70} 71 72form_security_purge( 'bug_relationship_add' ); 73 74print_header_redirect_view( $f_src_bug_id ); 75