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 - 2010 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 projax_api.php
46 * @uses project_api.php
47 * @uses relationship_api.php
48 * @uses string_api.php
49 * @uses utility_api.php
50 * @uses version_api.php
53 require_once( 'core.php' );
54 require_api( 'access_api.php' );
55 require_api( 'authentication_api.php' );
56 require_api( 'bug_api.php' );
57 require_api( 'collapse_api.php' );
58 require_api( 'columns_api.php' );
59 require_api( 'config_api.php' );
60 require_api( 'constant_inc.php' );
61 require_api( 'custom_field_api.php' );
62 require_api( 'date_api.php' );
63 require_api( 'error_api.php' );
64 require_api( 'event_api.php' );
65 require_api( 'file_api.php' );
66 require_api( 'form_api.php' );
67 require_api( 'gpc_api.php' );
68 require_api( 'helper_api.php' );
69 require_api( 'html_api.php' );
70 require_api( 'lang_api.php' );
71 require_api( 'print_api.php' );
72 require_api( 'profile_api.php' );
73 require_api( 'projax_api.php' );
74 require_api( 'project_api.php' );
75 require_api( 'relationship_api.php' );
76 require_api( 'string_api.php' );
77 require_api( 'utility_api.php' );
78 require_api( 'version_api.php' );
80 $g_allow_browser_cache = 1;
82 $f_master_bug_id = gpc_get_int( 'm_id', 0 );
84 # this page is invalid for the 'All Project' selection except if this is a clone
85 if ( ( ALL_PROJECTS
== helper_get_current_project() ) && ( 0 == $f_master_bug_id ) ) {
86 print_header_redirect( 'login_select_proj_page.php?ref=bug_report_page.php' );
89 if ( $f_master_bug_id > 0 ) {
90 # master bug exists...
91 bug_ensure_exists( $f_master_bug_id );
93 # master bug is not read-only...
94 if ( bug_is_readonly( $f_master_bug_id ) ) {
95 error_parameters( $f_master_bug_id );
96 trigger_error( ERROR_BUG_READ_ONLY_ACTION_DENIED
, ERROR
);
99 $t_bug = bug_get( $f_master_bug_id, true );
101 # the user can at least update the master bug (needed to add the relationship)...
102 access_ensure_bug_level( config_get( 'update_bug_threshold', null, $t_bug->project_id
), $f_master_bug_id );
104 #@@@ (thraxisp) Note that the master bug is cloned into the same project as the master, independent of
105 # what the current project is set to.
106 if( $t_bug->project_id
!= helper_get_current_project() ) {
107 # in case the current project is not the same project of the bug we are viewing...
108 # ... override the current project. This to avoid problems with categories and handlers lists etc.
109 $g_project_override = $t_bug->project_id
;
110 $t_changed_project = true;
112 $t_changed_project = false;
115 access_ensure_project_level( config_get( 'report_bug_threshold' ) );
117 $f_build = $t_bug->build
;
118 $f_platform = $t_bug->platform
;
120 $f_os_build = $t_bug->os_build
;
121 $f_product_version = $t_bug->version
;
122 $f_target_version = $t_bug->target_version
;
124 $f_handler_id = $t_bug->handler_id
;
126 $f_category_id = $t_bug->category_id
;
127 $f_reproducibility = $t_bug->reproducibility
;
128 $f_severity = $t_bug->severity
;
129 $f_priority = $t_bug->priority
;
130 $f_summary = $t_bug->summary
;
131 $f_description = $t_bug->description
;
132 $f_steps_to_reproduce = $t_bug->steps_to_reproduce
;
133 $f_additional_info = $t_bug->additional_information
;
134 $f_view_state = $t_bug->view_state
;
136 $t_project_id = $t_bug->project_id
;
138 access_ensure_project_level( config_get( 'report_bug_threshold' ) );
140 $f_build = gpc_get_string( 'build', '' );
141 $f_platform = gpc_get_string( 'platform', '' );
142 $f_os = gpc_get_string( 'os', '' );
143 $f_os_build = gpc_get_string( 'os_build', '' );
144 $f_product_version = gpc_get_string( 'product_version', '' );
145 $f_target_version = gpc_get_string( 'target_version', '' );
146 $f_profile_id = gpc_get_int( 'profile_id', 0 );
147 $f_handler_id = gpc_get_int( 'handler_id', 0 );
149 $f_category_id = gpc_get_int( 'category_id', 0 );
150 $f_reproducibility = gpc_get_int( 'reproducibility', config_get( 'default_bug_reproducibility' ) );
151 $f_severity = gpc_get_int( 'severity', config_get( 'default_bug_severity' ) );
152 $f_priority = gpc_get_int( 'priority', config_get( 'default_bug_priority' ) );
153 $f_summary = gpc_get_string( 'summary', '' );
154 $f_description = gpc_get_string( 'description', '' );
155 $f_steps_to_reproduce = gpc_get_string( 'steps_to_reproduce', config_get( 'default_bug_steps_to_reproduce' ) );
156 $f_additional_info = gpc_get_string( 'additional_info', config_get ( 'default_bug_additional_info' ) );
157 $f_view_state = gpc_get_int( 'view_state', config_get( 'default_bug_view_status' ) );
158 $f_due_date = gpc_get_string( 'due_date', '');
160 if ( $f_due_date == '' ) {
161 $f_due_date = date_get_null();
164 $t_project_id = helper_get_current_project();
166 $t_changed_project = false;
169 $f_report_stay = gpc_get_bool( 'report_stay', false );
171 $t_fields = config_get( 'bug_report_page_fields' );
172 $t_fields = columns_filter_disabled( $t_fields );
174 $tpl_show_category = in_array( BUG_FIELD_CATEGORY
, $t_fields );
175 $tpl_show_reproducibility = in_array( BUG_FIELD_REPRODUCIBILITY
, $t_fields );
176 $tpl_show_severity = in_array( BUG_FIELD_SEVERITY
, $t_fields );
177 $tpl_show_priority = in_array( BUG_FIELD_PRIORITY
, $t_fields );
178 $tpl_show_steps_to_reproduce = in_array( BUG_FIELD_STEPS_TO_REPRODUCE
, $t_fields );
179 $tpl_show_handler = in_array( BUG_FIELD_HANDLER
, $t_fields ) && access_has_project_level( config_get( 'update_bug_assign_threshold' ) );
180 $tpl_show_profiles = ON
== config_get( 'enable_profiles' );
181 $tpl_show_platform = in_array( BUG_FIELD_PLATFORM
, $t_fields );
182 $tpl_show_os = in_array( BUG_FIELD_OS
, $t_fields );
183 $tpl_show_os_version = in_array( BUG_FIELD_OS_VERSION
, $t_fields );
185 $tpl_show_versions = version_should_show_product_version( $t_project_id );
186 $tpl_show_product_version = $tpl_show_versions && in_array( BUG_FIELD_PRODUCT_VERSION
, $t_fields );
187 $tpl_show_product_build = $tpl_show_versions && in_array( BUG_FIELD_PRODUCT_BUILD
, $t_fields ) && config_get( 'enable_product_build' ) == ON
;
188 $tpl_show_target_version = $tpl_show_versions && in_array( BUG_FIELD_TARGET_VERSION
, $t_fields ) && access_has_project_level( config_get( 'roadmap_update_threshold' ) );
189 $tpl_show_additional_info = in_array( BUG_FIELD_ADDITIONAL_INFO
, $t_fields );
190 $tpl_show_due_date = in_array( BUG_FIELD_DUE_DATE
, $t_fields ) && access_has_project_level( config_get( 'due_date_update_threshold' ), helper_get_current_project(), auth_get_current_user_id() );
191 $tpl_show_attachments = in_array( BUG_FIELD_ATTACHMENTS
, $t_fields ) && file_allow_bug_upload();
192 $tpl_show_view_state = in_array( BUG_FIELD_VIEW_STATE
, $t_fields ) && access_has_project_level( config_get( 'set_view_status_threshold' ) );
194 # don't index bug report page
195 html_robots_noindex();
197 html_page_top( lang_get( 'report_bug_link' ) );
199 print_recently_visited();
203 <form name
="report_bug_form" method
="post" <?php
if ( $tpl_show_attachments ) { echo 'enctype="multipart/form-data"'; } ?
> action
="bug_report.php">
204 <?php
echo form_security_field( 'bug_report' ) ?
>
205 <table
class="width90" cellspacing
="1">
207 <td
class="form-title" colspan
="2">
208 <input type
="hidden" name
="m_id" value
="<?php echo $f_master_bug_id ?>" />
209 <input type
="hidden" name
="project_id" value
="<?php echo $t_project_id ?>" />
210 <?php
echo lang_get( 'enter_report_details_title' ) ?
>
214 event_signal( 'EVENT_REPORT_BUG_FORM_TOP', array( $t_project_id ) );
216 if ( $tpl_show_category ) {
218 <tr
<?php
echo helper_alternate_class() ?
>>
219 <td
class="category" width
="30%">
220 <?php
echo config_get( 'allow_no_category' ) ?
'' : '<span class="required">*</span>'; print_documentation_link( 'category' ) ?
>
223 <?php
if ( $t_changed_project ) {
224 echo "[" . project_get_field( $t_bug->project_id
, 'name' ) . "] ";
226 <select
<?php
echo helper_get_tab_index() ?
> name
="category_id">
228 print_category_option_list( $f_category_id );
235 if ( $tpl_show_reproducibility ) {
238 <tr
<?php
echo helper_alternate_class() ?
>>
239 <td
class="category">
240 <?php
print_documentation_link( 'reproducibility' ) ?
>
243 <select
<?php
echo helper_get_tab_index() ?
> name
="reproducibility">
244 <?php
print_enum_string_option_list( 'reproducibility', $f_reproducibility ) ?
>
251 if ( $tpl_show_severity ) {
253 <tr
<?php
echo helper_alternate_class() ?
>>
254 <td
class="category">
255 <?php
print_documentation_link( 'severity' ) ?
>
258 <select
<?php
echo helper_get_tab_index() ?
> name
="severity">
259 <?php
print_enum_string_option_list( 'severity', $f_severity ) ?
>
266 if ( $tpl_show_priority ) {
268 <tr
<?php
echo helper_alternate_class() ?
>>
269 <td
class="category">
270 <?php
print_documentation_link( 'priority' ) ?
>
273 <select
<?php
echo helper_get_tab_index() ?
> name
="priority">
274 <?php
print_enum_string_option_list( 'priority', $f_priority ) ?
>
281 if ( $tpl_show_due_date ) {
282 $t_date_to_display = '';
284 if ( !date_is_null( $f_due_date ) ) {
285 $t_date_to_display = date( config_get( 'calendar_date_format' ), $f_due_date );
288 <tr
<?php
echo helper_alternate_class() ?
>>
289 <td
class="category">
290 <?php
print_documentation_link( 'due_date' ) ?
>
294 print "<input ".helper_get_tab_index()." type=\"text\" id=\"due_date\" name=\"due_date\" size=\"20\" maxlength=\"10\" value=\"".$t_date_to_display."\" />";
295 date_print_calendar();
300 <?php
if ( $tpl_show_platform ||
$tpl_show_os ||
$tpl_show_os_version ) { ?
>
301 <tr
<?php
echo helper_alternate_class() ?
>>
302 <td
class="category">
303 <?php
echo lang_get( 'select_profile' ) ?
>
306 <?php
if (count(profile_get_all_for_user( auth_get_current_user_id() )) > 0) { ?
>
307 <select
<?php
echo helper_get_tab_index() ?
> name
="profile_id">
308 <?php
print_profile_option_list( auth_get_current_user_id(), $f_profile_id ) ?
>
313 <tr
<?php
echo helper_alternate_class() ?
>>
314 <td colspan
="2" class="none">
315 <?php
if( ON
== config_get( 'use_javascript' ) ) { ?
>
316 <?php
collapse_open( 'profile' ); collapse_icon('profile'); ?
>
317 <?php
echo lang_get( 'or_fill_in' ); ?
>
318 <table
class="width90" cellspacing
="0">
320 <?php
echo lang_get( 'or_fill_in' ); ?
>
322 <tr
<?php
echo helper_alternate_class() ?
>>
323 <td
class="category">
324 <?php
echo lang_get( 'platform' ) ?
>
327 <?php
if ( config_get( 'allow_freetext_in_profile_fields' ) == OFF
) { ?
>
328 <select name
="platform">
329 <option value
=""></option
>
330 <?php
print_platform_option_list( $f_platform ); ?
>
334 projax_autocomplete( 'platform_get_with_prefix', 'platform', array( 'value' => $f_platform, 'size' => '32', 'maxlength' => '32', 'tabindex' => helper_get_tab_index_value() ) );
339 <tr
<?php
echo helper_alternate_class() ?
>>
340 <td
class="category">
341 <?php
echo lang_get( 'os' ) ?
>
344 <?php
if ( config_get( 'allow_freetext_in_profile_fields' ) == OFF
) { ?
>
346 <option value
=""></option
>
347 <?php
print_os_option_list( $f_os ); ?
>
351 projax_autocomplete( 'os_get_with_prefix', 'os', array( 'value' => $f_os, 'size' => '32', 'maxlength' => '32', 'tabindex' => helper_get_tab_index_value() ) );
356 <tr
<?php
echo helper_alternate_class() ?
>>
357 <td
class="category">
358 <?php
echo lang_get( 'os_version' ) ?
>
362 if ( config_get( 'allow_freetext_in_profile_fields' ) == OFF
) {
364 <select name
="os_build">
365 <option value
=""></option
>
366 <?php
print_os_build_option_list( $f_os_build ); ?
>
370 projax_autocomplete( 'os_build_get_with_prefix', 'os_build', array( 'value' => $f_os_build, 'size' => '16', 'maxlength' => '16', 'tabindex' => helper_get_tab_index_value() ) );
375 <?php
if( ON
== config_get( 'use_javascript' ) ) { ?
>
377 <?php
collapse_closed( 'profile' ); collapse_icon('profile'); echo lang_get( 'or_fill_in' );?
>
378 <?php
collapse_end( 'profile' ); ?
>
384 if ( $tpl_show_product_version ) {
385 $t_product_version_released_mask = VERSION_RELEASED
;
387 if (access_has_project_level( config_get( 'report_issues_for_unreleased_versions_threshold' ) ) ) {
388 $t_product_version_released_mask = VERSION_ALL
;
391 <tr
<?php
echo helper_alternate_class() ?
>>
392 <td
class="category">
393 <?php
echo lang_get( 'product_version' ) ?
>
396 <select
<?php
echo helper_get_tab_index() ?
> name
="product_version">
397 <?php
print_version_option_list( $f_product_version, $t_project_id, $t_product_version_released_mask ) ?
>
404 <?php
if ( $tpl_show_product_build ) { ?
>
405 <tr
<?php
echo helper_alternate_class() ?
>>
406 <td
class="category">
407 <?php
echo lang_get( 'product_build' ) ?
>
410 <input
<?php
echo helper_get_tab_index() ?
> type
="text" name
="build" size
="32" maxlength
="32" value
="<?php echo string_attribute( $f_build ) ?>" />
415 <?php
if ( $tpl_show_handler ) { ?
>
416 <tr
<?php
echo helper_alternate_class() ?
>>
417 <td
class="category">
418 <?php
echo lang_get( 'assign_to' ) ?
>
421 <select
<?php
echo helper_get_tab_index() ?
> name
="handler_id">
422 <option value
="0" selected
="selected"></option
>
423 <?php
print_assign_to_option_list( $f_handler_id ) ?
>
429 <?php
// Target Version (if permissions allow)
430 if ( $tpl_show_target_version ) { ?
>
431 <tr
<?php
echo helper_alternate_class() ?
>>
432 <td
class="category">
433 <?php
echo lang_get( 'target_version' ) ?
>
436 <select
<?php
echo helper_get_tab_index() ?
> name
="target_version">
437 <?php
print_version_option_list() ?
>
442 <?php
event_signal( 'EVENT_REPORT_BUG_FORM', array( $t_project_id ) ) ?
>
443 <tr
<?php
echo helper_alternate_class() ?
>>
444 <td
class="category">
445 <span
class="required">*</span
><?php
print_documentation_link( 'summary' ) ?
>
448 <input
<?php
echo helper_get_tab_index() ?
> type
="text" name
="summary" size
="105" maxlength
="128" value
="<?php echo string_attribute( $f_summary ) ?>" />
451 <tr
<?php
echo helper_alternate_class() ?
>>
452 <td
class="category">
453 <span
class="required">*</span
><?php
print_documentation_link( 'description' ) ?
>
456 <textarea
<?php
echo helper_get_tab_index() ?
> name
="description" cols
="80" rows
="10"><?php
echo string_textarea( $f_description ) ?
></textarea
>
460 <?php
if ( $tpl_show_steps_to_reproduce ) { ?
>
461 <tr
<?php
echo helper_alternate_class() ?
>>
462 <td
class="category">
463 <?php
print_documentation_link( 'steps_to_reproduce' ) ?
>
466 <textarea
<?php
echo helper_get_tab_index() ?
> name
="steps_to_reproduce" cols
="80" rows
="10"><?php
echo string_textarea( $f_steps_to_reproduce ) ?
></textarea
>
471 <?php
if ( $tpl_show_additional_info ) { ?
>
472 <tr
<?php
echo helper_alternate_class() ?
>>
473 <td
class="category">
474 <?php
print_documentation_link( 'additional_information' ) ?
>
477 <textarea
<?php
echo helper_get_tab_index() ?
> name
="additional_info" cols
="80" rows
="10"><?php
echo string_textarea( $f_additional_info ) ?
></textarea
>
483 $t_custom_fields_found = false;
484 $t_related_custom_field_ids = custom_field_get_linked_ids( $t_project_id );
486 foreach( $t_related_custom_field_ids as $t_id ) {
487 $t_def = custom_field_get_definition( $t_id );
488 if( ( $t_def['display_report'] ||
$t_def['require_report']) && custom_field_has_write_access_to_project( $t_id, $t_project_id ) ) {
489 $t_custom_fields_found = true;
491 <tr
<?php
echo helper_alternate_class() ?
>>
492 <td
class="category">
493 <?php
if($t_def['require_report']) {?
><span
class="required">*</span
><?php
} echo string_display( lang_get_defaulted( $t_def['name'] ) ) ?
>
496 <?php
print_custom_field_input( $t_def, ( $f_master_bug_id === 0 ) ?
null : $f_master_bug_id ) ?
>
501 } # foreach( $t_related_custom_field_ids as $t_id )
503 <?php
if ( $tpl_show_attachments ) { // File Upload (if enabled)
504 $t_max_file_size = (int)min( ini_get_number( 'upload_max_filesize' ), ini_get_number( 'post_max_size' ), config_get( 'max_file_size' ) );
506 <tr
<?php
echo helper_alternate_class() ?
>>
507 <td
class="category">
508 <?php
echo lang_get( 'upload_file' ) ?
><br
/>
509 <span
class="small"><?php
echo lang_get( 'max_file_size_label' ) . lang_get( 'word_separator' ) . number_format( $t_max_file_size/1000 ) ?
>k
</span
>
512 <input type
="hidden" name
="max_file_size" value
="<?php echo $t_max_file_size ?>" />
513 <input
<?php
echo helper_get_tab_index() ?
> name
="file" type
="file" size
="60" />
519 if ( $tpl_show_view_state ) {
521 <tr
<?php
echo helper_alternate_class() ?
>>
522 <td
class="category">
523 <?php
echo lang_get( 'view_status' ) ?
>
526 <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
>
527 <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
>
533 <?php
//Relationship (in case of cloned bug creation...)
534 if( $f_master_bug_id > 0 ) {
536 <tr
<?php
echo helper_alternate_class() ?
>>
537 <td
class="category">
538 <?php
echo lang_get( 'relationship_with_parent' ) ?
>
541 <?php
relationship_list_box( /* none */ -2, "rel_type", false, true ) ?
>
542 <?php
echo '<b>' . lang_get( 'bug' ) . ' ' . bug_format_id( $f_master_bug_id ) . '</b>' ?
>
548 <tr
<?php
echo helper_alternate_class() ?
>>
549 <td
class="category">
550 <?php
print_documentation_link( 'report_stay' ) ?
>
553 <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
>
558 <span
class="required"> * <?php
echo lang_get( 'required' ) ?
></span
>
561 <input
<?php
echo helper_get_tab_index() ?
> type
="submit" class="button" value
="<?php echo lang_get( 'submit_report_button' ) ?>" />
568 <!-- Autofocus JS
-->
569 <?php
if ( ON
== config_get( 'use_javascript' ) ) { ?
>
570 <script type
="text/javascript" language
="JavaScript">
572 window
.document
.report_bug_form
.category_id
.focus();
576 if ( $tpl_show_due_date ) {
577 date_finish_calendar( 'due_date', 'trigger' );