| [ Index ] |
PHP Cross Reference of MantisBT |
[Summary view] [Print] [Text view]
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 * @package MantisBT 19 * @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org 20 * @copyright Copyright (C) 2002 - 2011 MantisBT Team - mantisbt-dev@lists.sourceforge.net 21 * @author Marcello Scata' <marcelloscata at users.sourceforge.net> ITALY 22 * @link http://www.mantisbt.org 23 * 24 * @uses core.php 25 * @uses access_api.php 26 * @uses bug_api.php 27 * @uses config_api.php 28 * @uses constant_inc.php 29 * @uses email_api.php 30 * @uses error_api.php 31 * @uses form_api.php 32 * @uses gpc_api.php 33 * @uses helper_api.php 34 * @uses history_api.php 35 * @uses lang_api.php 36 * @uses print_api.php 37 * @uses relationship_api.php 38 */ 39 40 /** 41 * MantisBT Core API's 42 */ 43 require_once ( 'core.php' ); 44 require_api( 'access_api.php' ); 45 require_api( 'bug_api.php' ); 46 require_api( 'config_api.php' ); 47 require_api( 'constant_inc.php' ); 48 require_api( 'email_api.php' ); 49 require_api( 'error_api.php' ); 50 require_api( 'form_api.php' ); 51 require_api( 'gpc_api.php' ); 52 require_api( 'helper_api.php' ); 53 require_api( 'history_api.php' ); 54 require_api( 'lang_api.php' ); 55 require_api( 'print_api.php' ); 56 require_api( 'relationship_api.php' ); 57 58 form_security_validate( 'bug_relationship_add' ); 59 60 $f_rel_type = gpc_get_int( 'rel_type' ); 61 $f_src_bug_id = gpc_get_int( 'src_bug_id' ); 62 $f_dest_bug_id_string = gpc_get_string( 'dest_bug_id' ); 63 64 # user has access to update the bug... 65 access_ensure_bug_level( config_get( 'update_bug_threshold' ), $f_src_bug_id ); 66 67 $f_dest_bug_id_string = str_replace( ',', '|', $f_dest_bug_id_string ); 68 69 $f_dest_bug_id_array = explode( '|', $f_dest_bug_id_string ); 70 71 foreach( $f_dest_bug_id_array as $f_dest_bug_id ) { 72 $f_dest_bug_id = (int)$f_dest_bug_id; 73 74 # source and destination bugs are the same bug... 75 if ( $f_src_bug_id == $f_dest_bug_id ) { 76 trigger_error( ERROR_RELATIONSHIP_SAME_BUG, ERROR ); 77 } 78 79 # the related bug exists... 80 bug_ensure_exists( $f_dest_bug_id ); 81 82 # bug is not read-only... 83 if ( bug_is_readonly( $f_src_bug_id ) ) { 84 error_parameters( $f_src_bug_id ); 85 trigger_error( ERROR_BUG_READ_ONLY_ACTION_DENIED, ERROR ); 86 } 87 88 # user can access to the related bug at least as viewer... 89 if ( !access_has_bug_level( VIEWER, $f_dest_bug_id ) ) { 90 error_parameters( $f_dest_bug_id ); 91 trigger_error( ERROR_RELATIONSHIP_ACCESS_LEVEL_TO_DEST_BUG_TOO_LOW, ERROR ); 92 } 93 94 $t_bug = bug_get( $f_src_bug_id, true ); 95 if( $t_bug->project_id != helper_get_current_project() ) { 96 # in case the current project is not the same project of the bug we are viewing... 97 # ... override the current project. This to avoid problems with categories and handlers lists etc. 98 $g_project_override = $t_bug->project_id; 99 } 100 101 # check if there is other relationship between the bugs... 102 $t_old_id_relationship = relationship_same_type_exists( $f_src_bug_id, $f_dest_bug_id, $f_rel_type ); 103 104 if ( $t_old_id_relationship == -1 ) { 105 # the relationship type is exactly the same of the new one. No sense to proceed 106 trigger_error( ERROR_RELATIONSHIP_ALREADY_EXISTS, ERROR ); 107 } 108 else if ( $t_old_id_relationship > 0 ) { 109 # there is already a relationship between them -> we have to update it and not to add a new one 110 helper_ensure_confirmed( lang_get( 'replace_relationship_sure_msg' ), lang_get( 'replace_relationship_button' ) ); 111 112 # Update the relationship 113 relationship_update( $t_old_id_relationship, $f_src_bug_id, $f_dest_bug_id, $f_rel_type ); 114 115 # Add log line to the history (both bugs) 116 history_log_event_special( $f_src_bug_id, BUG_REPLACE_RELATIONSHIP, $f_rel_type, $f_dest_bug_id ); 117 history_log_event_special( $f_dest_bug_id, BUG_REPLACE_RELATIONSHIP, relationship_get_complementary_type( $f_rel_type ), $f_src_bug_id ); 118 } else { 119 # Add the new relationship 120 relationship_add( $f_src_bug_id, $f_dest_bug_id, $f_rel_type ); 121 122 # Add log line to the history (both bugs) 123 history_log_event_special( $f_src_bug_id, BUG_ADD_RELATIONSHIP, $f_rel_type, $f_dest_bug_id ); 124 history_log_event_special( $f_dest_bug_id, BUG_ADD_RELATIONSHIP, relationship_get_complementary_type( $f_rel_type ), $f_src_bug_id ); 125 } 126 127 # update bug last updated for both bugs 128 bug_update_date( $f_src_bug_id ); 129 bug_update_date( $f_dest_bug_id ); 130 131 # send email notification to the users addressed by both the bugs 132 email_relationship_added( $f_src_bug_id, $f_dest_bug_id, $f_rel_type ); 133 email_relationship_added( $f_dest_bug_id, $f_src_bug_id, relationship_get_complementary_type( $f_rel_type ) ); 134 } 135 136 form_security_purge( 'bug_relationship_add' ); 137 138 print_header_redirect_view( $f_src_bug_id );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Jul 28 15:48:31 2011 | Cross-referenced by PHPXref 0.7 |