Skip to content

Commit

Permalink
MDL-37516 Translate fieldnames on output only.
Browse files Browse the repository at this point in the history
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
stronk7 committed Jul 2, 2013
1 parent 122d593 commit bc6835b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/conditionlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -823,7 +823,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 .= get_string('requires_user_field_'.$details->operator, 'condition', $a) . ' ';
}
Expand Down

0 comments on commit bc6835b

Please sign in to comment.