You are here

function twitter_twitter_accounts in Twitter 7.3

Same name and namespace in other branches
  1. 6.5 twitter.module \twitter_twitter_accounts()
  2. 6.2 twitter.module \twitter_twitter_accounts()
  3. 6.3 twitter.module \twitter_twitter_accounts()
  4. 6.4 twitter.module \twitter_twitter_accounts()
  5. 7.6 twitter.module \twitter_twitter_accounts()
  6. 7.4 twitter.module \twitter_twitter_accounts()
  7. 7.5 twitter.module \twitter_twitter_accounts()

An implementation of hook_twitter_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 Twitter accounts

File

./twitter.module, line 251
Provides API integration with the Twitter microblogging service.

Code

function twitter_twitter_accounts($account) {
  module_load_include('inc', 'twitter');
  $query = db_select('twitter_account', 'ta')
    ->fields('ta', array(
    'twitter_uid',
  ));
  if (user_access('use global twitter account', $account)) {
    $or = db_or();
    $or
      ->condition('ta.uid', $account->uid);
    $or
      ->condition('ta.is_global', 1);
    $query
      ->condition($or);
  }
  else {
    $query
      ->condition('ta.uid', $account->uid);
  }
  $twitter_accounts = array();
  foreach ($query
    ->execute()
    ->fetchCol() as $twitter_uid) {
    $twitter_accounts[] = twitter_account_load($twitter_uid);
  }
  return $twitter_accounts;
}