Index: chatroom.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/chatroom/Attic/chatroom.install,v
retrieving revision 1.23.2.18
diff -u -p -r1.23.2.18 chatroom.install
--- chatroom.install	12 Oct 2007 20:55:44 -0000	1.23.2.18
+++ chatroom.install	8 May 2008 16:43:59 -0000
@@ -99,6 +99,7 @@ function chatroom_install() {
       $ok = $ok && db_query("CREATE TABLE {chatroom_ban_list} (
         crid int(11) NOT NULL AUTO_INCREMENT,
         uid int(11) NOT NULL,
+        hostname varchar(128) NOT NULL,
         admin_uid int(11) NOT NULL,
         modified int(11) NOT NULL default '0',
         KEY crid_uid (crid,uid)
@@ -164,6 +165,7 @@ function chatroom_install() {
       $ok = $ok && db_query("CREATE TABLE {chatroom_ban_list} (
         crid SERIAL NOT NULL,
         uid INTEGER NOT NULL,
+        hostname VARCHAR NOT NULL,
         admin_uid INTEGER NOT NULL,
         modified INTEGER NOT NULL default '0',
         PRIMARY KEY (crid,uid)
@@ -356,3 +358,22 @@ function chatroom_update_5() {
   return array();
 }
 
+/**
+ * Implementation of hook_update_N().
+ *
+ * Add a column for banned hostnames to the chatroom_ban_list table.
+ */
+function chatroom_update_6() {
+  $ret = array();
+  switch ($GLOBALS['db_type']) {
+    case 'mysql':
+    case 'mysqli':
+      $ret[] = update_sql("ALTER TABLE {chatroom_ban_list} ADD hostname varchar(128) NOT NULL");
+      break;
+    case 'pgsql':
+      db_add_column($ret, 'chatroom_ban_list', 'hostname', 'varchar', array('not null' => TRUE));
+      break;
+  }
+  return $ret;
+}
+
Index: chatroom.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/chatroom/Attic/chatroom.js,v
retrieving revision 1.48.2.33
diff -u -p -r1.48.2.33 chatroom.js
--- chatroom.js	10 Oct 2007 15:07:05 -0000	1.48.2.33
+++ chatroom.js	8 May 2008 16:44:00 -0000
@@ -167,10 +167,6 @@ Drupal.chatroom.chat.getCommandMsg = fun
 
       if (msg.type == 'ban') {
         msg.uid = Drupal.chatroom.chat.findGuestId(msg.recipient).uid;
-        // can only ban Drupal users, not guests
-        if (!msg.uid) {
-          return false;
-        }
         msg.admin_uid = Drupal.settings.chatroom.chatUsers[0].uid;
       }
 
Index: chatroom.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/chatroom/Attic/chatroom.module,v
retrieving revision 1.59.2.71
diff -u -p -r1.59.2.71 chatroom.module
--- chatroom.module	8 May 2008 14:27:44 -0000	1.59.2.71
+++ chatroom.module	8 May 2008 16:44:00 -0000
@@ -293,13 +293,29 @@ function chatroom_form(&$node) {
       '#collapsible' => TRUE,
     );
     foreach ($node->chatroom->banned_users as $banned_user) {
-      $banned_users[$banned_user->uid] = check_plain($banned_user->name);
+      if (!empty($banned_user->uid)) {
+        $banned_users[$banned_user->uid] = $banned_user->name;
+      }
+      elseif (!empty($banned_user->hostname)) {
+        $banned_hosts[$banned_user->hostname] = $banned_user->hostname;
+      }
+    }
+    if (isset($banned_users)) {
+      $form['chatroom_banned_users']['unban_list'] = array(
+        '#type' => 'checkboxes',
+        '#title' => t('Banned users'),
+        '#options' => $banned_users,
+        '#description' => t('Check the users you would like to unban.')
+      );
+    }
+    if (isset($banned_hosts)) {
+      $form['chatroom_banned_users']['unban_hosts'] = array(
+        '#type' => 'checkboxes',
+        '#title' => t('Banned hosts'),
+        '#options' => $banned_hosts,
+        '#description' => t('Check the hosts you would like to unban.')
+      );
     }
-    $form['chatroom_banned_users']['unban_list'] = array(
-      '#type' => 'checkboxes',
-      '#options' => $banned_users,
-      '#description' => t('Check the users you would like to unban')
-    );
   }
   $form['chat_settings'] = array(
     '#type' => 'fieldset',
@@ -437,7 +453,10 @@ function chatroom_update($node) {
     }
   }
   if (isset($node->unban_list)) {
-    db_query('DELETE FROM {chatroom_ban_list} WHERE crid = %d AND uid IN (%s)', $node->chatroom->crid, implode(',', $node->unban_list));
+    db_query("DELETE FROM {chatroom_ban_list} WHERE crid = %d AND uid IN (%s)", $node->chatroom->crid, implode(',', $node->unban_list));
+  }
+  if (isset($node->unban_hosts)) {
+    db_query("DELETE FROM {chatroom_ban_list} WHERE crid = %d AND hostname IN ('%s')", $node->chatroom->crid, implode("','", $node->unban_hosts));
   }
 }
 
@@ -549,7 +568,7 @@ function chatroom_get_msg_info($msg) {
  * Gets a list of banned users for a given chat room.
  */
 function chatroom_get_banned_users($crid) {
-  $result = db_query("SELECT cbl.uid, u.name FROM {chatroom_ban_list} cbl INNER JOIN {users} u ON u.uid = cbl.uid WHERE cbl.crid = %d", $crid);
+  $result = db_query("SELECT cbl.uid, cbl.hostname, u.name FROM {chatroom_ban_list} cbl INNER JOIN {users} u ON u.uid = cbl.uid WHERE cbl.crid = %d", $crid);
   $banned_users = array();
   while ($banned_user = db_fetch_object($result)) {
     $banned_users[] = $banned_user;
@@ -1837,14 +1856,13 @@ function chatroom_get_site_online_list($
 function chatroom_is_banned_user($crid) {
   global $user;
   static $result = NULL;
-  if (!is_null($result)) {
-    return $result;
-  }
-  if ($user->uid == 0) {
-    $result = FALSE;
-  }
-  else {
-    $result = db_num_rows(db_query_range("SELECT crid FROM {chatroom_ban_list} WHERE crid = %d AND uid = %d", $crid, $user->uid, 0, 1));
+  if (is_null($result)) {
+    if (empty($user->uid)) {
+      $result = db_result(db_query_range("SELECT crid FROM {chatroom_ban_list} cbl INNER JOIN {sessions} s ON cbl.hostname = s.hostname WHERE cbl.crid = %d AND s.sid = %d", $crid, $user->sid, 0, 1)) !== FALSE;
+    }
+    else {
+      $result = db_result(db_query_range("SELECT crid FROM {chatroom_ban_list} WHERE crid = %d AND uid = %d", $crid, $user->uid, 0, 1)) !== FALSE;
+    }
   }
   return $result;
 }
Index: updates.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/chatroom/Attic/updates.inc,v
retrieving revision 1.1.2.7
diff -u -p -r1.1.2.7 updates.inc
--- updates.inc	3 Oct 2007 07:32:08 -0000	1.1.2.7
+++ updates.inc	8 May 2008 16:44:00 -0000
@@ -64,9 +64,14 @@ function chatroom_chat_kick_user($chat_i
  */
 function chatroom_ban_user($chat_id, $guest_id, $uid, $admin_uid, $cache_file) {
   if (user_access('administer chats')) {
-    db_query("DELETE FROM {chatroom_online_list} WHERE ccid = %d AND guest_id = '%s'", $chat_id, $guest_id);
     $chat = chatroom_chat_get_from_id($chat_id, FALSE);
-    db_query("INSERT INTO {chatroom_ban_list} (crid, uid, admin_uid) VALUES (%d, %d, %d)", $chat->crid, $uid, $admin_id);
+    if (empty($uid)) {
+      db_query("INSERT INTO {chatroom_ban_list} (crid, hostname, admin_uid) SELECT %d AS crid, s.hostname, %d AS admin_uid FROM {sessions} s INNER JOIN {chatroom_online_list} col on s.sid = col.session_id WHERE col.guest_id = %d", $chat->crid, $admin_uid, $guest_id);
+    }
+    else {
+      db_query("INSERT INTO {chatroom_ban_list} (crid, uid, admin_uid) VALUES (%d, %d, %d)", $chat->crid, $uid, $admin_uid);
+    }
+    db_query("DELETE FROM {chatroom_online_list} WHERE ccid = %d AND guest_id = '%s'", $chat_id, $guest_id);
   }
   $cache_timestamp = @filemtime($cache_file);
   $js->chatUsers = chatroom_chat_get_online_list($chat_id, $cache_timestamp);
