From c2282bc6ae9e1fde7f96a4a3e6ce82e61566efb9 Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Thu, 4 May 2017 20:19:45 +1200 Subject: [PATCH] Fix #259 undefined property warnings when showing temp users. --- classes/structure.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/classes/structure.php b/classes/structure.php index 8821b49..3284551 100644 --- a/classes/structure.php +++ b/classes/structure.php @@ -678,6 +678,8 @@ class mod_attendance_structure { // Convert a tempuser record into a user object. protected static function tempuser_to_user($tempuser) { + global $CFG; + $ret = (object)array( 'id' => $tempuser->studentid, 'firstname' => $tempuser->fullname, @@ -689,11 +691,17 @@ class mod_attendance_structure { 'picture' => 0, 'type' => 'temporary', ); - foreach (get_all_user_name_fields() as $namefield) { + $allfields = get_all_user_name_fields(); + if (!empty($CFG->showuseridentity)) { + $allfields = array_merge($allfields, explode(',', $CFG->showuseridentity)); + } + + foreach ($allfields as $namefield) { if (!isset($ret->$namefield)) { $ret->$namefield = ''; } } + return $ret; }