Skip to content

Commit

Permalink
MDL-50130 users: Filter profile fields data in external functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jleyva authored and stronk7 committed Jun 30, 2015
1 parent 0b45c56 commit f804c73
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion user/lib.php
Expand Up @@ -335,8 +335,17 @@ function user_get_user_details($user, $course = null, array $userfields = array(
$newfield = 'profile_field_'.$field->datatype;
$formfield = new $newfield($field->id, $user->id);
if ($formfield->is_visible() and !$formfield->is_empty()) {

// We only use display_data in fields that require text formatting.
if ($field->datatype == 'text' or $field->datatype == 'textarea') {
$fieldvalue = $formfield->display_data();
} else {
// Cases: datetime, checkbox and menu.
$fieldvalue = $formfield->data;
}

$userdetails['customfields'][] =
array('name' => $formfield->field->name, 'value' => $formfield->data,
array('name' => $formfield->field->name, 'value' => $fieldvalue,
'type' => $field->datatype, 'shortname' => $formfield->field->shortname);
}
}
Expand Down

0 comments on commit f804c73

Please sign in to comment.