You are here

function _drupalchat_chat in DrupalChat 6.2

Same name and namespace in other branches
  1. 6 drupalchat.module \_drupalchat_chat()
  2. 7.2 drupalchat.module \_drupalchat_chat()
  3. 7 drupalchat.module \_drupalchat_chat()
1 call to _drupalchat_chat()
drupalchat_preprocess_drupalchat in ./drupalchat.module

File

./drupalchat.module, line 156
Module code for DrupalChat.

Code

function _drupalchat_chat() {
  global $user;
  $chat = array();
  $chat['name'] = 'chat';
  $chat['header'] = t('Chat');
  $buddylist = _drupalchat_buddylist($user->uid);
  $buddylist_online = _drupalchat_buddylist_online($buddylist);
  $chat['contents'] = '<div class="chat_options">';

  //$chat['contents'] .= '<a class="options" href="#">' . t('Options') . '</a>';
  $chat['contents'] .= '<a class="chat_loading" href="#"></a>';
  $chat['contents'] .= '</div>';
  $items = array();
  foreach ($buddylist_online as $key => $value) {
    if ($key != 'total') {
      $items[] = array(
        'data' => '<a class="' . $key . '" href="#">' . $value['name'] . '</a>',
        'class' => 'status-' . $value['status'],
      );
    }
  }
  if ($items) {
    $chat['contents'] .= theme('item_list', $items);
  }
  else {
    $chat['contents'] .= theme('item_list', array(
      array(
        'data' => l(t('No users online'), 'user'),
        'class' => 'link',
      ),
    ));
  }
  $chat['text'] = t('Chat') . ' (<span class="online-count">' . count($items) . '</span>)';
  $theme = variable_get('drupalchat_theme', 'light');
  $chat['icon'] = theme('image', drupal_get_path('module', 'drupalchat') . '/themes/' . $theme . '/images/loading.gif', NULL, NULL, array(
    'class' => 'icon',
  ));
  return theme('drupalchat_subpanel', $chat);
}