Skip to content

Commit

Permalink
Cleanup: move function from view.php to locallib
Browse files Browse the repository at this point in the history
  • Loading branch information
karenliulll committed Apr 3, 2024
1 parent 0ad6b4c commit 5f46466
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
27 changes: 27 additions & 0 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1314,3 +1314,30 @@ 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) {
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;
$hostmoodleuser->alternatename = '';
$hostmoodleuser->firstnamephonetic = '';
$hostmoodleuser->lastnamephonetic = '';
$hostmoodleuser->middlename = '';

return fullname($hostmoodleuser);
} catch (moodle_exception $error) {
return null;
}
}
27 changes: 0 additions & 27 deletions view.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,33 +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) {
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;
$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);

$stryes = get_string('yes');
Expand Down

0 comments on commit 5f46466

Please sign in to comment.