From eb011e1696afe41212121cd892e44a756c8c1fa7 Mon Sep 17 00:00:00 2001
From: Damien Regad <damien.regad@merckgroup.com>
Date: Fri, 6 Jan 2012 00:44:09 +0100
Subject: [PATCH] Fix cross-project display of custom severity and priority

When a custom severity is defined in a different project, its code
was displayed as @X@ instead of the corresponding string in the
severity column on the View Issues page.

The same problem applied to custom priorities

Fixes #13718
---
 core/columns_api.php |    4 ++--
 core/print_api.php   |   16 ++++++++--------
 my_view_inc.php      |    2 +-
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/core/columns_api.php b/core/columns_api.php
index dbba861..3acb4ac 100644
--- a/core/columns_api.php
+++ b/core/columns_api.php
@@ -931,7 +931,7 @@ function print_column_edit( $p_bug, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE
 function print_column_priority( $p_bug, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE ) {
 	echo '<td>';
 	if( ON == config_get( 'show_priority_text' ) ) {
-		print_formatted_priority_string( $p_bug->status, $p_bug->priority );
+		print_formatted_priority_string( $p_bug );
 	} else {
 		print_status_icon( $p_bug->priority );
 	}
@@ -1070,7 +1070,7 @@ function print_column_category_id( $p_bug, $p_columns_target = COLUMNS_TARGET_VI
  */
 function print_column_severity( $p_bug, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE ) {
 	echo '<td class="center">';
-	print_formatted_severity_string( $p_bug->status, $p_bug->severity );
+	print_formatted_severity_string( $p_bug );
 	echo '</td>';
 }
 
diff --git a/core/print_api.php b/core/print_api.php
index 764d5be..9e6304b 100644
--- a/core/print_api.php
+++ b/core/print_api.php
@@ -1143,13 +1143,13 @@ function print_bug_link( $p_bug_id, $p_detail_info = true ) {
 
 # formats the priority given the status
 # shows the priority in BOLD if the bug is NOT closed and is of significant priority
-function print_formatted_priority_string( $p_status, $p_priority ) {
-	$t_pri_str = get_enum_element( 'priority', $p_priority );
+function print_formatted_priority_string( $p_bug ) {
+	$t_pri_str = get_enum_element( 'priority', $p_bug->priority );
 	$t_priority_threshold = config_get( 'priority_significant_threshold' );
 
 	if( $t_priority_threshold >= 0 &&
-		$p_priority >= $t_priority_threshold &&
-		$p_status < config_get( 'bug_closed_status_threshold' ) ) {
+		$p_bug->priority >= $t_priority_threshold &&
+		$p_bug->status < config_get( 'bug_closed_status_threshold' ) ) {
 		echo "<span class=\"bold\">$t_pri_str</span>";
 	} else {
 		echo $t_pri_str;
@@ -1158,13 +1158,13 @@ function print_formatted_priority_string( $p_status, $p_priority ) {
 
 # formats the severity given the status
 # shows the severity in BOLD if the bug is NOT closed and is of significant severity
-function print_formatted_severity_string( $p_status, $p_severity ) {
-	$t_sev_str = get_enum_element( 'severity', $p_severity );
+function print_formatted_severity_string( $p_bug ) {
+	$t_sev_str = get_enum_element( 'severity', $p_bug->severity, auth_get_current_user_id(), $p_bug->project_id );
 	$t_severity_threshold = config_get( 'severity_significant_threshold' );
 
 	if( $t_severity_threshold >= 0 &&
-		$p_severity >= $t_severity_threshold &&
-		$p_status < config_get( 'bug_closed_status_threshold' ) ) {
+		$p_bug->severity >= $t_severity_threshold &&
+		$p_bug->status < config_get( 'bug_closed_status_threshold' ) ) {
 		echo "<span class=\"bold\">$t_sev_str</span>";
 	} else {
 		echo $t_sev_str;
diff --git a/my_view_inc.php b/my_view_inc.php
index cedc67f..c40b04b 100644
--- a/my_view_inc.php
+++ b/my_view_inc.php
@@ -461,7 +461,7 @@ echo "($v_start - $v_end / $t_bug_count)";
 	}
 
 	if( ON == config_get( 'show_priority_text' ) ) {
-		print_formatted_priority_string( $t_bug->status, $t_bug->priority );
+		print_formatted_priority_string( $t_bug );
 	} else {
 		print_status_icon( $t_bug->priority );
 	}
-- 
1.7.0.4

