| [ 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 * To delete a relationship we need to ensure that: 19 * - User not anomymous 20 * - Source bug exists and is not in read-only state (peer bug could not exist...) 21 * - User that update the source bug and at least view the destination bug 22 * - Relationship must exist 23 * 24 * @package MantisBT 25 * @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org 26 * @copyright Copyright (C) 2002 - 2010 MantisBT Team - mantisbt-dev@lists.sourceforge.net 27 * @author Marcello Scata' <marcelloscata at users.sourceforge.net> ITALY 28 * @link http://www.mantisbt.org 29 * 30 * @uses core.php 31 * @uses access_api.php 32 * @uses bug_api.php 33 * @uses config_api.php 34 * @uses constant_inc.php 35 * @uses email_api.php 36 * @uses error_api.php 37 * @uses form_api.php 38 * @uses gpc_api.php 39 * @uses helper_api.php 40 * @uses history_api.php 41 * @uses lang_api.php 42 * @uses print_api.php 43 * @uses relationship_api.php 44 */ 45 46 /** 47 * MantisBT Core API's 48 */ 49 require_once ( 'core.php' ); 50 require_api( 'access_api.php' ); 51 require_api( 'bug_api.php' ); 52 require_api( 'config_api.php' ); 53 require_api( 'constant_inc.php' ); 54 require_api( 'email_api.php' ); 55 require_api( 'error_api.php' ); 56 require_api( 'form_api.php' ); 57 require_api( 'gpc_api.php' ); 58 require_api( 'helper_api.php' ); 59 require_api( 'history_api.php' ); 60 require_api( 'lang_api.php' ); 61 require_api( 'print_api.php' ); 62 require_api( 'relationship_api.php' ); 63 64 form_security_validate( 'bug_relationship_delete' ); 65 66 $f_rel_id = gpc_get_int( 'rel_id' ); 67 $f_bug_id = gpc_get_int( 'bug_id' ); 68 69 $t_bug = bug_get( $f_bug_id, true ); 70 if( $t_bug->project_id != helper_get_current_project() ) { 71 # in case the current project is not the same project of the bug we are viewing... 72 # ... override the current project. This to avoid problems with categories and handlers lists etc. 73 $g_project_override = $t_bug->project_id; 74 } 75 76 # user has access to update the bug... 77 access_ensure_bug_level( config_get( 'update_bug_threshold' ), $f_bug_id ); 78 79 # bug is not read-only... 80 if ( bug_is_readonly( $f_bug_id ) ) { 81 error_parameters( $f_bug_id ); 82 trigger_error( ERROR_BUG_READ_ONLY_ACTION_DENIED, ERROR ); 83 } 84 85 # retrieve the destination bug of the relationship 86 $t_dest_bug_id = relationship_get_linked_bug_id( $f_rel_id, $f_bug_id ); 87 88 # user can access to the related bug at least as viewer, if it's exist... 89 if ( bug_exists( $t_dest_bug_id )) { 90 if ( !access_has_bug_level( VIEWER, $t_dest_bug_id ) ) { 91 error_parameters( $t_dest_bug_id ); 92 trigger_error( ERROR_RELATIONSHIP_ACCESS_LEVEL_TO_DEST_BUG_TOO_LOW, ERROR ); 93 } 94 } 95 96 helper_ensure_confirmed( lang_get( 'delete_relationship_sure_msg' ), lang_get( 'delete_relationship_button' ) ); 97 98 $t_bug_relationship_data = relationship_get( $f_rel_id ); 99 $t_rel_type = $t_bug_relationship_data->type; 100 101 # delete relationship from the DB 102 relationship_delete( $f_rel_id ); 103 104 # update bug last updated (just for the src bug) 105 bug_update_date( $f_bug_id ); 106 107 # set the rel_type for both bug and dest_bug based on $t_rel_type and on who is the dest bug 108 if ($f_bug_id == $t_bug_relationship_data->src_bug_id) { 109 $t_bug_rel_type = $t_rel_type; 110 $t_dest_bug_rel_type = relationship_get_complementary_type( $t_rel_type ); 111 } else { 112 $t_bug_rel_type = relationship_get_complementary_type( $t_rel_type ); 113 $t_dest_bug_rel_type = $t_rel_type; 114 } 115 116 # send email and update the history for the src issue 117 history_log_event_special( $f_bug_id, BUG_DEL_RELATIONSHIP, $t_bug_rel_type, $t_dest_bug_id ); 118 email_relationship_deleted( $f_bug_id, $t_dest_bug_id, $t_bug_rel_type ); 119 120 if ( bug_exists( $t_dest_bug_id )) { 121 # send email and update the history for the dest issue 122 history_log_event_special( $t_dest_bug_id, BUG_DEL_RELATIONSHIP, $t_dest_bug_rel_type, $f_bug_id ); 123 email_relationship_deleted( $t_dest_bug_id, $f_bug_id, $t_dest_bug_rel_type ); 124 } 125 126 form_security_purge( 'bug_relationship_delete' ); 127 128 print_header_redirect_view( $f_bug_id );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Tue Sep 7 20:21:43 2010 | Cross-referenced by PHPXref 0.7 |