[ 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_report.php,v 1.49.2.1 2007-10-13 22:32:51 giallu Exp $ 22 # -------------------------------------------------------- 23 24 # This page stores the reported bug 25 26 require_once ( 'core.php' ); 27 28 $t_core_path = config_get( 'core_path' ); 29 30 require_once( $t_core_path.'string_api.php' ); 31 require_once( $t_core_path.'file_api.php' ); 32 require_once( $t_core_path.'bug_api.php' ); 33 require_once( $t_core_path.'custom_field_api.php' ); 34 35 access_ensure_project_level( config_get('report_bug_threshold' ) ); 36 37 $t_bug_data = new BugData; 38 $t_bug_data->build = gpc_get_string( 'build', '' ); 39 $t_bug_data->platform = gpc_get_string( 'platform', '' ); 40 $t_bug_data->os = gpc_get_string( 'os', '' ); 41 $t_bug_data->os_build = gpc_get_string( 'os_build', '' ); 42 $t_bug_data->version = gpc_get_string( 'product_version', '' ); 43 $t_bug_data->profile_id = gpc_get_int( 'profile_id', 0 ); 44 $t_bug_data->handler_id = gpc_get_int( 'handler_id', 0 ); 45 $t_bug_data->view_state = gpc_get_int( 'view_state', config_get( 'default_bug_view_status' ) ); 46 47 $t_bug_data->category = gpc_get_string( 'category', config_get( 'default_bug_category' ) ); 48 $t_bug_data->reproducibility = gpc_get_int( 'reproducibility', config_get( 'default_bug_reproducibility' ) ); 49 $t_bug_data->severity = gpc_get_int( 'severity', config_get( 'default_bug_severity' ) ); 50 $t_bug_data->priority = gpc_get_int( 'priority', config_get( 'default_bug_priority' ) ); 51 $t_bug_data->summary = gpc_get_string( 'summary' ); 52 $t_bug_data->description = gpc_get_string( 'description' ); 53 $t_bug_data->steps_to_reproduce = gpc_get_string( 'steps_to_reproduce', config_get( 'default_bug_steps_to_reproduce' ) ); 54 $t_bug_data->additional_information = gpc_get_string( 'additional_info', config_get ( 'default_bug_additional_info' ) ); 55 56 $f_file = gpc_get_file( 'file', null ); #@@@ (thraxisp) Note that this always returns a structure 57 # size = 0, if no file 58 $f_report_stay = gpc_get_bool( 'report_stay', false ); 59 $t_bug_data->project_id = gpc_get_int( 'project_id' ); 60 61 $t_bug_data->reporter_id = auth_get_current_user_id(); 62 63 $t_bug_data->summary = trim( $t_bug_data->summary ); 64 65 $t_bug_data->target_version = access_has_project_level( config_get( 'roadmap_update_threshold' ), $t_bug_data->project_id ) ? gpc_get_string( 'target_version', '' ) : ''; 66 67 # if a profile was selected then let's use that information 68 if ( 0 != $t_bug_data->profile_id ) { 69 if ( profile_is_global( $t_bug_data->profile_id ) ) { 70 $row = user_get_profile_row( ALL_USERS, $t_bug_data->profile_id ); 71 } else { 72 $row = user_get_profile_row( $t_bug_data->reporter_id, $t_bug_data->profile_id ); 73 } 74 75 if ( is_blank( $t_bug_data->platform ) ) { 76 $t_bug_data->platform = $row['platform']; 77 } 78 if ( is_blank( $t_bug_data->os ) ) { 79 $t_bug_data->os = $row['os']; 80 } 81 if ( is_blank( $t_bug_data->os_build ) ) { 82 $t_bug_data->os_build = $row['os_build']; 83 } 84 } 85 86 helper_call_custom_function( 'issue_create_validate', array( $t_bug_data ) ); 87 88 # Validate the custom fields before adding the bug. 89 $t_related_custom_field_ids = custom_field_get_linked_ids( $t_bug_data->project_id ); 90 foreach( $t_related_custom_field_ids as $t_id ) { 91 $t_def = custom_field_get_definition( $t_id ); 92 if ( $t_def['require_report'] && ( gpc_get_custom_field( "custom_field_$t_id", $t_def['type'], '' ) == '' ) ) { 93 error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) ); 94 trigger_error( ERROR_EMPTY_FIELD, ERROR ); 95 } 96 if ( !custom_field_validate( $t_id, gpc_get_custom_field( "custom_field_$t_id", $t_def['type'], $t_def['default_value'] ) ) ) { 97 error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) ); 98 trigger_error( ERROR_CUSTOM_FIELD_INVALID_VALUE, ERROR ); 99 } 100 } 101 102 # Create the bug 103 $t_bug_id = bug_create( $t_bug_data ); 104 105 # Handle the file upload 106 if ( !is_blank( $f_file['tmp_name'] ) && ( 0 < $f_file['size'] ) ) { 107 $f_file_error = ( isset( $f_file['error'] ) ) ? $f_file['error'] : 0; 108 file_add( $t_bug_id, $f_file['tmp_name'], $f_file['name'], $f_file['type'], 'bug', $f_file_error ); 109 } 110 111 # Handle custom field submission 112 foreach( $t_related_custom_field_ids as $t_id ) { 113 # Do not set custom field value if user has no write access. 114 if( !custom_field_has_write_access( $t_id, $t_bug_id ) ) { 115 continue; 116 } 117 118 $t_def = custom_field_get_definition( $t_id ); 119 if( !custom_field_set_value( $t_id, $t_bug_id, gpc_get_custom_field( "custom_field_$t_id", $t_def['type'], $t_def['default_value'] ) ) ) { 120 error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) ); 121 trigger_error( ERROR_CUSTOM_FIELD_INVALID_VALUE, ERROR ); 122 } 123 } 124 125 $f_master_bug_id = gpc_get_int( 'm_id', 0 ); 126 $f_rel_type = gpc_get_int( 'rel_type', -1 ); 127 128 if ( $f_master_bug_id > 0 ) { 129 # it's a child generation... let's create the relationship and add some lines in the history 130 131 # update master bug last updated 132 bug_update_date( $f_master_bug_id ); 133 134 # Add log line to record the cloning action 135 history_log_event_special( $t_bug_id, BUG_CREATED_FROM, '', $f_master_bug_id ); 136 history_log_event_special( $f_master_bug_id, BUG_CLONED_TO, '', $t_bug_id ); 137 138 if ( $f_rel_type >= 0 ) { 139 # Add the relationship 140 relationship_add( $t_bug_id, $f_master_bug_id, $f_rel_type ); 141 142 # Add log line to the history (both issues) 143 history_log_event_special( $f_master_bug_id, BUG_ADD_RELATIONSHIP, relationship_get_complementary_type( $f_rel_type ), $t_bug_id ); 144 history_log_event_special( $t_bug_id, BUG_ADD_RELATIONSHIP, $f_rel_type, $f_master_bug_id ); 145 146 # Send the email notification 147 email_relationship_added( $f_master_bug_id, $t_bug_id, relationship_get_complementary_type( $f_rel_type ) ); 148 } 149 } 150 151 email_new_bug( $t_bug_id ); 152 153 helper_call_custom_function( 'issue_create_notify', array( $t_bug_id ) ); 154 155 html_page_top1(); 156 157 if ( ! $f_report_stay ) { 158 html_meta_redirect( 'view_all_bug_page.php' ); 159 } 160 161 html_page_top2(); 162 ?> 163 <br /> 164 <div align="center"> 165 <?php 166 echo lang_get( 'operation_successful' ) . '<br />'; 167 print_bracket_link( string_get_bug_view_url( $t_bug_id ), lang_get( 'view_submitted_bug_link' ) . " $t_bug_id" ); 168 print_bracket_link( 'view_all_bug_page.php', lang_get( 'view_bugs_link' ) ); 169 170 if ( $f_report_stay ) { 171 ?> 172 <p> 173 <form method="post" action="<?php echo string_get_bug_report_url() ?>"> 174 <input type="hidden" name="category" value="<?php echo $t_bug_data->category ?>" /> 175 <input type="hidden" name="severity" value="<?php echo $t_bug_data->severity ?>" /> 176 <input type="hidden" name="reproducibility" value="<?php echo $t_bug_data->reproducibility ?>" /> 177 <input type="hidden" name="profile_id" value="<?php echo $t_bug_data->profile_id ?>" /> 178 <input type="hidden" name="platform" value="<?php echo $t_bug_data->platform ?>" /> 179 <input type="hidden" name="os" value="<?php echo $t_bug_data->os ?>" /> 180 <input type="hidden" name="os_build" value="<?php echo $t_bug_data->os_build ?>" /> 181 <input type="hidden" name="product_version" value="<?php echo $t_bug_data->version ?>" /> 182 <input type="hidden" name="target_version" value="<?php echo $t_bug_data->target_version ?>" /> 183 <input type="hidden" name="build" value="<?php echo $t_bug_data->build ?>" /> 184 <input type="hidden" name="report_stay" value="1" /> 185 <input type="hidden" name="view_state" value="<?php echo $t_bug_data->view_state ?>" /> 186 <input type="submit" class="button" value="<?php echo lang_get( 'report_more_bugs' ) ?>" /> 187 </form> 188 </p> 189 <?php 190 } 191 ?> 192 </div> 193 194 <?php html_page_bottom1( __FILE__ ) ?>
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 |
![]() |