You are here

function hook_twitter_accounts in Twitter 6.2

Same name and namespace in other branches
  1. 6.5 twitter.api.php \hook_twitter_accounts()
  2. 6.3 twitter.api.php \hook_twitter_accounts()
  3. 6.4 twitter.api.php \hook_twitter_accounts()
  4. 7.6 twitter.api.php \hook_twitter_accounts()
  5. 7.3 twitter.api.php \hook_twitter_accounts()
  6. 7.4 twitter.api.php \hook_twitter_accounts()
  7. 7.5 twitter.api.php \hook_twitter_accounts()

Retrieves what Twitter accounts the given user can post to.

1 function implements hook_twitter_accounts()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

twitter_twitter_accounts in ./twitter.module
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 invocation of hook_twitter_accounts()
twitter_get_user_accounts in ./twitter.inc
User/account relationship code

File

./twitter.api.php, line 11
Provides API documentation for the Twitter module.

Code

function hook_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 ";
  $sql .= "LEFT JOIN {twitter_account} ta ON (tu.screen_name = ta.screen_name) ";
  $sql .= "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;
}