Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit c10fc915ad68f1d5dd46c40991ed2ea3c9b73be9 1 parent a6683d3
Eloy Lafuente (stronk7) stronk7 authored

Showing 1 changed file with 4 additions and 2 deletions. Show diff stats Hide diff stats

  1. +4 2 lib/conditionlib.php
6 lib/conditionlib.php
@@ -547,7 +547,7 @@ protected static function fill_availability_conditions_inner($item, $tableprefix
547 547 }
548 548 } else {
549 549 $field = $condition->userfield;
550   - $fieldname = get_user_field_name($condition->userfield);
  550 + $fieldname = $condition->userfield;
551 551 }
552 552 $details = new stdClass;
553 553 $details->fieldname = $fieldname;
@@ -828,7 +828,9 @@ public function get_full_information($modinfo=null) {
828 828 // Need the array of operators
829 829 foreach ($this->item->conditionsfield as $field => $details) {
830 830 $a = new stdclass;
831   - $a->field = format_string($details->fieldname, true, array('context' => $context));
  831 + // Display the fieldname into current lang.
  832 + $translatedfieldname = get_user_field_name($details->fieldname);
  833 + $a->field = format_string($translatedfieldname, true, array('context' => $context));
832 834 $a->value = s($details->value);
833 835 $information .= html_writer::start_tag('li');
834 836 $information .= get_string('requires_user_field_'.$details->operator, 'condition', $a) . ' ';

0 comments on commit c10fc91

Please sign in to comment.
Something went wrong with that request. Please try again.