You are here

function commerce_file_license_user_allowed_licenses in Commerce File 7

Load all 'allowed' licenses for given account

Parameters

$account: A user object.

Return value

An array of entity objects, indexed by id.

File

includes/commerce_file.entities.inc, line 301
Handles file licenses and file license logs

Code

function commerce_file_license_user_allowed_licenses($account = NULL) {
  global $user;
  $licenses = array();
  if (!isset($account)) {
    $account = $user;
  }
  if (isset($account->uid)) {
    $allowed_statuses = commerce_file_license_statuses(array(
      'state' => 'allowed',
    ));
    $licenses = commerce_file_license_load_multiple(FALSE, array(
      'uid' => $account->uid,
      'status' => $allowed_statuses,
    ));
  }
  return $licenses;
}