mantis view.php,bug_view_inc.php

# 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 '

';

echo '

';

echo '

';

print_icon( 'fa-bars', 'ace-icon' );

echo string_display_line( $t_issue_view['form_title'] );

echo '';

echo '

';

echo '

';

echo '

';

echo '

';

# Send Bug Reminder

if( $t_flags['reminder_can_add'] ) {

print_small_button( 'bug_reminder_page.php?bug_id=' . $f_issue_id, lang_get( 'bug_reminder' ) );

}

if( isset( $t_issue_view['wiki_link'] ) ) {

print_small_button( $t_issue_view['wiki_link'], lang_get( 'wiki' ) );

}

# TODO: should be moved to command

foreach ( $t_issue_view['links'] as $t_plugin => $t_hooks ) {

foreach( $t_hooks as $t_hook ) {

if( is_array( $t_hook ) ) {

foreach( $t_hook as $t_label => $t_href ) {

if( is_numeric( $t_label ) ) {

print_bracket_link_prepared( $t_href );

} else {

print_small_button( $t_href, $t_label );

}

}

} elseif( !empty( $t_hook ) ) {

print_bracket_link_prepared( $t_hook );

}

}

}

# Jump to Bugnotes

print_small_button( '#bugnotes', lang_get( 'jump_to_bugnotes' ) );

# Display or Jump to History

if( $t_flags['history_show'] ) {

if( $f_history ) {

$t_history_link = '#history';

$t_history_label = lang_get( 'jump_to_history' );

} else {

$t_history_link = 'view.php?id=' . $f_issue_id . '&history=1#history';

$t_history_label = lang_get( 'display_history' );

}

print_small_button( $t_history_link, $t_history_label );

}

echo '

';

# prev/next links

echo '

';

if( $t_bugslist ) {

$t_bugslist = explode( ',', $t_bugslist );

$t_index = array_search( $f_issue_id, $t_bugslist );

if( false !== $t_index ) {

if( isset( $t_bugslist[$t_index-1] ) ) {

print_small_button( 'view.php?id='.$t_bugslist[$t_index-1], '<<' );

}

if( isset( $t_bugslist[$t_index+1] ) ) {

print_small_button( 'view.php?id='.$t_bugslist[$t_index+1], '>>' );

}

}

}

echo '

';

echo '

';

echo '

';

echo '

';

echo '

if( $t_top_buttons_enabled ) {

echo '';

echo '

';

echo '

';

bug_view_action_buttons( $f_issue_id, $t_flags );

echo '

';

echo '

';

echo '

';

}

if( $t_bottom_buttons_enabled ) {

echo '

';

echo '

';

bug_view_action_buttons( $f_issue_id, $t_flags );

echo '

';

echo '

';

}

echo '

';

if( $t_flags['id_show'] || $t_flags['project_show'] || $t_flags['category_show'] ||

$t_flags['view_state_show'] || $t_flags['created_at_show'] || $t_flags['updated_at_show']

) {

# Labels

echo '

';

echo '

', $t_flags['id_show'] ? lang_get( 'id' ) : '', '';

echo '

', $t_flags['project_show'] ? lang_get( 'email_project' ) : '', '';

echo '

', $t_flags['category_show'] ? lang_get( 'category' ) : '', '';

echo '

', $t_flags['view_state_show'] ? lang_get( 'view_status' ) : '', '';

echo '

', $t_flags['created_at_show'] ? lang_get( 'date_submitted' ) : '', '';

echo '

', $t_flags['updated_at_show'] ? lang_get( 'last_update' ) : '','';

echo '

';

echo '

';

# Bug ID

echo '

', $t_flags['id_show'] ? $t_issue_view['id_formatted'] : '', '';

# Project

echo '

', $t_flags['project_show'] && isset( $t_issue['project']['name'] ) ? string_display_line( $t_issue['project']['name'] ) : '', '';

# Category

echo '

',

$t_flags['category_show'] && isset( $t_issue['category']['name'] )

? string_display_line( $t_issue['category']['name'] )

: '',

'

';

# View Status

echo '

', $t_flags['view_state_show'] && isset( $t_issue['view_state']['label'] ) ? string_display_line( $t_issue['view_state']['label'] ) : '', '';

# Date Submitted

echo '

', $t_flags['created_at_show'] ? $t_issue_view['created_at'] : '', '';

# Date Updated

echo '

', $t_flags['updated_at_show'] ? $t_issue_view['updated_at'] : '', '';

echo '

';

# spacer

echo '

';

echo '

';

}

#

# Reporter, Handler, Due Date

#

if( $t_flags['reporter_show'] || $t_flags['handler_show'] || $t_flags['due_date_show'] ) {

echo '

';

$t_spacer = 0;

# Reporter

if( $t_flags['reporter_show'] ) {

echo '

', lang_get( 'reporter' ), '';

echo '

';

print_user_with_subject( $t_issue['reporter']['id'], $f_issue_id );

echo '

';

} else {

$t_spacer += 2;

}

# Handler

if( $t_flags['handler_show'] ) {

echo '

', lang_get( 'assigned_to' ), '';

echo '

';

if( isset( $t_issue['handler'] ) ) {

print_user_with_subject( $t_issue['handler']['id'], $f_issue_id );

}

echo '

';

} else {

$t_spacer += 2;

}

# Due Date

if( $t_flags['due_date_show'] ) {

echo '

', lang_get( 'due_date' ), '';

$t_css = 'bug-due-date';

if( $t_issue_view['overdue'] !== false ) {

$t_css .= ' due-' . $t_issue_view['overdue'];

}

echo '

', $t_issue_view['due_date'], '';

} else {

$t_spacer += 2;

}

if( $t_spacer > 0 ) {

echo '

 ';

}

echo '

';

}

#

# Priority, Severity, Reproducibility

#

if( $t_flags['priority_show'] || $t_flags['severity_show'] || $t_flags['reproducibility_show'] ) {

echo '

';

$t_spacer = 0;

# Priority

if( $t_flags['priority_show'] ) {

echo '

', lang_get( 'priority' ), '';

echo '

', string_display_line( $t_issue['priority']['label'] ), '';

} else {

$t_spacer += 2;

}

# Severity

if( $t_flags['severity_show'] ) {

echo '

', lang_get( 'severity' ), '';

echo '

', string_display_line( $t_issue['severity']['label'] ), '';

} else {

$t_spacer += 2;

}

# Reproducibility

if( $t_flags['reproducibility_show'] ) {

echo '

', lang_get( 'reproducibility' ), '';

echo '

', string_display_line( $t_issue['reproducibility']['label'] ), '';

} else {

$t_spacer += 2;

}

# spacer

if( $t_spacer > 0 ) {

echo '

 ';

}

echo '

';

}

#

# Status, Resolution

#

if( $t_flags['status_show'] || $t_flags['resolution_show'] ) {

echo '

';

$t_spacer = 2;

# Status

if( $t_flags['status_show'] ) {

echo '

', lang_get( 'status' ), '';

# choose color based on status

$t_status_css = html_get_status_css_fg( $t_issue['status']['id'] );

echo '

';

print_icon( 'fa-square', 'fa-status-box ' . $t_status_css );

echo ' ' . string_display_line( $t_issue['status']['label'] ), '

';

} else {

$t_spacer += 2;

}

# Resolution

if( $t_flags['resolution_show'] ) {

echo '

', lang_get( 'resolution' ), '';

echo '

', string_display_line( $t_issue['resolution']['label'] ), '';

} else {

$t_spacer += 2;

}

# spacer

if( $t_spacer > 0 ) {

echo '

 ';

}

echo '

';

}

#

# Projection, ETA

#

if( $t_flags['projection_show'] || $t_flags['eta_show'] ) {

echo '

';

$t_spacer = 2;

if( $t_flags['projection_show'] ) {

# Projection

echo '

', lang_get( 'projection' ), '';

echo '

', string_display_line( $t_issue['projection']['label'] ), '';

} else {

$t_spacer += 2;

}

# ETA

if( $t_flags['eta_show'] ) {

echo '

', lang_get( 'eta' ), '';

echo '

', string_display_line( $t_issue['eta']['label'] ), '';

} else {

$t_spacer += 2;

}

echo '

 ';

echo '

';

}

#

# Platform, OS, OS Version

#

if( ( $t_flags['profiles_platform_show'] && isset( $t_issue['platform'] ) && !is_blank( $t_issue['platform'] ) ) ||

( $t_flags['profiles_os_show'] && isset( $t_issue['os'] ) && !is_blank( $t_issue['os'] ) ) ||

( $t_flags['profiles_os_build_show'] && isset( $t_issue['os_build'] ) && !is_blank( $t_issue['os_build'] ) ) ) {

$t_spacer = 0;

echo '

';

# Platform

if( $t_flags['profiles_platform_show'] && isset( $t_issue['platform'] ) && !is_blank( $t_issue['platform'] ) ) {

echo '

', lang_get( 'platform' ), '';

echo '

', string_display_line( $t_issue['platform'] ), '';

} else {

$t_spacer += 2;

}

# Operating System

if( $t_flags['profiles_os_show'] && isset( $t_issue['os'] ) && !is_blank( $t_issue['os'] ) ) {

echo '

', lang_get( 'os' ), '';

echo '

', string_display_line( $t_issue['os'] ), '';

} else {

$t_spacer += 2;

}

# OS Version

if( $t_flags['profiles_os_build_show'] && isset( $t_issue['os_build'] ) && !is_blank( $t_issue['os_build'] ) ) {

echo '

', lang_get( 'os_build' ), '';

echo '

', string_display_line( $t_issue['os_build'] ), '';

} else {

$t_spacer += 2;

}

if( $t_spacer > 0 ) {

echo '

 ';

}

echo '

';

}

#

# Product Version, Product Build

#

if( ( $t_flags['versions_product_version_show'] && isset( $t_issue['version'] ) ) ||

( $t_flags['versions_product_build_show'] && isset( $t_issue['build'] ) ) ) {

$t_spacer = 2;

echo '

';

# Product Version

if( $t_flags['versions_product_version_show'] && isset( $t_issue['version'] ) ) {

echo '

', lang_get( 'product_version' ), '';

echo '

', string_display_line( $t_issue['version']['name'] ), '';

} else {

$t_spacer += 2;

}

# Product Build

if( $t_flags['versions_product_build_show'] && isset( $t_issue['build'] ) ) {

echo '

', lang_get( 'product_build' ), '';

echo '

', string_display_line( $t_issue['build'] ), '';

} else {

$t_spacer += 2;

}

# spacer

echo '

 ';

echo '

';

}

#

# Target Version, Fixed In Version

#

if( ( $t_flags['versions_target_version_show'] && isset( $t_issue['target_version'] ) ) ||

( $t_flags['versions_fixed_in_version_show'] && isset( $t_issue['fixed_in_version'] ) ) ) {

$t_spacer = 2;

echo '

';

# target version

if( $t_flags['versions_target_version_show'] && isset( $t_issue['target_version'] ) ) {

# Target Version

echo '

', lang_get( 'target_version' ), '';

echo '

', string_display_line( $t_issue['target_version']['name'] ), '';

} else {

$t_spacer += 2;

}

# fixed in version

if( $t_flags['versions_fixed_in_version_show'] && isset( $t_issue['fixed_in_version'] ) ) {

echo '

', lang_get( 'fixed_in_version' ), '';

echo '

', string_display_line( $t_issue['fixed_in_version']['name'] ), '';

} else {

$t_spacer += 2;

}

# spacer

echo '

 ';

echo '

';

}

#

# Bug Details Event Signal

#

event_signal( 'EVENT_VIEW_BUG_DETAILS', array( $f_issue_id ) );

# spacer

echo '

';

echo '

';

#

# Bug Details (screen wide fields)

#

# Summary

if( $t_flags['summary_show'] && isset( $t_issue['summary'] ) ) {

echo '

';

echo '

', lang_get( 'summary' ), '';

echo '

', string_display_line( bug_format_id( $f_issue_id ) . ': ' . $t_issue['summary'] ), '';

echo '

';

}

# Description

if( $t_flags['description_show'] && isset( $t_issue['description'] ) ) {

echo '

';

echo '

', lang_get( 'description' ), '';

echo '

', string_display_links( $t_issue['description'] ), '';

echo '

';

}

# Steps to Reproduce

if( $t_flags['steps_to_reproduce_show'] && isset( $t_issue['steps_to_reproduce'] ) ) {

echo '

';

echo '

', lang_get( 'steps_to_reproduce' ), '';

echo '

', string_display_links( $t_issue['steps_to_reproduce'] ), '';

echo '

';

}

# Additional Information

if( $t_flags['additional_information_show'] && isset( $t_issue['additional_information'] ) ) {

echo '

';

echo '

', lang_get( 'additional_information' ), '';

echo '

', string_display_links( $t_issue['additional_information'] ), '';

echo '

';

}

# Tagging

if( $t_flags['tags_show'] ) {

echo '

';

echo '

', lang_get( 'tags' ), '';

echo '

';

tag_display_attached( $f_issue_id );

echo '

';

}

# Attach Tags

if( $t_flags['tags_can_attach'] ) {

echo '

';

echo '

', lang_get( 'tag_attach_long' ), '';

echo '

';

print_tag_attach_form( $f_issue_id );

echo '

';

}

# spacer

echo '

';

echo '

';

# Custom Fields

if( isset( $t_issue['custom_fields'] ) ) {

foreach( $t_issue['custom_fields'] as $t_custom_field ) {

$t_def = custom_field_get_definition( $t_custom_field['field']['id'] );

echo '

';

echo '

', string_display_line( lang_get_defaulted( $t_def['name'] ) ), '';

echo '

';

print_custom_field_value( $t_def, $t_custom_field['field']['id'], $f_issue_id );

echo '

';

}

# spacer

echo '

';

echo '

';

}

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 '';

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';

?>

if( !isset( $t_issue['monitors'] ) || count( $t_issue['monitors'] ) == 0 ) {

echo lang_get( 'no_users_monitoring_bug' );

} else {

$t_first_user = true;

foreach( $t_issue['monitors'] as $t_monitor_user ) {

if( $t_first_user ) {

$t_first_user = false;

} else {

echo ', ';

}

print_user( $t_monitor_user['id'] );

if( $t_flags['monitor_can_delete'] ) {

echo '

. 'href="' . helper_mantis_url( 'bug_monitor_delete.php' )

. '?bug_id=' . $f_issue_id . '&user_id=' . $t_monitor_user['id']

. htmlspecialchars(form_security_param( 'bug_monitor_delete' ))

. '">'

. icon_get( 'fa-times' )

. '

';

}

}

}

if( $t_flags['monitor_can_add'] ) {

?>

}

# 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 );

?>

foreach( $t_history as $t_item ) {

?>

} # end for loop

?>

}

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 .= '

. 'href="bug_relationship_delete.php?bug_id=' . $p_bug_id

. '&rel_id=' . $p_relationship->id

. htmlspecialchars( form_security_param( 'bug_relationship_delete' ) )

. '">'

. icon_get( 'fa-trash-o', 'ace-icon bigger-115' )

. '

';

}

}

$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';

?>

if( $t_show_top_div ) {

?>

# Default relationship buttons

$t_buttons = array();

if( $t_relationship_graph ) {

$t_buttons[lang_get( 'relation_graph' )] =

'bug_relationship_graph.php?bug_id=' . $p_bug_id . '&graph=relation';

$t_buttons[lang_get( 'dependency_graph' )] =

'bug_relationship_graph.php?bug_id=' . $p_bug_id . '&graph=dependency';

}

# Plugin-added buttons

foreach( $t_event_buttons as $t_plugin => $t_plugin_buttons ) {

foreach( $t_plugin_buttons as $t_callback => $t_callback_buttons ) {

if( is_array( $t_callback_buttons ) ) {

$t_buttons = array_merge( $t_buttons, $t_callback_buttons );

}

}

}

?>

# Print the buttons, if any

foreach( $t_buttons as $t_label => $t_url ) {

print_small_button( $t_url, $t_label );

}

?>

if( $p_can_update ) {

?>

} # can update

?>

} # show top div

?>

}

/**

* 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

原始数据

按行查看

历史

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值