You are here

function twitter_load_authenticated_accounts in Twitter 7.6

Same name and namespace in other branches
  1. 6.5 twitter.inc \twitter_load_authenticated_accounts()
  2. 7.5 twitter.inc \twitter_load_authenticated_accounts()

Returns a list of authenticated global or user-specific Twitter accounts.

Parameters

int $uid: Optional Drupal user ID to limit the results against.

bool $access_global: Whether or not to load the global accounts too.

bool $force: Loads accounts regardless of other access limits. Should be used with care and only for limited scenarios that do would not pose a security risk.

Return value

array List of TwitterUser objects. Will always include global accounts, will optionally include accounts from a specific user.

4 calls to twitter_load_authenticated_accounts()
twitter_actions_account_options in twitter_actions/twitter_actions.module
Returns a list of authenticated Twitter accounts to be used as options.
twitter_connect in ./twitter.inc
Connect to the Twitter API.
twitter_drush_tweet in ./twitter.drush.inc
Callback for Drush command 'twitter-tweet'.
twitter_post_field_widget_form in twitter_post/twitter_post.field.inc
Implements hook_field_widget_form().

File

./twitter.inc, line 135

Code

function twitter_load_authenticated_accounts($uid = NULL, $access_global = TRUE, $force = FALSE) {
  $auth_accounts = array();

  // Load every Twitter account, check to see if each one is suitable.
  foreach (twitter_load_accounts() as $index => $twitter_account) {

    // Only include authenticated accounts.
    if ($twitter_account
      ->is_auth()) {

      // Only include either global accounts or, if a $uid was passed in,
      // accounts that are owned by the requested user.
      if ($force || $access_global && $twitter_account->is_global || isset($uid) && $uid == $twitter_account->uid) {
        $auth_accounts[] = $twitter_account;
      }
    }
  }
  return $auth_accounts;
}