You are here

function drupagram_drupagram_accounts in Drupagram 6

Same name and namespace in other branches
  1. 7 drupagram.module \drupagram_drupagram_accounts()

An implementation of hook_drupagram_accounts. We want to move this into a separate module eventually, but sticking the code here and using a hook lets other modules solve the 'what accounts can a user post with' problem in cleaner ways.

Return value

array with Instagram accounts

File

./drupagram.module, line 101

Code

function drupagram_drupagram_accounts($account) {
  module_load_include('inc', 'drupagram');
  $query = "SELECT da.drupagram_id FROM {drupagram_account} da";
  $condition = " WHERE da.uid = %d";
  if (user_access('use global drupagram account', $account)) {
    $condition .= " OR da.is_global=1";
  }
  $query = $query . $condition;
  $drupagram_accounts = db_query($query, $account->uid);
  $drupagram_accounts_list = array();
  while ($drupagram_account = db_fetch_object($drupagram_accounts)) {
    $drupagram_accounts_list[] = drupagram_account_load($drupagram_account->drupagram_id);
  }
  return $drupagram_accounts_list;
}