+ function subscribed_twitter_users() {
+
+ $current_user = common_current_user();
+
+ $qry = 'SELECT user.* ' .
+ 'FROM subscription ' .
+ 'JOIN user ON subscription.subscribed = user.id ' .
+ 'JOIN foreign_link ON foreign_link.user_id = user.id ' .
+ 'WHERE subscriber = %d ' .
+ 'ORDER BY user.nickname';
+
+ $user = new User();
+
+ $user->query(sprintf($qry, $current_user->id));
+
+ $users = array();
+
+ while ($user->fetch()) {
+
+ // Don't include the user's own self-subscription
+ if ($user->id != $current_user->id) {
+ $users[] = clone($user);
+ }
+ }
+
+ return $users;
+ }
+
+ function show_twitter_subscriptions() {
+
+ $friends = $this->subscribed_twitter_users();
+ $friends_count = count($friends);
+
+ if ($friends_count > 0) {
+
+ common_element('h3', NULL, _('Twitter Friends'));
+ common_element_start('div', array('id' => 'subscriptions'));
+ common_element_start('ul', array('id' => 'subscriptions_avatars'));
+
+ for ($i = 0; $i < min($friends_count, SUBSCRIPTIONS); $i++) {
+
+ $other = Profile::staticGet($friends[$i]->id);
+
+ if (!$other) {
+ common_log_db_error($subs, 'SELECT', __FILE__);
+ continue;
+ }
+
+ common_element_start('li');
+ common_element_start('a', array('title' => ($other->fullname) ?
+ $other->fullname :
+ $other->nickname,
+ 'href' => $other->profileurl,
+ 'rel' => 'contact',
+ 'class' => 'subscription'));
+ $avatar = $other->getAvatar(AVATAR_MINI_SIZE);
+ common_element('img', array('src' => (($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_MINI_SIZE)),
+ 'width' => AVATAR_MINI_SIZE,
+ 'height' => AVATAR_MINI_SIZE,
+ 'class' => 'avatar mini',
+ 'alt' => ($other->fullname) ?
+ $other->fullname :
+ $other->nickname));
+ common_element_end('a');
+ common_element_end('li');
+
+ }
+
+ common_element_end('ul');
+ common_element_end('div');
+
+ }
+
+ // XXX Figure out a way to show all Twitter friends... ?
+
+ /*
+ if ($subs_count > SUBSCRIPTIONS) {
+ common_element_start('p', array('id' => 'subscriptions_viewall'));
+
+ common_element('a', array('href' => common_local_url('subscriptions',
+ array('nickname' => $profile->nickname)),
+ 'class' => 'moresubscriptions'),
+ _('All subscriptions'));
+ common_element_end('p');
+ }
+ */
+
+ }
+