From f8c54a7469204561baa05317dc8ccdfd19934911 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Tue, 2 Jul 2013 20:28:34 +0200 Subject: [PATCH] MDL-37516 Translate fieldnames on output only. This reverts a change performed by the previous commit where user fieldnames were being translated (and cached) when fetched, causing the information to remain static later, not responding to language switches (and perhaps leading to other problems if those structures are used lated for DB / $USER comparisons. With the commit, the translation happens on output, so no potential interferences will happen and, also, the information changes dynamically on lang switching. --- lib/conditionlib.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/conditionlib.php b/lib/conditionlib.php index 6e9dc833a4e..00af5730e1c 100644 --- a/lib/conditionlib.php +++ b/lib/conditionlib.php @@ -547,7 +547,7 @@ abstract class condition_info_base { } } else { $field = $condition->userfield; - $fieldname = get_user_field_name($condition->userfield); + $fieldname = $condition->userfield; } $details = new stdClass; $details->fieldname = $fieldname; @@ -828,7 +828,9 @@ abstract class condition_info_base { // Need the array of operators foreach ($this->item->conditionsfield as $field => $details) { $a = new stdclass; - $a->field = format_string($details->fieldname, true, array('context' => $context)); + // Display the fieldname into current lang. + $translatedfieldname = get_user_field_name($details->fieldname); + $a->field = format_string($translatedfieldname, true, array('context' => $context)); $a->value = s($details->value); $information .= html_writer::start_tag('li'); $information .= get_string('requires_user_field_'.$details->operator, 'condition', $a) . ' ';