You are here

function brightcove_get_clients_by_account_id in Brightcove Video Connect 7.6

Same name and namespace in other branches
  1. 7.7 brightcove.client.inc \brightcove_get_clients_by_account_id()

Loads all brightcove clients for a given brightcove account a drupal user has 'Use X client' permission to.

Parameters

string $account_id: The brightcove client account id.

object $account: The drupal user object.

2 calls to brightcove_get_clients_by_account_id()
BrightcoveVideoEntityController::load in ./brightcove.video.inc
Overridden.
MediaBrightcoveVideoStreamWrapper::brightcoveValues in brightcove_media/includes/MediaBrightcoveVideoStreamWrapper.inc
Extracts values from a brightcove:// or a brightcove-playlist:// uri.

File

./brightcove.client.inc, line 565
Client related code.

Code

function brightcove_get_clients_by_account_id($account_id, $account = NULL) {
  if (is_null($account)) {
    global $user;
    $account = $user;
  }

  // Get all client bcids belonging to this $account_id.
  $query = new EntityFieldQuery();
  $query
    ->entityCondition('entity_type', 'brightcove_client')
    ->propertyCondition('account_id', $account_id)
    ->addMetaData('account', user_load(1));
  $result = $query
    ->execute();

  // Only keep the clients this $account has 'use' access to.
  $bcids = [];
  if (isset($result['brightcove_client'])) {
    foreach ($result['brightcove_client'] as $bcid => $client_result) {
      if (_brightcove_client_access('use', $bcid, $account)) {
        $bcids[] = $bcid;
      }
    }
  }
  return entity_load('brightcove_client', $bcids);
}