[ Index ] |
|
Code source de Mantis 1.1.0rc3 |
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_update.php,v 1.91.2.3 2007-10-26 08:52:18 giallu Exp $ 22 # -------------------------------------------------------- 23 ?> 24 <?php 25 # Update bug data then redirect to the appropriate viewing page 26 ?> 27 <?php 28 require_once ( 'core.php' ); 29 30 $t_core_path = config_get( 'core_path' ); 31 32 require_once( $t_core_path.'bug_api.php' ); 33 require_once( $t_core_path.'bugnote_api.php' ); 34 require_once( $t_core_path.'custom_field_api.php' ); 35 ?> 36 <?php 37 $f_bug_id = gpc_get_int( 'bug_id' ); 38 $f_update_mode = gpc_get_bool( 'update_mode', FALSE ); # set if called from generic update page 39 $f_new_status = gpc_get_int( 'status', bug_get_field( $f_bug_id, 'status' ) ); 40 41 $t_bug_data = bug_get( $f_bug_id, true ); 42 if( $t_bug_data->project_id != helper_get_current_project() ) { 43 # in case the current project is not the same project of the bug we are viewing... 44 # ... override the current project. This to avoid problems with categories and handlers lists etc. 45 $g_project_override = $t_bug_data->project_id; 46 } 47 48 if ( ! ( 49 ( access_has_bug_level( access_get_status_threshold( $f_new_status, bug_get_field( $f_bug_id, 'project_id' ) ), $f_bug_id ) ) || 50 ( access_has_bug_level( config_get( 'update_bug_threshold' ) , $f_bug_id ) ) || 51 ( ( bug_get_field( $f_bug_id, 'reporter_id' ) == auth_get_current_user_id() ) && 52 ( ( ON == config_get( 'allow_reporter_reopen' ) ) || 53 ( ON == config_get( 'allow_reporter_close' ) ) ) ) 54 ) ) { 55 access_denied(); 56 } 57 58 # extract current extended information 59 $t_old_bug_status = $t_bug_data->status; 60 61 $t_bug_data->reporter_id = gpc_get_int( 'reporter_id', $t_bug_data->reporter_id ); 62 $t_bug_data->handler_id = gpc_get_int( 'handler_id', $t_bug_data->handler_id ); 63 $t_bug_data->duplicate_id = gpc_get_int( 'duplicate_id', $t_bug_data->duplicate_id ); 64 $t_bug_data->priority = gpc_get_int( 'priority', $t_bug_data->priority ); 65 $t_bug_data->severity = gpc_get_int( 'severity', $t_bug_data->severity ); 66 $t_bug_data->reproducibility = gpc_get_int( 'reproducibility', $t_bug_data->reproducibility ); 67 $t_bug_data->status = gpc_get_int( 'status', $t_bug_data->status ); 68 $t_bug_data->resolution = gpc_get_int( 'resolution', $t_bug_data->resolution ); 69 $t_bug_data->projection = gpc_get_int( 'projection', $t_bug_data->projection ); 70 $t_bug_data->category = gpc_get_string( 'category', $t_bug_data->category ); 71 $t_bug_data->eta = gpc_get_int( 'eta', $t_bug_data->eta ); 72 $t_bug_data->os = gpc_get_string( 'os', $t_bug_data->os ); 73 $t_bug_data->os_build = gpc_get_string( 'os_build', $t_bug_data->os_build ); 74 $t_bug_data->platform = gpc_get_string( 'platform', $t_bug_data->platform ); 75 $t_bug_data->version = gpc_get_string( 'version', $t_bug_data->version ); 76 $t_bug_data->build = gpc_get_string( 'build', $t_bug_data->build ); 77 $t_bug_data->fixed_in_version = gpc_get_string( 'fixed_in_version', $t_bug_data->fixed_in_version ); 78 $t_bug_data->target_version = gpc_get_string( 'target_version', $t_bug_data->target_version ); 79 $t_bug_data->view_state = gpc_get_int( 'view_state', $t_bug_data->view_state ); 80 $t_bug_data->summary = gpc_get_string( 'summary', $t_bug_data->summary ); 81 82 $t_bug_data->description = gpc_get_string( 'description', $t_bug_data->description ); 83 $t_bug_data->steps_to_reproduce = gpc_get_string( 'steps_to_reproduce', $t_bug_data->steps_to_reproduce ); 84 $t_bug_data->additional_information = gpc_get_string( 'additional_information', $t_bug_data->additional_information ); 85 86 $f_private = gpc_get_bool( 'private' ); 87 $f_bugnote_text = gpc_get_string( 'bugnote_text', '' ); 88 $f_time_tracking = gpc_get_string( 'time_tracking', '0:00' ); 89 $f_close_now = gpc_get_string( 'close_now', false ); 90 91 # Handle auto-assigning 92 if ( ( NEW_ == $t_bug_data->status ) 93 && ( 0 != $t_bug_data->handler_id ) 94 && ( ON == config_get( 'auto_set_status_to_assigned' ) ) ) { 95 $t_bug_data->status = config_get( 'bug_assigned_status' ); 96 } 97 98 helper_call_custom_function( 'issue_update_validate', array( $f_bug_id, $t_bug_data, $f_bugnote_text ) ); 99 100 $t_resolved = config_get( 'bug_resolved_status_threshold' ); 101 102 $t_custom_status_label = "update"; # default info to check 103 if ( $t_bug_data->status == $t_resolved ) { 104 $t_custom_status_label = "resolved"; 105 } 106 if ( $t_bug_data->status == CLOSED ) { 107 $t_custom_status_label = "closed"; 108 } 109 110 $t_related_custom_field_ids = custom_field_get_linked_ids( $t_bug_data->project_id ); 111 foreach( $t_related_custom_field_ids as $t_id ) { 112 $t_def = custom_field_get_definition( $t_id ); 113 $t_custom_field_value = gpc_get_custom_field( "custom_field_$t_id", $t_def['type'], null ); 114 115 # Only update the field if it would have been display for editing 116 if( !( ( ! $f_update_mode && $t_def['require_' . $t_custom_status_label] ) || 117 ( ! $f_update_mode && $t_def['display_' . $t_custom_status_label] && in_array( $t_custom_status_label, array( "resolved", "closed" ) ) ) || 118 ( $f_update_mode && $t_def['display_update'] ) || 119 ( $f_update_mode && $t_def['require_update'] ) ) ) { 120 continue; 121 } 122 123 # Only update the field if it is posted 124 # ( will fail in custom_field_set_value(), if it was required ) 125 if ( $t_custom_field_value === null ) { 126 continue; 127 } 128 129 # Do not set custom field value if user has no write access. 130 if( !custom_field_has_write_access( $t_id, $f_bug_id ) ) { 131 continue; 132 } 133 134 if ( $t_def['require_' . $t_custom_status_label] && ( gpc_get_custom_field( "custom_field_$t_id", $t_def['type'], '' ) == '' ) ) { 135 error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) ); 136 trigger_error( ERROR_EMPTY_FIELD, ERROR ); 137 } 138 if ( !custom_field_set_value( $t_id, $f_bug_id, $t_custom_field_value ) ) { 139 error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) ); 140 trigger_error( ERROR_CUSTOM_FIELD_INVALID_VALUE, ERROR ); 141 } 142 } 143 144 $t_notify = true; 145 $t_bug_note_set = false; 146 if ( ( $t_old_bug_status != $t_bug_data->status ) && ( FALSE == $f_update_mode ) ) { 147 # handle status transitions that come from pages other than bug_*update_page.php 148 # this does the minimum to act on the bug and sends a specific message 149 switch ( $t_bug_data->status ) { 150 case $t_resolved: 151 # bug_resolve updates the status, fixed_in_version, resolution, handler_id and bugnote and sends message 152 bug_resolve( $f_bug_id, $t_bug_data->resolution, $t_bug_data->fixed_in_version, 153 $f_bugnote_text, $t_bug_data->duplicate_id, $t_bug_data->handler_id, 154 $f_private, $f_time_tracking ); 155 $t_notify = false; 156 $t_bug_note_set = true; 157 158 if ( $f_close_now ) { 159 bug_set_field( $f_bug_id, 'status', CLOSED ); 160 } 161 162 // update bug data with fields that may be updated inside bug_resolve(), otherwise changes will be overwritten 163 // in bug_update() call below. 164 $t_bug_data->handler_id = bug_get_field( $f_bug_id, 'handler_id' ); 165 $t_bug_data->status = bug_get_field( $f_bug_id, 'status' ); 166 break; 167 168 case CLOSED: 169 # bug_close updates the status and bugnote and sends message 170 bug_close( $f_bug_id, $f_bugnote_text, $f_private, $f_time_tracking ); 171 $t_notify = false; 172 $t_bug_note_set = true; 173 break; 174 175 case config_get( 'bug_reopen_status' ): 176 if ( $t_old_bug_status >= $t_resolved ) { 177 bug_set_field( $f_bug_id, 'handler_id', $t_bug_data->handler_id ); # fix: update handler_id before calling bug_reopen 178 # bug_reopen updates the status and bugnote and sends message 179 bug_reopen( $f_bug_id, $f_bugnote_text, $f_time_tracking, $f_private ); 180 $t_notify = false; 181 $t_bug_note_set = true; 182 183 // update bug data with fields that may be updated inside bug_resolve(), otherwise changes will be overwritten 184 // in bug_update() call below. 185 $t_bug_data->status = bug_get_field( $f_bug_id, 'status' ); 186 $t_bug_data->resolution = bug_get_field( $f_bug_id, 'resolution' ); 187 break; 188 } # else fall through to default 189 } 190 } 191 192 # Add a bugnote if there is one 193 if ( ( !is_blank( $f_bugnote_text ) ) && ( false == $t_bug_note_set ) ) { 194 bugnote_add( $f_bug_id, $f_bugnote_text, $f_time_tracking, $f_private ); 195 } 196 197 # Update the bug entry, notify if we haven't done so already 198 bug_update( $f_bug_id, $t_bug_data, true, ( false == $t_notify ) ); 199 200 helper_call_custom_function( 'issue_update_notify', array( $f_bug_id ) ); 201 202 print_successful_redirect_to_bug( $f_bug_id ); 203 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Thu Nov 29 09:42:17 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |