Index: chatroom.css =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/chatroom/chatroom.css,v retrieving revision 1.16 diff -u -F^f -r1.16 chatroom.css --- chatroom.css 2 Oct 2006 23:02:47 -0000 1.16 +++ chatroom.css 7 Oct 2006 00:53:00 -0000 @@ -7,12 +7,11 @@ font-size: 80%; color: #666666; } -#chatroom-list-description { - padding: 5px 5px 5px 5px; - background-color: #f5f5f5; - border: solid 1px #e0e0e0; - margin-bottom: 20px; + +#chatroom table { + width: 100%; } + .chatroom-textentry-smileys { padding-top: 10px; } Index: chatroom.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/chatroom/chatroom.module,v retrieving revision 1.51 diff -u -F^f -r1.51 chatroom.module --- chatroom.module 2 Oct 2006 23:02:47 -0000 1.51 +++ chatroom.module 7 Oct 2006 00:53:01 -0000 @@ -41,7 +41,7 @@ function chatroom_menu($may_cache) { 'title' => t('chatroom'), 'access' => user_access('create chatrooms')); $items[] = array('path' => 'chatrooms', - 'callback' => 'chatroom_home', + 'callback' => 'chatroom_page', 'access' => user_access('access chatrooms'), 'title' => t('chatrooms'), 'type' => MENU_SUGGESTED_ITEM); @@ -1409,37 +1409,13 @@ function chatroom_chat($chat_id = false) } /** - * chatroom module home + * Menu callback; prints a chatroom listing. */ -function chatroom_home() { - global $user; - if ($node->type == 'chatroom') { - $bc = drupal_get_breadcrumb(); - $bc[] = l('Chatrooms', 'chatrooms/'); - drupal_set_breadcrumb($bc); +function chatroom_page() { + foreach (chatroom_get_chatroom_list() as $room) { + $tree[$room->nid] = node_load($room->nid); } - $out = ''; - if (user_access('create chatrooms')) { - $out .= ''; - } - if ($chatrooms = chatroom_get_chatroom_list()) { - if ($list_description = variable_get('chatroom_list_description', '')) { - $out .= theme('chatroom_list_description', $list_description); - } - $header = array(t('Name'), t('Description'), t('Active chats')); - foreach ($chatrooms as $room) { - $rows[] = array( - array('data' => l(check_plain($room->title), "node/$room->nid")), - array('data' => filter_xss($room->body)), - array('data' => $room->chat_count) - ); - } - $out .= theme('table', $header, $rows); - } - else { - $out .= '

' . t('There are no chatrooms'). '

'; - } - return $out; + return theme('chatroom_display', $tree); } /** @@ -1676,3 +1652,74 @@ function theme_chatroom_chat_textentry() return $output; } +/** + * Format the chatroom listing. + * + * @ingroup themeable + */ +function theme_chatroom_display($tree) { + global $user; + // chatroom list, chats list, and 'add new chat' link + + if (count($tree)) { + $output = '
'; + $output .= ''; + $output .= theme('chatroom_list', $tree); + $output .= '
'; + } + else { + drupal_set_title(t('No chatrooms defined')); + $output = ''; + } + + return $output; +} + +/** + * Format the chatroom table. + * + * @ingroup themeable + */ +function theme_chatroom_list($tree) { + global $user; + + if ($tree) { + $header = array(t('Chatroom'), t('Chats'), t('Messages'), t('Last message')); + foreach ($tree as $room) { + $description = "
\n"; + $description .= '
'. l($room->title, "node/$room->nid"). '
'; + + if ($room->body) { + $description .= '
'. filter_xss_admin($room->body) ."
\n"; + } + $description .= "
\n"; + + $rows[] = array(array('data' => $description, 'class' => 'container', 'colspan' => '4')); + + foreach ($room->chatroom->chats as $id => $chat) { + $description = "
\n"; + $description .= '
'. l($chat->chatname, "chatrooms/chat/$chat->ccid") ."
\n"; + $description .= "
\n"; + + $row[] = array('data' => ' '); + $row[] = array('data' => $description, 'class' => 'chatroom-chat'); + $row[] = array('data' => $chat->msg_count, 'class' => 'chatroom-msg-count'); + $row[] = array('data' => $chat->msg_info, 'class' => 'chatrom-msg-info'); + $rows[] = $row; + unset($row); + } + } + return theme('table', $header, $rows); + } +} \ No newline at end of file