2 # MantisBT - A PHP based bugtracking system
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.
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.
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/>.
18 * This file POSTs data to report_bug.php
21 * @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
22 * @copyright Copyright (C) 2002 - 2011 MantisBT Team - mantisbt-dev@lists.sourceforge.net
23 * @link http://www.mantisbt.org
26 * @uses access_api.php
27 * @uses authentication_api.php
29 * @uses collapse_api.php
30 * @uses columns_api.php
31 * @uses config_api.php
32 * @uses constant_inc.php
33 * @uses custom_field_api.php
40 * @uses helper_api.php
44 * @uses profile_api.php
45 * @uses project_api.php
46 * @uses relationship_api.php
47 * @uses string_api.php
48 * @uses utility_api.php
49 * @uses version_api.php
55 require_once( 'core.php' );
56 require_api( 'access_api.php' );
57 require_api( 'authentication_api.php' );
58 require_api( 'bug_api.php' );
59 require_api( 'collapse_api.php' );
60 require_api( 'columns_api.php' );
61 require_api( 'config_api.php' );
62 require_api( 'constant_inc.php' );
63 require_api( 'custom_field_api.php' );
64 require_api( 'date_api.php' );
65 require_api( 'error_api.php' );
66 require_api( 'event_api.php' );
67 require_api( 'file_api.php' );
68 require_api( 'form_api.php' );
69 require_api( 'gpc_api.php' );
70 require_api( 'helper_api.php' );
71 require_api( 'html_api.php' );
72 require_api( 'lang_api.php' );
73 require_api( 'print_api.php' );
74 require_api( 'profile_api.php' );
75 require_api( 'project_api.php' );
76 require_api( 'relationship_api.php' );
77 require_api( 'string_api.php' );
78 require_api( 'utility_api.php' );
79 require_api( 'version_api.php' );
81 $g_allow_browser_cache = 1;
83 $f_master_bug_id = gpc_get_int( 'm_id', 0 );
85 # this page is invalid for the 'All Project' selection except if this is a clone
86 if ( ( ALL_PROJECTS
== helper_get_current_project() ) && ( 0 == $f_master_bug_id ) ) {
87 print_header_redirect( 'login_select_proj_page.php?ref=bug_report_page.php' );
90 if ( $f_master_bug_id > 0 ) {
91 # master bug exists...
92 bug_ensure_exists( $f_master_bug_id );
94 # master bug is not read-only...
95 if ( bug_is_readonly( $f_master_bug_id ) ) {
96 error_parameters( $f_master_bug_id );
97 trigger_error( ERROR_BUG_READ_ONLY_ACTION_DENIED
, ERROR
);
100 $t_bug = bug_get( $f_master_bug_id, true );
102 # the user can at least update the master bug (needed to add the relationship)...
103 access_ensure_bug_level( config_get( 'update_bug_threshold', null, $t_bug->project_id
), $f_master_bug_id );
105 #@@@ (thraxisp) Note that the master bug is cloned into the same project as the master, independent of
106 # what the current project is set to.
107 if( $t_bug->project_id
!= helper_get_current_project() ) {
108 # in case the current project is not the same project of the bug we are viewing...
109 # ... override the current project. This to avoid problems with categories and handlers lists etc.
110 $g_project_override = $t_bug->project_id
;
111 $t_changed_project = true;
113 $t_changed_project = false;
116 access_ensure_project_level( config_get( 'report_bug_threshold' ) );
118 $f_build = $t_bug->build
;
119 $f_platform = $t_bug->platform
;
121 $f_os_build = $t_bug->os_build
;
122 $f_product_version = $t_bug->version
;
123 $f_target_version = $t_bug->target_version
;
125 $f_handler_id = $t_bug->handler_id
;
127 $f_category_id = $t_bug->category_id
;
128 $f_reproducibility = $t_bug->reproducibility
;
129 $f_severity = $t_bug->severity
;
130 $f_priority = $t_bug->priority
;
131 $f_summary = $t_bug->summary
;
132 $f_description = $t_bug->description
;
133 $f_steps_to_reproduce = $t_bug->steps_to_reproduce
;
134 $f_additional_info = $t_bug->additional_information
;
135 $f_view_state = $t_bug->view_state
;
136 $f_due_date = $t_bug->due_date
;
138 $t_project_id = $t_bug->project_id
;
140 access_ensure_project_level( config_get( 'report_bug_threshold' ) );
142 $f_build = gpc_get_string( 'build', '' );
143 $f_platform = gpc_get_string( 'platform', '' );
144 $f_os = gpc_get_string( 'os', '' );
145 $f_os_build = gpc_get_string( 'os_build', '' );
146 $f_product_version = gpc_get_string( 'product_version', '' );
147 $f_target_version = gpc_get_string( 'target_version', '' );
148 $f_profile_id = gpc_get_int( 'profile_id', 0 );
149 $f_handler_id = gpc_get_int( 'handler_id', 0 );
151 $f_category_id = gpc_get_int( 'category_id', 0 );
152 $f_reproducibility = gpc_get_int( 'reproducibility', config_get( 'default_bug_reproducibility' ) );
153 $f_severity = gpc_get_int( 'severity', config_get( 'default_bug_severity' ) );
154 $f_priority = gpc_get_int( 'priority', config_get( 'default_bug_priority' ) );
155 $f_summary = gpc_get_string( 'summary', '' );
156 $f_description = gpc_get_string( 'description', '' );
157 $f_steps_to_reproduce = gpc_get_string( 'steps_to_reproduce', config_get( 'default_bug_steps_to_reproduce' ) );
158 $f_additional_info = gpc_get_string( 'additional_info', config_get ( 'default_bug_additional_info' ) );
159 $f_view_state = gpc_get_int( 'view_state', config_get( 'default_bug_view_status' ) );
160 $f_due_date = gpc_get_string( 'due_date', '');
162 if ( $f_due_date == '' ) {
163 $f_due_date = date_get_null();
166 $t_project_id = helper_get_current_project();
168 $t_changed_project = false;
171 $f_report_stay = gpc_get_bool( 'report_stay', false );
173 $t_fields = config_get( 'bug_report_page_fields' );
174 $t_fields = columns_filter_disabled( $t_fields );
176 $tpl_show_category = in_array( 'category_id', $t_fields );
177 $tpl_show_reproducibility = in_array( 'reproducibility', $t_fields );
178 $tpl_show_severity = in_array( 'severity', $t_fields );
179 $tpl_show_priority = in_array( 'priority', $t_fields );
180 $tpl_show_steps_to_reproduce = in_array( 'steps_to_reproduce', $t_fields );
181 $tpl_show_handler = in_array( 'handler', $t_fields ) && access_has_project_level( config_get( 'update_bug_assign_threshold' ) );
182 $tpl_show_profiles = config_get( 'enable_profiles' );
183 $tpl_show_platform = $tpl_show_profiles && in_array( 'platform', $t_fields );
184 $tpl_show_os = $tpl_show_profiles && in_array( 'os', $t_fields );
185 $tpl_show_os_version = $tpl_show_profiles && in_array( 'os_version', $t_fields );
187 $tpl_show_versions = version_should_show_product_version( $t_project_id );
188 $tpl_show_product_version = $tpl_show_versions && in_array( 'product_version', $t_fields );
189 $tpl_show_product_build = $tpl_show_versions && in_array( 'product_build', $t_fields ) && config_get( 'enable_product_build' ) == ON
;
190 $tpl_show_target_version = $tpl_show_versions && in_array( 'target_version', $t_fields ) && access_has_project_level( config_get( 'roadmap_update_threshold' ) );
191 $tpl_show_additional_info = in_array( 'additional_info', $t_fields );
192 $tpl_show_due_date = in_array( 'due_date', $t_fields ) && access_has_project_level( config_get( 'due_date_update_threshold' ), helper_get_current_project(), auth_get_current_user_id() );
193 $tpl_show_attachments = in_array( 'attachments', $t_fields ) && file_allow_bug_upload();
194 $tpl_show_view_state = in_array( 'view_state', $t_fields ) && access_has_project_level( config_get( 'set_view_status_threshold' ) );
196 if ( $tpl_show_due_date ) {
197 require_js( 'jscalendar/calendar.js' );
198 require_js( 'jscalendar/lang/calendar-en.js' );
199 require_js( 'jscalendar/calendar-setup.js' );
200 require_css( 'calendar-blue.css' );
203 # don't index bug report page
204 html_robots_noindex();
206 html_page_top( lang_get( 'report_bug_link' ) );
208 print_recently_visited();
212 <form name
="report_bug_form" method
="post" <?php
if ( $tpl_show_attachments ) { echo 'enctype="multipart/form-data"'; } ?
> action
="bug_report.php">
213 <?php
echo form_security_field( 'bug_report' ) ?
>
214 <table
class="width90" cellspacing
="1">
216 <td
class="form-title" colspan
="2">
217 <input type
="hidden" name
="m_id" value
="<?php echo $f_master_bug_id ?>" />
218 <input type
="hidden" name
="project_id" value
="<?php echo $t_project_id ?>" />
219 <?php
echo lang_get( 'enter_report_details_title' ) ?
>
223 event_signal( 'EVENT_REPORT_BUG_FORM_TOP', array( $t_project_id ) );
225 if ( $tpl_show_category ) {
227 <tr
<?php
echo helper_alternate_class() ?
>>
228 <th
class="category" width
="30%">
230 echo config_get( 'allow_no_category' ) ?
'' : '<span class="required">*</span>';
231 echo '<label for="category_id">';
232 print_documentation_link( 'category' );
237 <?php
if ( $t_changed_project ) {
238 echo "[" . project_get_field( $t_bug->project_id
, 'name' ) . "] ";
240 <select
<?php
echo helper_get_tab_index() ?
> id
="category_id" name
="category_id" class="autofocus">
242 print_category_option_list( $f_category_id );
249 if ( $tpl_show_reproducibility ) {
252 <tr
<?php
echo helper_alternate_class() ?
>>
253 <th
class="category">
254 <label
for="reproducibility"><?php
print_documentation_link( 'reproducibility' ) ?
></label
>
257 <select
<?php
echo helper_get_tab_index() ?
> id
="reproducibility" name
="reproducibility">
258 <?php
print_enum_string_option_list( 'reproducibility', $f_reproducibility ) ?
>
265 if ( $tpl_show_severity ) {
267 <tr
<?php
echo helper_alternate_class() ?
>>
268 <th
class="category">
269 <label
for="severity"><?php
print_documentation_link( 'severity' ) ?
></label
>
272 <select
<?php
echo helper_get_tab_index() ?
> id
="severity" name
="severity">
273 <?php
print_enum_string_option_list( 'severity', $f_severity ) ?
>
280 if ( $tpl_show_priority ) {
282 <tr
<?php
echo helper_alternate_class() ?
>>
283 <th
class="category">
284 <label
for="priority"><?php
print_documentation_link( 'priority' ) ?
></label
>
287 <select
<?php
echo helper_get_tab_index() ?
> id
="priority" name
="priority">
288 <?php
print_enum_string_option_list( 'priority', $f_priority ) ?
>
295 if ( $tpl_show_due_date ) {
296 $t_date_to_display = '';
298 if ( !date_is_null( $f_due_date ) ) {
299 $t_date_to_display = date( config_get( 'calendar_date_format' ), $f_due_date );
302 <tr
<?php
echo helper_alternate_class() ?
>>
303 <th
class="category">
304 <label
for="due_date"><?php
print_documentation_link( 'due_date' ) ?
></label
>
307 <?php
echo "<input " . helper_get_tab_index() . " type=\"text\" id=\"due_date\" name=\"due_date\" class=\"datetime\" size=\"20\" maxlength=\"16\" value=\"" . $t_date_to_display . "\" />" ?
>
311 <?php
if ( $tpl_show_platform ||
$tpl_show_os ||
$tpl_show_os_version ) { ?
>
312 <tr
<?php
echo helper_alternate_class() ?
>>
313 <th
class="category">
314 <label
for="profile_id"><?php
echo lang_get( 'select_profile' ) ?
></label
>
317 <?php
if (count(profile_get_all_for_user( auth_get_current_user_id() )) > 0) { ?
>
318 <select
<?php
echo helper_get_tab_index() ?
> id
="profile_id" name
="profile_id">
319 <?php
print_profile_option_list( auth_get_current_user_id(), $f_profile_id ) ?
>
324 <tr
<?php
echo helper_alternate_class() ?
>>
325 <td colspan
="2" class="none">
326 <?php
if( ON
== config_get( 'use_javascript' ) ) { ?
>
327 <?php
collapse_open( 'profile' ); collapse_icon('profile'); ?
>
328 <?php
echo lang_get( 'or_fill_in' ); ?
>
329 <table
class="width90" cellspacing
="0">
331 <?php
echo lang_get( 'or_fill_in' ); ?
>
333 <tr
<?php
echo helper_alternate_class() ?
>>
334 <th
class="category">
335 <label
for="platform"><?php
echo lang_get( 'platform' ) ?
></label
>
338 <?php
if ( config_get( 'allow_freetext_in_profile_fields' ) == OFF
) { ?
>
339 <select id
="platform" name
="platform">
340 <option value
=""></option
>
341 <?php
print_platform_option_list( $f_platform ); ?
>
345 echo '<input type="text" id="platform" name="platform" class="autocomplete" size="32" maxlength="32" tabindex="' . helper_get_tab_index_value() . '" value="' . string_attribute( $f_platform ) . '" />';
350 <tr
<?php
echo helper_alternate_class() ?
>>
351 <th
class="category">
352 <label
for="os"><?php
echo lang_get( 'os' ) ?
></label
>
355 <?php
if ( config_get( 'allow_freetext_in_profile_fields' ) == OFF
) { ?
>
356 <select id
="os" name
="os">
357 <option value
=""></option
>
358 <?php
print_os_option_list( $f_os ); ?
>
362 echo '<input type="text" id="os" name="os" class="autocomplete" size="32" maxlength="32" tabindex="' . helper_get_tab_index_value() . '" value="' . string_attribute( $f_os) . '" />';
367 <tr
<?php
echo helper_alternate_class() ?
>>
368 <th
class="category">
369 <label
for="os_build"><?php
echo lang_get( 'os_version' ) ?
></label
>
373 if ( config_get( 'allow_freetext_in_profile_fields' ) == OFF
) {
375 <select id
="os_build" name
="os_build">
376 <option value
=""></option
>
377 <?php
print_os_build_option_list( $f_os_build ); ?
>
381 echo '<input type="text" id="os_build" name="os_build" class="autocomplete" size="16" maxlength="16" tabindex="' . helper_get_tab_index_value() . '" value="' . string_attribute( $f_os_build ) . '" />';
386 <?php
if( ON
== config_get( 'use_javascript' ) ) { ?
>
388 <?php
collapse_closed( 'profile' ); collapse_icon('profile'); echo lang_get( 'or_fill_in' );?
>
389 <?php
collapse_end( 'profile' ); ?
>
395 if ( $tpl_show_product_version ) {
396 $t_product_version_released_mask = VERSION_RELEASED
;
398 if (access_has_project_level( config_get( 'report_issues_for_unreleased_versions_threshold' ) ) ) {
399 $t_product_version_released_mask = VERSION_ALL
;
402 <tr
<?php
echo helper_alternate_class() ?
>>
403 <th
class="category">
404 <label
for="product_version"><?php
echo lang_get( 'product_version' ) ?
></label
>
407 <select
<?php
echo helper_get_tab_index() ?
> id
="product_version" name
="product_version">
408 <?php
print_version_option_list( $f_product_version, $t_project_id, $t_product_version_released_mask ) ?
>
415 <?php
if ( $tpl_show_product_build ) { ?
>
416 <tr
<?php
echo helper_alternate_class() ?
>>
417 <th
class="category">
418 <label
for="build"><?php
echo lang_get( 'product_build' ) ?
></label
>
421 <input
<?php
echo helper_get_tab_index() ?
> type
="text" id
="build" name
="build" size
="32" maxlength
="32" value
="<?php echo string_attribute( $f_build ) ?>" />
426 <?php
if ( $tpl_show_handler ) { ?
>
427 <tr
<?php
echo helper_alternate_class() ?
>>
428 <th
class="category">
429 <label
for="handler_id"><?php
echo lang_get( 'assign_to' ) ?
></label
>
432 <select
<?php
echo helper_get_tab_index() ?
> id
="handler_id" name
="handler_id">
433 <option value
="0" selected
="selected"></option
>
434 <?php
print_assign_to_option_list( $f_handler_id ) ?
>
440 <?php
// Target Version (if permissions allow)
441 if ( $tpl_show_target_version ) { ?
>
442 <tr
<?php
echo helper_alternate_class() ?
>>
443 <th
class="category">
444 <label
for="target_version"><?php
echo lang_get( 'target_version' ) ?
></label
>
447 <select
<?php
echo helper_get_tab_index() ?
> id
="target_version" name
="target_version">
448 <?php
print_version_option_list() ?
>
453 <?php
event_signal( 'EVENT_REPORT_BUG_FORM', array( $t_project_id ) ) ?
>
454 <tr
<?php
echo helper_alternate_class() ?
>>
455 <th
class="category">
456 <span
class="required">*</span
><label
for="summary"><?php
print_documentation_link( 'summary' ) ?
></label
>
459 <input
<?php
echo helper_get_tab_index() ?
> type
="text" id
="summary" name
="summary" size
="105" maxlength
="128" value
="<?php echo string_attribute( $f_summary ) ?>" />
462 <tr
<?php
echo helper_alternate_class() ?
>>
463 <th
class="category">
464 <span
class="required">*</span
><label
for="description"><?php
print_documentation_link( 'description' ) ?
></label
>
467 <textarea
<?php
echo helper_get_tab_index() ?
> id
="description" name
="description" cols
="80" rows
="10"><?php
echo string_textarea( $f_description ) ?
></textarea
>
471 <?php
if ( $tpl_show_steps_to_reproduce ) { ?
>
472 <tr
<?php
echo helper_alternate_class() ?
>>
473 <th
class="category">
474 <label
for="steps_to_reproduce"><?php
print_documentation_link( 'steps_to_reproduce' ) ?
></label
>
477 <textarea
<?php
echo helper_get_tab_index() ?
> id
="steps_to_reproduce" name
="steps_to_reproduce" cols
="80" rows
="10"><?php
echo string_textarea( $f_steps_to_reproduce ) ?
></textarea
>
482 <?php
if ( $tpl_show_additional_info ) { ?
>
483 <tr
<?php
echo helper_alternate_class() ?
>>
484 <th
class="category">
485 <label
for="additional_info"><?php
print_documentation_link( 'additional_information' ) ?
></label
>
488 <textarea
<?php
echo helper_get_tab_index() ?
> id
="additional_info" name
="additional_info" cols
="80" rows
="10"><?php
echo string_textarea( $f_additional_info ) ?
></textarea
>
494 $t_custom_fields_found = false;
495 $t_related_custom_field_ids = custom_field_get_linked_ids( $t_project_id );
497 foreach( $t_related_custom_field_ids as $t_id ) {
498 $t_def = custom_field_get_definition( $t_id );
499 if( ( $t_def['display_report'] ||
$t_def['require_report']) && custom_field_has_write_access_to_project( $t_id, $t_project_id ) ) {
500 $t_custom_fields_found = true;
502 <tr
<?php
echo helper_alternate_class() ?
>>
503 <th
class="category">
504 <?php
if($t_def['require_report']) {?
><span
class="required">*</span
><?php
} ?
>
505 <?php
if ( $t_def['type'] != CUSTOM_FIELD_TYPE_RADIO
&& $t_def['type'] != CUSTOM_FIELD_TYPE_CHECKBOX
) { ?
>
506 <label
for="custom_field_<?php echo string_attribute( $t_def['id'] ) ?>"><?php
echo string_display( lang_get_defaulted( $t_def['name'] ) ) ?
></label
>
507 <?php
} else echo string_display( lang_get_defaulted( $t_def['name'] ) ) ?
>
510 <?php
print_custom_field_input( $t_def, ( $f_master_bug_id === 0 ) ?
null : $f_master_bug_id ) ?
>
515 } # foreach( $t_related_custom_field_ids as $t_id )
517 <?php
if ( $tpl_show_attachments ) { // File Upload (if enabled)
518 $t_max_file_size = (int)min( ini_get_number( 'upload_max_filesize' ), ini_get_number( 'post_max_size' ), config_get( 'max_file_size' ) );
520 <tr
<?php
echo helper_alternate_class() ?
>>
521 <td
class="category">
522 <label
for="file"><?php
echo lang_get( 'upload_file' ) ?
></label
><br
/>
523 <span
class="small"><?php
echo lang_get( 'max_file_size_label' ) . lang_get( 'word_separator' ) . number_format( $t_max_file_size/1000 ) ?
>k
</span
>
526 <input type
="hidden" name
="max_file_size" value
="<?php echo $t_max_file_size ?>" />
527 <input
<?php
echo helper_get_tab_index() ?
> id
="file" name
="file" type
="file" size
="60" />
533 if ( $tpl_show_view_state ) {
535 <tr
<?php
echo helper_alternate_class() ?
>>
536 <th
class="category">
537 <?php
echo lang_get( 'view_status' ) ?
>
540 <label
><input
<?php
echo helper_get_tab_index() ?
> type
="radio" name
="view_state" value
="<?php echo VS_PUBLIC ?>" <?php
check_checked( $f_view_state, VS_PUBLIC
) ?
> /> <?php
echo lang_get( 'public' ) ?
></label
>
541 <label
><input
<?php
echo helper_get_tab_index() ?
> type
="radio" name
="view_state" value
="<?php echo VS_PRIVATE ?>" <?php
check_checked( $f_view_state, VS_PRIVATE
) ?
> /> <?php
echo lang_get( 'private' ) ?
></label
>
546 //Relationship (in case of cloned bug creation...)
547 if( $f_master_bug_id > 0 ) {
549 <tr
<?php
echo helper_alternate_class() ?
>>
550 <th
class="category">
551 <?php
echo lang_get( 'relationship_with_parent' ) ?
>
554 <?php
relationship_list_box( /* none */ -2, "rel_type", false, true ) ?
>
555 <?php
echo '<strong>' . lang_get( 'bug' ) . ' ' . bug_format_id( $f_master_bug_id ) . '</strong>' ?
>
561 <tr
<?php
echo helper_alternate_class() ?
>>
562 <th
class="category">
563 <?php
print_documentation_link( 'report_stay' ) ?
>
566 <label
><input
<?php
echo helper_get_tab_index() ?
> type
="checkbox" id
="report_stay" name
="report_stay" <?php
check_checked( $f_report_stay ) ?
> /> <?php
echo lang_get( 'check_report_more_bugs' ) ?
></label
>
571 <span
class="required"> * <?php
echo lang_get( 'required' ) ?
></span
>
574 <input
<?php
echo helper_get_tab_index() ?
> type
="submit" class="button" value
="<?php echo lang_get( 'submit_report_button' ) ?>" />