You are here

function twitter_twitter_accounts in Twitter 6.2

Same name and namespace in other branches
  1. 6.5 twitter.module \twitter_twitter_accounts()
  2. 6.3 twitter.module \twitter_twitter_accounts()
  3. 6.4 twitter.module \twitter_twitter_accounts()
  4. 7.6 twitter.module \twitter_twitter_accounts()
  5. 7.3 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.

1 call to twitter_twitter_accounts()
twitter_user_settings in ./twitter.pages.inc

File

./twitter.module, line 272

Code

function twitter_twitter_accounts($drupal_user, $full_access = FALSE) {
  $accounts = array();
  if (user_access('use global twitter account') && ($name = variable_get('twitter_global_name', NULL)) && ($pass = variable_get('twitter_global_password', NULL))) {
    $accounts[$name] = array(
      'screen_name' => $name,
      'password' => $pass,
    );
  }
  $sql = "SELECT ta.*, tu.uid, tu.password, tu.import FROM {twitter_user} tu LEFT JOIN {twitter_account} ta ON (tu.screen_name = ta.screen_name) WHERE tu.uid = %d";
  if ($full_access) {
    $sql .= " AND tu.password IS NOT NULL";
  }
  $args = array(
    $drupal_user->uid,
  );
  $results = db_query($sql, $args);
  while ($account = db_fetch_array($results)) {
    $accounts[$account['screen_name']] = $account;
  }
  return $accounts;
}