Skip to content

Commit

Permalink
Fix issues with get_user_display_name declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
joel1124 committed Aug 19, 2024
1 parent 2d3210b commit 9bbbaa1
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 43 deletions.
44 changes: 44 additions & 0 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1497,3 +1497,47 @@ function zoom_get_registrant_join_url($useremail, $meetingid, $iswebinar) {

return false;
}

/**
* Get the display name for a Zoom user.
* This is wrapped in a function to avoid unnecessary API calls.
*
* @package mod_zoom
* @param string $zoomuserid Zoom user ID.
* @return ?string
*/
function zoom_get_user_display_name($zoomuserid) {
global $USER, $DB;

try {
$hostuser = zoom_get_user($zoomuserid);

// Compose Moodle user object for host.
$hostmoodleuser = new stdClass();
$hostmoodleuser->firstname = $hostuser->first_name;
$hostmoodleuser->lastname = $hostuser->last_name;

/**
* Joel Dapiawencd
* July 30, 2024
* If Zoom account first name & last name returns empty, use the First name and Last name record in the database.
*/
if (empty($hostmoodleuser->firstname) && empty($hostmoodleuser->lastname)) {
$hostrecord = $DB->get_record('user', array('email' => $hostuser->email));
if ($hostrecord) {
$hostmoodleuser->firstname = $hostrecord->firstname;
$hostmoodleuser->lastname = $hostrecord->lastname;
}
}
$hostmoodleuser->alternatename = '';
$hostmoodleuser->firstnamephonetic = '';
$hostmoodleuser->lastnamephonetic = '';
$hostmoodleuser->middlename = '';

return fullname($hostmoodleuser);


} catch (moodle_exception $error) {
return null;
}
}
43 changes: 0 additions & 43 deletions view.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,49 +90,6 @@
}
}

/**
* Get the display name for a Zoom user.
* This is wrapped in a function to avoid unnecessary API calls.
*
* @package mod_zoom
* @param string $zoomuserid Zoom user ID.
* @return ?string
*/
function zoom_get_user_display_name($zoomuserid) {
global $USER, $DB;

try {
$hostuser = zoom_get_user($zoomuserid);

// Compose Moodle user object for host.
$hostmoodleuser = new stdClass();
$hostmoodleuser->firstname = $hostuser->first_name;
$hostmoodleuser->lastname = $hostuser->last_name;

/**
* Joel Dapiawen
* July 30, 2024
* If Zoom account first name & last name returns empty, use the First name and Last name record in the database.
*/
if (empty($hostmoodleuser->firstname) && empty($hostmoodleuser->lastname)) {
$hostrecord = $DB->get_record('user', array('email' => $hostuser->email));
if ($hostrecord) {
$hostmoodleuser->firstname = $hostrecord->firstname;
$hostmoodleuser->lastname = $hostrecord->lastname;
}
}
$hostmoodleuser->alternatename = '';
$hostmoodleuser->firstnamephonetic = '';
$hostmoodleuser->lastnamephonetic = '';
$hostmoodleuser->middlename = '';

return fullname($hostmoodleuser);


} catch (moodle_exception $error) {
return null;
}
}

$isrecurringnotime = ($zoom->recurring && $zoom->recurrence_type == ZOOM_RECURRINGTYPE_NOTIME);

Expand Down

0 comments on commit 9bbbaa1

Please sign in to comment.