You are here

function messaging_twitter_user_destination in Messaging 6.3

Same name and namespace in other branches
  1. 6.4 messaging_twitter/messaging_twitter.module \messaging_twitter_user_destination()
  2. 6 messaging_twitter/messaging_twitter.module \messaging_twitter_user_destination()
  3. 6.2 messaging_twitter/messaging_twitter.module \messaging_twitter_user_destination()

Map user account to twitter screen name

1 string reference to 'messaging_twitter_user_destination'
messaging_twitter_messaging in messaging_twitter/messaging_twitter.module
Implementation of hook_messaging

File

messaging_twitter/messaging_twitter.module, line 48
Messaging Twitter sending method

Code

function messaging_twitter_user_destination($account) {
  static $cache = array();
  if (!array_key_exists($account->uid, $cache)) {
    _messaging_twitter_include();
    $twitter_accounts = twitter_get_user_accounts($account->uid);
    if (is_array($twitter_accounts) && !empty($twitter_accounts)) {
      reset($twitter_accounts);
      $first = current($twitter_accounts);
      $cache[$account->uid] = $first['screen_name'];
    }
    else {
      $cache[$account->uid] = NULL;
    }
  }
  return $cache[$account->uid];
}