You are here

function gauth_account_load in Google Auth 7

Same name and namespace in other branches
  1. 7.2 gauth.module \gauth_account_load()

Get an array of all accounts or load a specific account.

@returns An array of accounts and their details.

Parameters

string $account_id: Name or id of the account to be loaded

bool $by_name: Set False if passing account id and True for account name

array $fields: Array of fields to be retrieved from the database

11 calls to gauth_account_load()
gauth_account_authenticate in ./gauth.module
Authenticate a google account.
gauth_account_delete in ./gauth.module
Delete an account.
gauth_account_edit_form in ./gauth.admin.inc
Form builder; Edit an account.
gauth_account_edit_form_validate in ./gauth.admin.inc
Validate handler for adding a new account to google auth accounts.
gauth_account_is_authenticated in ./gauth.module
Check if an account is authenticated or not.

... See full list

File

./gauth.module, line 328
Google Auth Api for drupal.

Code

function gauth_account_load($account_id = NULL, $by_name = TRUE, $fields = 'gauth_accounts') {
  $accounts = array();
  if ($by_name) {
    $filter = 'name';
  }
  else {
    $filter = 'id';
  }
  $query = db_select('gauth_accounts');
  if (is_array($fields)) {
    $query
      ->fields('gauth_accounts', $fields);
  }
  else {
    $query
      ->fields('gauth_accounts');
  }
  if ($account_id) {
    $accounts = $query
      ->condition($filter, $account_id, '=')
      ->execute()
      ->fetchAssoc();
  }
  else {
    $accounts = $query
      ->orderBy('id')
      ->execute()
      ->fetchAllAssoc($filter);
  }
  return $accounts;
}