You are here

function zoomapi_user_get in Zoom API 7

Get Zoom User.

Parameters

object $account: The Drupal user account to check if matching Zoom API account exists.

Return value

array An array of the Zoom user account information.

File

./zoomapi.module, line 203
Main file for the Zoom API module.

Code

function zoomapi_user_get($account) {
  if (empty($account->data['zoomapi_user_id'])) {
    return [];
  }
  $zoomapi_user = new ZoomAPIUser();
  $zoom_user = $zoomapi_user
    ->get($account->data['zoomapi_user_id']);

  // If we're unable to retrieve the user using the zoomapi_user_id on the
  // account then it's possible the user account was deleted directly on Zoom.
  // First search by email and update the data properties or remove the data
  // properties from the user.
  if (empty($zoom_user)) {

    // Zoom account found by email so update id.
    if ($zoom_user = zoomapi_user_find_by_email($account->data['zoomapi_user_email'])) {
      $account->data['zoomapi_user_id'] = $zoom_user['id'];
      user_save($account);
    }
    else {
      zoomapi_user_clean_account($account);
    }
  }
  return $zoom_user;
}