You are here

function nodejs_buddylist_block_content in Node.js integration 7

Get the content for the buddy list block.

2 calls to nodejs_buddylist_block_content()
nodejs_buddylist_block_view in nodejs_buddylist/nodejs_buddylist.module
Implementation of hook_block_view().
nodejs_buddylist_page_alter in nodejs_buddylist/nodejs_buddylist.module
Implements hook_page_alter().

File

nodejs_buddylist/nodejs_buddylist.module, line 90

Code

function nodejs_buddylist_block_content($account, $id_prefix = 'nodejs-buddylist-uid-') {
  $buddies = nodejs_buddylist_user_list($account);
  if ($buddies) {
    $online_uids = nodejs_buddylist_get_online_uids(array_keys($buddies));
    $html = '<ul>';
    $chat_enabled = module_exists('chatroom_nodejs');
    foreach ($buddies as $buddy) {
      $buddy = user_load($buddy['uid']);
      $id = $id_prefix . $buddy->uid;
      $class = 'nodejs-buddylist-' . (in_array($buddy->uid, $online_uids) ? 'online' : 'offline');
      $chat_button = '';
      if ($chat_enabled && $class == 'nodejs-buddylist-online') {
        $chat_button = theme('nodejs_buddylist_chat_button', array(
          'buddy' => $buddy,
          'online' => TRUE,
        ));
      }
      else {
        $chat_button = theme('nodejs_buddylist_chat_button', array(
          'buddy' => $buddy,
          'online' => FALSE,
        ));
      }
      $html .= '<li id="' . $id . '" class="' . $class . '">';
      $html .= theme('username', array(
        'account' => $buddy,
      )) . $chat_button;
      $html .= '</li>';
    }
    $html .= '</ul>';
    return $html;
  }
  else {
    return t("You have no buddies.");
  }
}