# MantisBT - A PHP based bugtracking system
# MantisBT is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# MantisBT is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with MantisBT. If not, see .
/**
* This include file prints out the bug information
*
* @package MantisBT
* @copyright Copyright 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
* @copyright Copyright 2002 MantisBT Team - mantisbt-dev@lists.sourceforge.net
* @link http://www.mantisbt.org
*
* @uses access_api.php
* @uses authentication_api.php
* @uses bug_api.php
* @uses category_api.php
* @uses columns_api.php
* @uses compress_api.php
* @uses config_api.php
* @uses constant_inc.php
* @uses current_user_api.php
* @uses custom_field_api.php
* @uses date_api.php
* @uses event_api.php
* @uses gpc_api.php
* @uses helper_api.php
* @uses html_api.php
* @uses lang_api.php
* @uses prepare_api.php
* @uses print_api.php
* @uses project_api.php
* @uses string_api.php
* @uses tag_api.php
* @uses utility_api.php
* @uses version_api.php
*/
if( !defined( 'BUG_VIEW_INC_ALLOW' ) ) {
return;
}
require_api( 'access_api.php' );
require_api( 'authentication_api.php' );
require_api( 'bug_api.php' );
require_api( 'category_api.php' );
require_api( 'columns_api.php' );
require_api( 'compress_api.php' );
require_api( 'config_api.php' );
require_api( 'constant_inc.php' );
require_api( 'current_user_api.php' );
require_api( 'custom_field_api.php' );
require_api( 'date_api.php' );
require_api( 'event_api.php' );
require_api( 'gpc_api.php' );
require_api( 'helper_api.php' );
require_api( 'html_api.php' );
require_api( 'lang_api.php' );
require_api( 'prepare_api.php' );
require_api( 'print_api.php' );
require_api( 'project_api.php' );
require_api( 'string_api.php' );
require_api( 'tag_api.php' );
require_api( 'utility_api.php' );
require_api( 'version_api.php' );
require_css( 'status_config.php' );
$f_issue_id = gpc_get_int( 'id' );
$f_history = gpc_get_bool( 'history', config_get( 'history_default_visible' ) );
# compat variables for included pages
$f_bug_id = $f_issue_id;
$t_bug = $t_bug = bug_get( $f_bug_id, true );
$t_data = array(
'query' => array( 'id' => $f_issue_id ),
'options' => array( 'force_readonly' => $t_force_readonly )
);
$t_cmd = new IssueViewPageCommand( $t_data );
$t_result = $t_cmd->execute();
$t_issue = $t_result['issue'];
$t_issue_view = $t_result['issue_view'];
$t_flags = $t_result['flags'];
compress_enable();
if( $t_show_page_header ) {
layout_page_header( bug_format_summary( $f_issue_id, SUMMARY_CAPTION ), null, 'view-issue-page' );
layout_page_begin( 'view_all_bug_page.php' );
}
$t_action_button_position = config_get( 'action_button_position' );
$t_bugslist = gpc_get_cookie( config_get_global( 'bug_list_cookie' ), false );
$t_top_buttons_enabled = !$t_force_readonly && ( $t_action_button_position == POSITION_TOP || $t_action_button_position == POSITION_BOTH );
$t_bottom_buttons_enabled = !$t_force_readonly && ( $t_action_button_position == POSITION_BOTTOM || $t_action_button_position == POSITION_BOTH );
#
# Start of Template
#
echo '
echo '
# User list sponsoring the bug
if( $t_flags['sponsorships_show'] ) {
define( 'BUG_SPONSORSHIP_LIST_VIEW_INC_ALLOW', true );
include( $t_mantis_dir . 'bug_sponsorship_list_view_inc.php' );
}
# Bug Relationships
if( $t_flags['relationships_show'] ) {
bug_view_relationship_view_box( $f_issue_id, /* can_update */ $t_flags['relationships_can_update'] );
}
# User list monitoring the bug
if( $t_flags['monitor_show'] ) {
echo '
echo '
$t_collapse_block = is_collapsed( 'monitoring' );
$t_block_css = $t_collapse_block ? 'collapsed' : '';
$t_block_icon = $t_collapse_block ? 'fa-chevron-down' : 'fa-chevron-up';
?>
}
# Bugnotes and "Add Note" box
if( 'ASC' == current_user_get_pref( 'bugnote_order' ) ) {
define( 'BUGNOTE_VIEW_INC_ALLOW', true );
include( $t_mantis_dir . 'bugnote_view_inc.php' );
if( !$t_force_readonly ) {
define( 'BUGNOTE_ADD_INC_ALLOW', true );
include( $t_mantis_dir . 'bugnote_add_inc.php' );
}
} else {
if( !$t_force_readonly ) {
define( 'BUGNOTE_ADD_INC_ALLOW', true );
include( $t_mantis_dir . 'bugnote_add_inc.php' );
}
define( 'BUGNOTE_VIEW_INC_ALLOW', true );
include( $t_mantis_dir . 'bugnote_view_inc.php' );
}
# Allow plugins to display stuff after notes
event_signal( 'EVENT_VIEW_BUG_EXTRA', array( $f_issue_id ) );
# Time tracking statistics
if( config_get( 'time_tracking_enabled' ) &&
access_has_bug_level( config_get( 'time_tracking_view_threshold' ), $f_issue_id ) ) {
define( 'BUGNOTE_STATS_INC_ALLOW', true );
include( $t_mantis_dir . 'bugnote_stats_inc.php' );
}
# History
if( $t_flags['history_show'] && $f_history ) {
?>
$t_collapse_block = is_collapsed( 'history' );
$t_block_css = $t_collapse_block ? 'collapsed' : '';
$t_block_icon = $t_collapse_block ? 'fa-chevron-down' : 'fa-chevron-up';
$t_history = history_get_events_array( $f_issue_id );
?>
}
layout_page_end();
/**
* return formatted string with all the details on the requested relationship
* @param integer $p_bug_id A bug identifier.
* @param BugRelationshipData $p_relationship A bug relationship object.
* @param boolean $p_html_preview Whether to include style/hyperlinks - if preview is false, we prettify the output.
* @param boolean $p_show_project Show Project details.
* @return string
*/
function bug_view_relationship_get_details( $p_bug_id, BugRelationshipData $p_relationship, $p_html_preview = false, $p_show_project = false ) {
if( $p_bug_id == $p_relationship->src_bug_id ) {
# root bug is in the source side, related bug in the destination side
$t_related_project_id = $p_relationship->dest_bug_id;
$t_related_project_name = project_get_name( $p_relationship->dest_project_id );
$t_related_bug_id = $p_relationship->dest_bug_id;
$t_relationship_descr = relationship_get_description_src_side( $p_relationship->type );
} else {
# root bug is in the dest side, related bug in the source side
$t_related_project_id = $p_relationship->src_bug_id;
$t_related_bug_id = $p_relationship->src_bug_id;
$t_related_project_name = project_get_name( $p_relationship->src_project_id );
$t_relationship_descr = relationship_get_description_dest_side( $p_relationship->type );
}
# related bug not existing...
if( !bug_exists( $t_related_bug_id ) ) {
return '';
}
# user can access to the related bug at least as a viewer
if( !access_has_bug_level( config_get( 'view_bug_threshold', null, null, $t_related_project_id ), $t_related_bug_id ) ) {
return '';
}
if( $p_html_preview == false ) {
$t_td = '
';} else {
$t_td = '
';}
# get the information from the related bug and prepare the link
$t_bug = bug_get( $t_related_bug_id, false );
$t_status_string = get_enum_element( 'status', $t_bug->status, auth_get_current_user_id(), $t_bug->project_id );
$t_resolution_string = get_enum_element( 'resolution', $t_bug->resolution, auth_get_current_user_id(), $t_bug->project_id );
$t_relationship_info_html = $t_td . string_no_break( $t_relationship_descr ) . '
';if( $p_html_preview == false ) {
# choose color based on status
$t_status_css = html_get_status_css_fg( $t_bug->status, auth_get_current_user_id(), $t_bug->project_id );
$t_relationship_info_html .= '
' . string_display_line( bug_format_id( $t_related_bug_id ) ) . '';$t_relationship_info_html .= '
' . icon_get( 'fa-square', 'fa-status-box ' . $t_status_css );$t_relationship_info_html .= ' ' . string_display_line( $t_status_string ) . '
';} else {
$t_relationship_info_html .= $t_td . string_display_line( bug_format_id( $t_related_bug_id ) ) . '';
$t_relationship_info_html .= $t_td . string_display_line( $t_status_string ) . ' ';
}
# get the handler name of the related bug
$t_relationship_info_html .= $t_td;
if( $t_bug->handler_id > 0 ) {
$t_relationship_info_html .= string_no_break( prepare_user_name( $t_bug->handler_id ) );
}
$t_relationship_info_html .= ' ';
# add project name
if( $p_show_project ) {
$t_relationship_info_html .= $t_td . string_display_line( $t_related_project_name ) . ' ';
}
# add summary
$t_relationship_info_html .= $t_td . string_display_line_links( $t_bug->summary );
if( VS_PRIVATE == $t_bug->view_state ) {
$t_relationship_info_html .= icon_get( 'fa-lock', '', lang_get( 'private' ) );
}
# add delete link if bug not read only and user has access level
if( !bug_is_readonly( $p_bug_id ) && !current_user_is_anonymous() && ( $p_html_preview == false ) ) {
if( access_has_bug_level( config_get( 'update_bug_threshold' ), $p_bug_id ) ) {
$t_relationship_info_html .= '
';
}
}
$t_relationship_info_html .= ' ';
$t_relationship_info_html = '
' . $t_relationship_info_html . '';return $t_relationship_info_html;
}
/**
* print ALL the RELATIONSHIPS OF A SPECIFIC BUG
* @param integer $p_bug_id A bug identifier.
* @return string
*/
function bug_view_relationship_get_summary_html( $p_bug_id ) {
$t_summary = '';
# A variable that will be set by the following call to indicate if relationships belong
# to multiple projects.
$t_show_project = false;
$t_relationship_all = relationship_get_all( $p_bug_id, $t_show_project );
$t_relationship_all_count = count( $t_relationship_all );
# prepare the relationships table
for( $i = 0; $i < $t_relationship_all_count; $i++ ) {
$t_summary .= bug_view_relationship_get_details( $p_bug_id, $t_relationship_all[$i], /* html_preview */ false, $t_show_project );
}
if( !is_blank( $t_summary ) ) {
if( relationship_can_resolve_bug( $p_bug_id ) == false ) {
$t_summary .= '
' .lang_get( 'relationship_warning_blocking_bugs_not_resolved' ) . '
';}
$t_summary = '
';}
return $t_summary;
}
/**
* print HTML relationship form
* @param integer $p_bug_id A bug identifier.
* @param bool $p_can_update Can update relationships?
* @return void
*/
function bug_view_relationship_view_box( $p_bug_id, $p_can_update ) {
$t_relationships_html = bug_view_relationship_get_summary_html( $p_bug_id );
if( !$p_can_update && empty( $t_relationships_html ) ) {
return;
}
$t_relationship_graph = ON == config_get( 'relationship_graph_enable' );
$t_event_buttons = event_signal( 'EVENT_MENU_ISSUE_RELATIONSHIP', $p_bug_id );
$t_show_top_div = $p_can_update || $t_relationship_graph || !empty( $t_event_buttons );
?>
$t_collapse_block = is_collapsed( 'relationships' );
$t_block_css = $t_collapse_block ? 'collapsed' : '';
$t_block_icon = $t_collapse_block ? 'fa-chevron-down' : 'fa-chevron-up';
?>
}
/**
* Print Change Status to: button
* This code is similar to print_status_option_list except
* there is no masking, except for the current state
*
* @param BugData $p_bug A valid bug object.
* @return void
*/
function bug_view_button_bug_change_status( BugData $p_bug ) {
$t_current_access = access_get_project_level( $p_bug->project_id );
$t_enum_list = get_status_option_list(
$t_current_access,
$p_bug->status,
false,
# Add close if user is bug's reporter, still has rights to report issues
# (to prevent users downgraded to viewers from updating issues) and
# reporters are allowed to close their own issues
( bug_is_user_reporter( $p_bug->id, auth_get_current_user_id() )
&& access_has_bug_level( config_get( 'report_bug_threshold' ), $p_bug->id )
&& ON == config_get( 'allow_reporter_close' )
),
$p_bug->project_id );
if( count( $t_enum_list ) > 0 ) {
# resort the list into ascending order after noting the key from the first element (the default)
$t_default = key( $t_enum_list );
ksort( $t_enum_list );
echo '
';# CSRF protection not required here - form does not result in modifications
$t_button_text = lang_get( 'bug_status_to_button' );
echo '';
echo ' ';
# space at beginning of line is important
foreach( $t_enum_list as $t_key => $t_val ) {
echo '
check_selected( $t_key, $t_default );
echo '>' . $t_val . '
';}
echo '';
$t_bug_id = string_attribute( $p_bug->id );
echo '' . "\n";
echo '' . "\n";
echo '
' . "\n";}
}
/**
* Print Assign To: combo box of possible handlers
* @param BugData $p_bug Bug object.
* @return void
*/
function bug_view_button_bug_assign_to( BugData $p_bug ) {
$t_current_user_id = auth_get_current_user_id();
$t_options = array();
$t_default_assign_to = null;
if( ( $p_bug->handler_id != $t_current_user_id )
&& access_has_bug_level( config_get( 'handle_bug_threshold' ), $p_bug->id, $t_current_user_id )
) {
$t_options[] = array(
$t_current_user_id,
'[' . lang_get( 'myself' ) . ']',
);
$t_default_assign_to = $t_current_user_id;
}
if( ( $p_bug->handler_id != $p_bug->reporter_id )
&& user_exists( $p_bug->reporter_id )
&& access_has_bug_level( config_get( 'handle_bug_threshold' ), $p_bug->id, $p_bug->reporter_id )
) {
$t_options[] = array(
$p_bug->reporter_id,
'[' . lang_get( 'reporter' ) . ']',
);
if( $t_default_assign_to === null ) {
$t_default_assign_to = $p_bug->reporter_id;
}
}
echo '
';echo form_security_field( 'bug_update' );
echo '';
echo '';
$t_button_text = lang_get( 'bug_assign_to_button' );
echo '';
echo ' ';
# space at beginning of line is important
$t_already_selected = false;
foreach( $t_options as $t_entry ) {
$t_id = (int)$t_entry[0];
$t_caption = string_attribute( $t_entry[1] );
# if current user and reporter can't be selected, then select the first
# user in the list.
if( $t_default_assign_to === null ) {
$t_default_assign_to = $t_id;
}
echo '
if( ( $t_id == $t_default_assign_to ) && !$t_already_selected ) {
check_selected( $t_id, $t_default_assign_to );
$t_already_selected = true;
}
echo '>' . $t_caption . '
';}
# allow un-assigning if already assigned.
if( $p_bug->handler_id != 0 ) {
echo '';
}
# 0 means currently selected
print_assign_to_option_list( 0, $p_bug->project_id );
echo '';
$t_bug_id = string_attribute( $p_bug->id );
echo '' . "\n";
echo '
' . "\n";}
/**
* Print all buttons for view bug pages
* @param integer $p_bug_id A valid bug identifier.
* @param array $p_flags Flags from issue view command
* @return void
*/
function bug_view_action_buttons( $p_bug_id, $p_flags ) {
$t_bug = bug_get( $p_bug_id );
echo '
# UPDATE button
if( $p_flags['can_update'] ) {
echo '
html_button( string_get_bug_update_page(), lang_get( 'edit' ), array( 'bug_id' => $p_bug_id ) );
echo '
}
# ASSIGN button
if( $p_flags['can_assign'] ) {
echo '
bug_view_button_bug_assign_to( $t_bug );
echo '
}
# Change status button/dropdown
if( $p_flags['can_change_status'] ) {
echo '
bug_view_button_bug_change_status( $t_bug );
echo '
}
# Unmonitor
if( $p_flags['can_unmonitor'] ) {
echo '
html_button( 'bug_monitor_delete.php', lang_get( 'unmonitor_bug_button' ), array( 'bug_id' => $p_bug_id ) );
echo '
}
# Monitor
if( $p_flags['can_monitor'] ) {
echo '
html_button( 'bug_monitor_add.php', lang_get( 'monitor_bug_button' ), array( 'bug_id' => $p_bug_id ) );
echo '
}
# Stick
if( $p_flags['can_sticky'] ) {
echo '
html_button( 'bug_stick.php', lang_get( 'stick_bug_button' ), array( 'bug_id' => $p_bug_id, 'action' => 'stick' ) );
echo '
}
# Unstick
if( $p_flags['can_unsticky'] ) {
echo '
html_button( 'bug_stick.php', lang_get( 'unstick_bug_button' ), array( 'bug_id' => $p_bug_id, 'action' => 'unstick' ) );
echo '
}
# CLONE button
if( $p_flags['can_clone'] ) {
echo '
html_button( string_get_bug_report_url(), lang_get( 'create_child_bug_button' ), array( 'm_id' => $p_bug_id ) );
echo '
}
# REOPEN button
if( $p_flags['can_reopen'] ) {
echo '
$t_reopen_status = config_get( 'bug_reopen_status', null, null, $t_bug->project_id );
html_button(
'bug_change_status_page.php',
lang_get( 'reopen_bug_button' ),
array( 'id' => $t_bug->id, 'new_status' => $t_reopen_status, 'change_type' => BUG_UPDATE_TYPE_REOPEN ) );
echo '
}
# CLOSE button
if( $p_flags['can_close'] ) {
$t_closed_status = config_get( 'bug_closed_status_threshold', null, null, $t_bug->project_id );
echo '
html_button(
'bug_change_status_page.php',
lang_get( 'close' ),
array( 'id' => $t_bug->id, 'new_status' => $t_closed_status, 'change_type' => BUG_UPDATE_TYPE_CLOSE ) );
echo '
}
# MOVE button
if( $p_flags['can_move'] ) {
echo '
html_button( 'bug_actiongroup_page.php', lang_get( 'move' ), array( 'bug_arr[]' => $p_bug_id, 'action' => 'MOVE' ) );
echo '
}
# DELETE button
if( $p_flags['can_delete'] ) {
echo '
html_button( 'bug_actiongroup_page.php', lang_get( 'delete' ), array( 'bug_arr[]' => $p_bug_id, 'action' => 'DELETE' ) );
echo '
}
helper_call_custom_function( 'print_bug_view_page_custom_buttons', array( $p_bug_id ) );
echo '
}
一键复制
编辑
Web IDE
原始数据
按行查看
历史