Permalink
Browse files

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.
  • Loading branch information...
1 parent a6683d3 commit c10fc915ad68f1d5dd46c40991ed2ea3c9b73be9 @stronk7 stronk7 committed Jul 2, 2013
Showing with 4 additions and 2 deletions.
  1. +4 −2 lib/conditionlib.php
View
6 lib/conditionlib.php
@@ -547,7 +547,7 @@ protected static function fill_availability_conditions_inner($item, $tableprefix
}
} else {
$field = $condition->userfield;
- $fieldname = get_user_field_name($condition->userfield);
+ $fieldname = $condition->userfield;
}
$details = new stdClass;
$details->fieldname = $fieldname;
@@ -828,7 +828,9 @@ public function get_full_information($modinfo=null) {
// 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) . ' ';

0 comments on commit c10fc91

Please sign in to comment.