mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 10:26:40 +02:00
MDL-42098 - Libraries: Alter fullname debugging logic to display when user name fields are missing.
This commit is contained in:
parent
56cc9b387e
commit
a49bc6c940
1 changed files with 13 additions and 6 deletions
|
@ -3562,6 +3562,19 @@ function ismoving($courseid) {
|
||||||
function fullname($user, $override=false) {
|
function fullname($user, $override=false) {
|
||||||
global $CFG, $SESSION;
|
global $CFG, $SESSION;
|
||||||
|
|
||||||
|
// Get all of the name fields.
|
||||||
|
$allnames = get_all_user_name_fields();
|
||||||
|
if ($CFG->debugdeveloper) {
|
||||||
|
foreach ($allnames as $allname) {
|
||||||
|
if (!array_key_exists($allname, $user)) {
|
||||||
|
// If all the user name fields are not set in the user object, then notify the programmer that it needs to be fixed.
|
||||||
|
debugging('You need to update your sql to include additional name fields in the user object.', DEBUG_DEVELOPER);
|
||||||
|
// Message has been sent, no point in sending the message multiple times.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!isset($user->firstname) and !isset($user->lastname)) {
|
if (!isset($user->firstname) and !isset($user->lastname)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -3589,17 +3602,11 @@ function fullname($user, $override=false) {
|
||||||
return get_string('fullnamedisplay', null, $user);
|
return get_string('fullnamedisplay', null, $user);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get all of the name fields.
|
|
||||||
$allnames = get_all_user_name_fields();
|
|
||||||
$requirednames = array();
|
$requirednames = array();
|
||||||
// With each name, see if it is in the display name template, and add it to the required names array if it is.
|
// With each name, see if it is in the display name template, and add it to the required names array if it is.
|
||||||
foreach ($allnames as $allname) {
|
foreach ($allnames as $allname) {
|
||||||
if (strpos($template, $allname) !== false) {
|
if (strpos($template, $allname) !== false) {
|
||||||
$requirednames[] = $allname;
|
$requirednames[] = $allname;
|
||||||
// If the field is in the template but not set in the user object then notify the programmer that it needs to be fixed.
|
|
||||||
if (!array_key_exists($allname, $user)) {
|
|
||||||
debugging('You need to update your sql to include additional name fields in the user object.', DEBUG_DEVELOPER);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue