Index: chatroom.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/chatroom/Attic/chatroom.info,v
retrieving revision 1.1.2.4
diff -u -p -r1.1.2.4 chatroom.info
--- chatroom.info	28 Jun 2007 12:09:20 -0000	1.1.2.4
+++ chatroom.info	19 May 2008 09:39:11 -0000
@@ -1,3 +1,4 @@
-; $Id: chatroom.info,v 1.1.2.4 2007/06/28 12:09:20 darrenoh Exp $
+; $Id$
 name = Chat Room
 description = Enables the creation of rooms that provide access to chats and chat archives.
+core = 6.x
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	19 May 2008 09:39:12 -0000
@@ -2,6 +2,11 @@
 // $Id: chatroom.install,v 1.23.2.18 2007/10/12 20:55:44 darrenoh Exp $
 
 /**
+ * @file
+ * Install chatroom module
+ */
+
+/**
  * Implementation of hook_requirements().
  */
 function chatroom_requirements($phase) {
@@ -25,186 +30,23 @@ function chatroom_requirements($phase) {
 }
 
 /**
- * Implementation of hook_install()
+ * Implementation of hook_install().
  */
 function chatroom_install() {
+  // Schema api
+  $errors = drupal_install_schema('chatroom');
+
+  // TODO: Show message error if cannot install schema
+
+  // TODO: If no errors, execute this
   $t = get_t();
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      // check to see if we have mysql 4.1. if we do, then we want to
-      // set the default charset to utf8. snippet taken from db_connect()
-      // in includes/database.mysql.inc and utf8 declaration taken from
-      // database/database.4.1.mysql
-      $utf_declaration = '';
-      if (version_compare(mysql_get_server_info(), '4.1.0', '>=')) {
-        $utf_declaration = 'DEFAULT CHARACTER SET utf8';
-      }
-      global $active_db;
-      $ok = db_query("CREATE TABLE {chatroom} (
-        crid int(11) NOT NULL AUTO_INCREMENT,
-        nid int(11) NOT NULL,
-        poll_freq int(2) NOT NULL default '3000',
-        idle_freq int(3) NOT NULL default '60000',
-        kicked_out_message longtext,
-        banned_message longtext,
-        module varchar(255) default 'chatroom',
-        auto_archive int(1) default '0',
-        old_msg_count int(3) default '20',
-        modified int(11) NOT NULL default '0',
-        PRIMARY KEY (crid),
-        KEY nid (nid)
-      ) $utf_declaration;");
-      $ok = $ok && db_query("CREATE TABLE {chatroom_chat} (
-        ccid int(11) NOT NULL AUTO_INCREMENT,
-        crid int(11) NOT NULL,
-        uid int(11) NOT NULL,
-        chatname varchar(255) NOT NULL,
-        modified int(11) NOT NULL default '0',
-        when_archived int(11) default NULL,
-        PRIMARY KEY  (ccid),
-        KEY crid (crid),
-        KEY modified (modified)
-      ) $utf_declaration;");
-      $ok = $ok && db_query("CREATE TABLE {chatroom_msg} (
-        cmid int(11) NOT NULL AUTO_INCREMENT,
-        ccid int(11) NOT NULL,
-        uid int(11) NOT NULL,
-        msg_type varchar(64) NOT NULL,
-        msg longtext NOT NULL,
-        session_id varchar(255) NOT NULL,
-        recipient varchar(255) NOT NULL,
-        modified int(11) NOT NULL default '0',
-        PRIMARY KEY  (cmid),
-        KEY ccid (ccid),
-        KEY session_id (session_id),
-        KEY recipient (recipient),
-        KEY modified (modified)
-      ) $utf_declaration;");
-      $ok = $ok && db_query("CREATE TABLE {chatroom_msg_archive} (
-        cmid int(11) NOT NULL,
-        ccid int(11) NOT NULL,
-        uid int(11) NOT NULL,
-        msg_type varchar(64) NOT NULL,
-        msg varchar(512) NOT NULL,
-        session_id varchar(255) NOT NULL,
-        recipient varchar(255) NOT NULL,
-        modified int(11) NOT NULL default '0',
-        PRIMARY KEY  (cmid),
-        KEY ccid (ccid),
-        KEY session_id (session_id),
-        KEY recipient (recipient),
-        KEY modified (modified)
-      ) $utf_declaration;");
-      $ok = $ok && db_query("CREATE TABLE {chatroom_ban_list} (
-        crid int(11) NOT NULL AUTO_INCREMENT,
-        uid int(11) NOT NULL,
-        admin_uid int(11) NOT NULL,
-        modified int(11) NOT NULL default '0',
-        KEY crid_uid (crid,uid)
-      ) $utf_declaration;");
-      $ok = $ok && db_query("CREATE TABLE {chatroom_online_list} (
-        coid int(11) NOT NULL AUTO_INCREMENT,
-        ccid int(11) NOT NULL,
-        uid int(11) NOT NULL,
-        session_id varchar(255) NOT NULL,
-        guest_id int(11) NOT NULL default '1',
-        away int(1) default '0',
-        is_admin int(1) default '0',
-        modified int(11) NOT NULL default '0',
-        PRIMARY KEY  (coid),
-        KEY update_time (ccid,uid,session_id)
-      ) $utf_declaration;");
-      break;
-    case 'pgsql':
-      $ok = db_query("CREATE TABLE {chatroom} (
-        crid SERIAL NOT NULL,
-        nid INTEGER NOT NULL,
-        poll_freq INTEGER NOT NULL default 3000,
-        idle_freq INTEGER NOT NULL default 60000,
-        kicked_out_message TEXT,
-        banned_message TEXT,
-        module VARCHAR default 'chatroom',
-        auto_archive INTEGER default 0,
-        old_msg_count INTEGER default 20,
-        modified INTEGER NOT NULL default '0',
-        PRIMARY KEY (crid)
-      );");
-      $ok = $ok && db_query("CREATE TABLE {chatroom_chat} (
-        ccid SERIAL NOT NULL,
-        crid INTEGER NOT NULL,
-        uid INTEGER NOT NULL,
-        chatname VARCHAR NOT NULL,
-        modified INTEGER NOT NULL default 0,
-        when_archived INTEGER default NULL,
-        PRIMARY KEY  (ccid)
-      );");
-      $ok = $ok && db_query("CREATE TABLE {chatroom_msg} (
-        cmid SERIAL NOT NULL,
-        ccid INTEGER NOT NULL,
-        uid INTEGER NOT NULL,
-        msg_type VARCHAR NOT NULL,
-        msg TEXT NOT NULL,
-        session_id VARCHAR NOT NULL,
-        recipient VARCHAR NOT NULL,
-        modified INTEGER NOT NULL default 0,
-        PRIMARY KEY  (cmid)
-      );");
-      $ok = $ok && db_query("CREATE TABLE {chatroom_msg_archive} (
-        cmid SERIAL NOT NULL,
-        ccid INTEGER NOT NULL,
-        uid INTEGER NOT NULL,
-        msg_type VARCHAR NOT NULL,
-        msg TEXT NOT NULL,
-        session_id VARCHAR NOT NULL,
-        recipient VARCHAR NOT NULL,
-        modified INTEGER NOT NULL default '0',
-        PRIMARY KEY  (cmid)
-      );");
-      $ok = $ok && db_query("CREATE TABLE {chatroom_ban_list} (
-        crid SERIAL NOT NULL,
-        uid INTEGER NOT NULL,
-        admin_uid INTEGER NOT NULL,
-        modified INTEGER NOT NULL default '0',
-        PRIMARY KEY (crid,uid)
-      ) $utf_declaration;");
-      $ok = $ok && db_query("CREATE TABLE {chatroom_online_list} (
-        coid SERIAL NOT NULL,
-        ccid INTEGER NOT NULL,
-        uid INTEGER NOT NULL,
-        session_id VARCHAR NOT NULL,
-        guest_id INTEGER NOT NULL default '1',
-        away INTEGER default '0',
-        is_admin INTEGER default '0',
-        modified INTEGER NOT NULL default '0',
-        PRIMARY KEY  (coid)
-      );");
-      break;
-  }
-  $error = FALSE;
-  if (!$ok) {
-    $error = $t('A database operation failed when setting up Chat Room.');
-    db_query('DROP TABLE {chatroom}');
-    db_query('DROP TABLE {chatroom_chat}');
-    db_query('DROP TABLE {chatroom_msg}');
-    db_query('DROP TABLE {chatroom_msg_archive}');
-    db_query('DROP TABLE {chatroom_ban_list}');
-    db_query('DROP TABLE {chatroom_online_list}');
-  }
-  if ($error) {
-    $error .= $t('Please fix these errors and attempt to enable Chat Room again.');
-    drupal_set_message($error, 'error');
-    db_query("UPDATE {system} SET status = 0 WHERE name = 'chatroom'");
-  }
-  else {
-    global $user;
-    $themes = list_themes();
-    $theme = $user->theme && $themes[$user->theme]->status ? $user->theme : variable_get('theme_default', 'garland');
-    db_query("INSERT INTO {blocks} (status, weight, region, throttle, module, delta, theme) VALUES (1, -10, 'left', 0, 'chatroom', '2', '%s')", $theme);
-    variable_set('comment_chatroom', variable_get('comment_chatroom', COMMENT_NODE_DISABLED));
-    variable_set('chatroom_guest_user_prefix', $t('guest-'));
-    drupal_set_message($t('Chat Room is ready to go.'));
-  }
+  global $user;
+  $themes = list_themes();
+  $theme = $user->theme && $themes[$user->theme]->status ? $user->theme : variable_get('theme_default', 'garland');
+  db_query("INSERT INTO {blocks} (status, weight, region, throttle, module, delta, theme) VALUES (1, -10, 'left', 0, 'chatroom', '2', '%s')", $theme);
+  variable_set('comment_chatroom', variable_get('comment_chatroom', COMMENT_NODE_DISABLED));
+  variable_set('chatroom_guest_user_prefix', $t('guest-'));
+  drupal_set_message($t('Chat Room is ready to go.'));
 }
 
 /**
@@ -241,12 +83,10 @@ function chatroom_uninstall() {
   while ($room = db_fetch_object($rooms)) {
     node_delete($room->nid);
   }
-  db_query('DROP TABLE {chatroom}');
-  db_query('DROP TABLE {chatroom_chat}');
-  db_query('DROP TABLE {chatroom_msg}');
-  db_query('DROP TABLE {chatroom_msg_archive}');
-  db_query('DROP TABLE {chatroom_ban_list}');
-  db_query('DROP TABLE {chatroom_online_list}');
+
+  // Schema api
+  $errors = drupal_uninstall_schema('chatroom');
+
   drupal_set_message($t('Chat room tables have been dropped from the database.'));
   db_query("DELETE FROM {blocks} WHERE module = 'chatroom'");
   $settings = db_query("SELECT name FROM {variable} WHERE name LIKE 'chatroom\_%'");
@@ -310,12 +150,12 @@ function chatroom_update_2() {
   $nids = db_query("SELECT nid FROM {node} WHERE type = '%s'", 'chatroom');
   $row = 0;
   while ($nid = db_result($nids, $row++)) {
-    if (db_num_rows(db_query("SELECT * FROM {chatroom} WHERE nid = %d", $nid)) == 0) {
+    if (db_result(db_query("SELECT COUNT(*) FROM {chatroom} WHERE nid = %d", $nid)) == 0) {
       $ret[] = update_sql("INSERT INTO {chatroom} SET nid = %d", $nid);
     }
   }
   $ret[] = update_sql("DELETE FROM {chatroom_chat} WHERE crid = %d", 0);
-  $ret[] = update_sql('DROP TABLE {chatroom_chat_invites}');
+  db_drop_table($ret, 'chatroom_chat_invites');
   return $ret;
 }
 
@@ -333,12 +173,7 @@ function chatroom_update_3() {
 
 function chatroom_update_4() {
   $ret = array();
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      $ret[] = update_sql('ALTER TABLE {chatroom_msg} CHANGE msg msg varchar(512) NOT NULL');
-      break;
-  }
+  db_change_field($ret, 'chatroom_msg', 'msg', 'msg', array('type' => 'text', 'size' => 'big', 'not null' => TRUE));
   return $ret;
 }
 
@@ -356,3 +191,95 @@ function chatroom_update_5() {
   return array();
 }
 
+/**
+ * Implementation of hook_schema().
+ */
+function chatroom_schema() {
+  $schema['chatroom_online_list'] = array(
+    'fields' => array(
+      'coid' => array('type' => 'serial', 'not null' => TRUE, 'disp-width' => '11'),
+      'ccid' => array('type' => 'int', 'not null' => TRUE, 'disp-width' => '11'),
+      'uid' => array('type' => 'int', 'not null' => TRUE, 'disp-width' => '11'),
+      'session_id' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE),
+      'guest_id' => array('type' => 'int', 'not null' => TRUE, 'default' => 1, 'disp-width' => '11'),
+      'away' => array('type' => 'int', 'not null' => FALSE, 'default' => 0, 'disp-width' => '1'),
+      'is_admin' => array('type' => 'int', 'not null' => FALSE, 'default' => 0, 'disp-width' => '1'),
+      'modified' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11')),
+    'primary key' => array('coid'),
+    'indexes' => array(
+      'update_time' => array('ccid', 'uid', 'session_id')),
+  );
+  $schema['chatroom_msg_archive'] = array(
+    'fields' => array(
+      'cmid' => array('type' => 'int', 'not null' => TRUE, 'disp-width' => '11'),
+      'ccid' => array('type' => 'int', 'not null' => TRUE, 'disp-width' => '11'),
+      'uid' => array('type' => 'int', 'not null' => TRUE, 'disp-width' => '11'),
+      'msg_type' => array('type' => 'varchar', 'length' => '64', 'not null' => TRUE),
+      'msg' => array('type' => 'varchar', 'length' => '512', 'not null' => TRUE),
+      'session_id' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE),
+      'recipient' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE),
+      'modified' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11')),
+    'primary key' => array('cmid'),
+    'indexes' => array(
+      'ccid' => array('ccid'),
+      'modified' => array('modified'),
+      'recipient' => array('recipient'),
+      'session_id' => array('session_id')),
+  );
+  $schema['chatroom_msg'] = array(
+    'fields' => array(
+      'cmid' => array('type' => 'serial', 'not null' => TRUE, 'disp-width' => '11'),
+      'ccid' => array('type' => 'int', 'not null' => TRUE, 'disp-width' => '11'),
+      'uid' => array('type' => 'int', 'not null' => TRUE, 'disp-width' => '11'),
+      'msg_type' => array('type' => 'varchar', 'length' => '64', 'not null' => TRUE),
+      'msg' => array('type' => 'text', 'size' => 'big', 'not null' => TRUE),
+      'session_id' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE),
+      'recipient' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE),
+      'modified' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11')),
+    'primary key' => array('cmid'),
+    'indexes' => array(
+      'ccid' => array('ccid'),
+      'modified' => array('modified'),
+      'recipient' => array('recipient'),
+      'session_id' => array('session_id')),
+  );
+  $schema['chatroom_chat'] = array(
+    'fields' => array(
+      'ccid' => array('type' => 'serial', 'not null' => TRUE, 'disp-width' => '11'),
+      'crid' => array('type' => 'int', 'not null' => TRUE, 'disp-width' => '11'),
+      'uid' => array('type' => 'int', 'not null' => TRUE, 'disp-width' => '11'),
+      'chatname' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE),
+      'modified' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
+      'when_archived' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11')),
+    'primary key' => array('ccid'),
+    'indexes' => array(
+      'crid' => array('crid'),
+      'modified' => array('modified')),
+  );
+  $schema['chatroom_ban_list'] = array(
+    'fields' => array(
+      'crid' => array('type' => 'serial', 'not null' => TRUE, 'disp-width' => '11'),
+      'uid' => array('type' => 'int', 'not null' => TRUE, 'disp-width' => '11'),
+      'admin_uid' => array('type' => 'int', 'not null' => TRUE, 'disp-width' => '11'),
+      'modified' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11')),
+    'indexes' => array(
+      'crid_uid' => array('crid', 'uid')),
+  );
+  $schema['chatroom'] = array(
+    'fields' => array(
+      'crid' => array('type' => 'serial', 'not null' => TRUE, 'disp-width' => '11'),
+      'nid' => array('type' => 'int', 'not null' => TRUE, 'disp-width' => '11'),
+      'poll_freq' => array('type' => 'int', 'not null' => TRUE, 'default' => 3000, 'disp-width' => '2'),
+      'idle_freq' => array('type' => 'int', 'not null' => TRUE, 'default' => 60000, 'disp-width' => '3'),
+      'kicked_out_message' => array('type' => 'text', 'size' => 'big', 'not null' => FALSE),
+      'banned_message' => array('type' => 'text', 'size' => 'big', 'not null' => FALSE),
+      'module' => array('type' => 'varchar', 'length' => '255', 'not null' => FALSE, 'default' => 'chatroom'),
+      'auto_archive' => array('type' => 'int', 'not null' => FALSE, 'default' => 0, 'disp-width' => '1'),
+      'old_msg_count' => array('type' => 'int', 'not null' => FALSE, 'default' => 20, 'disp-width' => '3'),
+      'modified' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11')),
+    'primary key' => array('crid'),
+    'indexes' => array(
+      'nid' => array('nid')),
+  );
+  return $schema;
+}
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	19 May 2008 09:39:14 -0000
@@ -9,8 +9,8 @@
 /**
  * Implementation of hook_help().
  */
-function chatroom_help($section) {
-  switch ($section) {
+function chatroom_help($path, $arg) {
+  switch ($path) {
     case 'admin/help#chatroom':
       return '<p />';
   }
@@ -19,13 +19,12 @@ function chatroom_help($section) {
 /**
  * Implementation of hook_access().
  */
-function chatroom_access($op, $node) {
-  global $user;
+function chatroom_access($op, $node, $account) {
   if ($op == 'create') {
-    return user_access('create chat rooms');
+    return user_access('create chat rooms', $account);
   }
   if ($op == 'update' || $op == 'delete') {
-    if (user_access('edit own chat rooms') && ($user->uid == $node->uid)) {
+    if (user_access('edit own chat rooms', $account) && ($account->uid == $account->uid)) {
       return TRUE;
     }
   }
@@ -41,40 +40,36 @@ function chatroom_perm() {
 /**
  * Implementation of hook_menu().
  */
-function chatroom_menu($may_cache) {
-  $items = array();
-  $items[] = array(
-    'path' => 'admin/settings/chatroom',
-    'callback' => 'drupal_get_form',
-    'callback arguments' => array('chatroom_admin_settings'),
-    'title' => t('Chat room'),
-    'description' => t('Configure chat rooms.'),
-    'access' => user_access('administer chat rooms')
-  );
-  $items[] = array(
-    'path' => 'chatrooms',
-    'callback' => 'chatroom_page',
-    'access' => user_access('access chat rooms'),
-    'title' => t('Chat rooms'),
-    'type' => MENU_SUGGESTED_ITEM
-  );
-  $items[] = array(
-    'path' => 'chatrooms/kicked',
-    'callback' => 'chatroom_chat_kicked_user',
-    'access' => user_access('access chat rooms'),
-    'type' => MENU_CALLBACK
-  );
-  $items[] = array(
-    'path' => 'chatrooms/chat',
-    'callback' => 'chatroom_chat',
-    'access' => user_access('access chat rooms'),
-    'type' => MENU_CALLBACK
-  );
-  $items[] = array(
-    'path' => 'chatrooms/archives',
-    'callback' => 'chatroom_chat_archive',
-    'access' => user_access('access chat rooms'),
-    'type' => MENU_CALLBACK
+function chatroom_menu() {
+  $items['admin/settings/chatroom'] = array(
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('chatroom_admin_settings'),
+    'title' => 'Chat room',
+    'access arguments' => array('administer chat rooms'),
+  );
+  $items['chatrooms'] = array(
+    'title' => 'Chat rooms',
+    'page callback' => 'chatroom_page',
+    'access arguments' => array('access chat rooms'),
+    'type' => MENU_SUGGESTED_ITEM,
+  );
+  $items['chatrooms/kicked'] = array(
+    'page callback' => 'chatroom_chat_kicked_user',
+    'page arguments' => array(2),
+    'access arguments' => array('access chat rooms'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['chatrooms/chat'] = array(
+    'page callback' => 'chatroom_chat',
+    'page arguments' => array(2),
+    'access arguments' => array('access chat rooms'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['chatrooms/archives'] = array(
+    'page callback' => 'chatroom_chat_archive',
+    'page arguments' => array(2),
+    'access arguments' => array('access chat rooms'),
+    'type' => MENU_CALLBACK,
   );
   return $items;
 }
@@ -167,13 +162,13 @@ function chatroom_admin_settings() {
   $form['chatroom_alerts']['chatroom_message_alert_upload'] = array(
     '#type' => 'file',
     '#title' => t('Custom new message sound'),
-    '#description' => isset($js['messageSound']) ? t('Replace the custom new message sound with a new MP3. !Listen to current file.', array('!Listen' => l(t('Listen'), $js['messageSound'], array('id' => 'sound_message')))) : t('Replace the default new message sound with your own MP3.'),
+    '#description' => isset($js['messageSound']) ? t('Replace the custom new message sound with a new MP3. !Listen to current file.', array('!Listen' => l(t('Listen'), $js['messageSound'], array('attributes' => array('id' => 'sound_message'))))) : t('Replace the default new message sound with your own MP3.'),
     '#size' => 30,
   );
   $form['chatroom_alerts']['chatroom_user_alert_upload'] = array(
     '#type' => 'file',
     '#title' => t('Custom new user sound'),
-    '#description' => isset($js['userSound']) ? t('Replace the custom new user sound with a new MP3. !Listen to current file.', array('!Listen' => l(t('Listen'), $js['userSound'], array('id' => 'sound_user')))) : t('Replace the default new user sound with your own MP3.'),
+    '#description' => isset($js['userSound']) ? t('Replace the custom new user sound with a new MP3. !Listen to current file.', array('!Listen' => l(t('Listen'), $js['userSound'], array('attributes' => array('id' => 'sound_user'))))) : t('Replace the default new user sound with your own MP3.'),
     '#size' => 30,
   );
   if (!empty($js)) {
@@ -189,7 +184,8 @@ function chatroom_admin_settings() {
   return system_settings_form($form);
 }
 
-function chatroom_admin_settings_validate($form_id, $form_values) {
+//function chatroom_admin_settings_validate($form_id, $form_values) {
+function chatroom_admin_settings_validate($form, &$form_state) {
   $path = file_directory_path();
   if (file_check_directory($path, FILE_CREATE_DIRECTORY)) {
     $path .= '/chatroom';
@@ -209,7 +205,7 @@ function chatroom_admin_settings_validat
   }
 }
 
-function chatroom_admin_settings_submit($form_id, $form_values) {
+function chatroom_admin_settings_submit($form, &$form_state) {
   $path = file_directory_path() .'/chatroom';
   if (file_check_upload('chatroom_user_alert_upload')) {
     file_save_upload('chatroom_user_alert_upload', "$path/user.mp3", FILE_EXISTS_REPLACE);
@@ -217,7 +213,7 @@ function chatroom_admin_settings_submit(
   if (file_check_upload('chatroom_message_alert_upload')) {
     file_save_upload('chatroom_message_alert_upload', "$path/message.mp3", FILE_EXISTS_REPLACE);
   }
-  system_settings_form_submit($form_id, $form_values);
+  system_settings_form_submit($form, &$form_state);
 }
 
 function _chatroom_element_numeric_unsigned($element) {
@@ -256,7 +252,7 @@ function chatroom_node_info() {
 /**
  * Implementation of hook_form().
  */
-function chatroom_form(&$node) {
+function chatroom_form(&$node, &$params) {
   global $user;
   $form['title'] = array(
     '#type' => 'textfield',
@@ -275,14 +271,14 @@ function chatroom_form(&$node) {
   $form['kicked_out_message'] = array(
     '#type' => 'textarea',
     '#title' => t('Chat room kicked out message'),
-    '#default_value' => $node->chatroom->kicked_out_message,
+    '#default_value' => isset($node->chatroom->kicked_out_message) ? $node->chatroom->kicked_out_message : null,
     '#rows' => 3,
     '#description' => t('This text will appear on the page kicked out users are sent to. Defaults to, "You have been kicked out of %chat for misbehaving."', array('%chat' => t('chat-name'))),
   );
   $form['banned_message'] = array(
     '#type' => 'textarea',
     '#title' => t('Chat room banned message'),
-    '#default_value' => $node->chatroom->banned_message,
+    '#default_value' => isset($node->chatroom->banned_message) ? $node->chatroom->banned_message : null,
     '#rows' => 3,
     '#description' => t('This text will appear on the page banned users are sent to. Defaults to, "You have been banned from %chatroom."', array('%chatroom' => t('chat-room'))),
   );
@@ -310,7 +306,7 @@ function chatroom_form(&$node) {
     '#type' => 'select',
     '#title' => t('Update frequency'),
     '#default_value' => empty($node->chatroom->poll_freq) ? 1 : $node->chatroom->poll_freq / 1000,
-    '#options' => drupal_map_assoc(range(1,10)),
+    '#options' => drupal_map_assoc(range(1, 10)),
     '#description' => t('How many seconds between each request for updates from the server.'),
   );
   $form['chat_settings']['idle_freq'] = array(
@@ -371,7 +367,7 @@ function chatroom_form(&$node) {
 }
 
 /**
- * Implementation of hook_insert()
+ * Implementation of hook_insert().
  */
 function chatroom_insert($node) {
   $result = db_query("
@@ -393,7 +389,7 @@ function chatroom_insert($node) {
 }
 
 /**
- * Implementation of hook_update()
+ * Implementation of hook_update().
  */
 function chatroom_update($node) {
   db_query("
@@ -624,7 +620,7 @@ function chatroom_view($node, $teaser = 
 /**
  * returns a create chat form
  */
-function chatroom_create_chat_form($room_id) {
+function chatroom_create_chat_form(&$form_state, $room_id) {
   $form['chatroom_create_chat'] = array(
     '#type' => 'fieldset',
     '#title' => t('Create a new chat'),
@@ -652,11 +648,11 @@ function chatroom_create_chat_form($room
 /**
  * validates attempt to create chat - checks this name is not already in use
  */
-function chatroom_create_chat_form_validate($f_id, $f_values) {
-  $crid = $f_values['room_id'];
-  $name = $f_values['chat_name'];
-  $sql = "SELECT ccid FROM {chatroom_chat} WHERE crid = %d AND chatname = '%s' AND when_archived IS NULL";
-  if (db_num_rows(db_query_range($sql, $crid, $name, 0, 1))) {
+function chatroom_create_chat_form_validate($form, &$form_state) {
+  $crid = $form_state['values']['room_id'];
+  $name = $form_state['values']['chat_name'];
+  $sql = "SELECT COUNT(ccid) FROM {chatroom_chat} WHERE crid = %d AND chatname = '%s' AND when_archived IS NULL";
+  if (db_result(db_query_range($sql, $crid, $name, 0, 1))) {
     form_set_error('chatroom_chat_name', t('A chat called %name already exists.', array('%name' => $name)));
   }
 }
@@ -664,12 +660,12 @@ function chatroom_create_chat_form_valid
 /**
  * creates a chat
  */
-function chatroom_create_chat_form_submit($f_id, $f_values) {
+function chatroom_create_chat_form_submit($form, &$form_state) {
   global $user;
   $created = db_query("
     INSERT INTO {chatroom_chat} (crid, uid, chatname, modified)
     VALUES (%d, %d, '%s', %d)
-  ", $f_values['room_id'], $user->uid, $f_values['chat_name'], time());
+  ", $form_state['values']['room_id'], $user->uid, $form_state['values']['chat_name'], time());
   if (!$created) {
     drupal_set_message(t("There was an error creating your chat"), 'error');
   }
@@ -846,11 +842,11 @@ function chatroom_get_active_chats($star
   else {
     $result = db_query($sql);
   }
-  if (db_num_rows($result) > 0) {
-    $chats = array();
-    while ($chat = db_fetch_object($result)) {
-      $chats[] = $chat;
-    }
+  $chats = array();
+  while ($chat = db_fetch_object($result)) {
+    $chats[] = $chat;
+  }
+  if (!empty($rows)) {
     return $chats;
   }
   return FALSE;
@@ -947,7 +943,7 @@ function chatroom_block_settings() {
     $state_set = TRUE;
     global $user, $base_url;
     // need some css for the user list display when not in chat room chat page
-    if (substr($_GET['q'], 0, strlen('chatrooms/chat/')) != 'chatrooms/chat/') {
+    if (drupal_substr($_GET['q'], 0, drupal_strlen('chatrooms/chat/')) != 'chatrooms/chat/') {
       drupal_add_css(drupal_get_path('module', 'chatroom') .'/chatroom.css');
     }
     $module_base = drupal_get_path('module', 'chatroom');
@@ -972,11 +968,13 @@ function chatroom_block_settings() {
       'roomsMessage' => t('There are no active chat rooms.'),
     );
     $drupal_js = drupal_add_js();
-    foreach ($drupal_js['setting'] as $setting) {
-      if (is_array($setting['chatroom'])) {
-        foreach ($js as $key => $value) {
-          if (array_key_exists($key, $setting['chatroom'])) {
-            unset($js[$key]);
+    if (isset($drupal_js['setting']) && is_array($drupal_js['setting'])) {
+      foreach ($drupal_js['setting'] as $setting) {
+        if (isset($setting['chatroom']) && is_array($setting['chatroom'])) {
+          foreach ($js as $key => $value) {
+            if (array_key_exists($key, $setting['chatroom'])) {
+              unset($js[$key]);
+            }
           }
         }
       }
@@ -1042,7 +1040,7 @@ function theme_chatroom_list($tree) {
     $header = array(t('Chat room'), t('Chats'), t('Messages'), t('Last message'));
     foreach ($tree as $room) {
       $description  = "<div>\n";
-      $description .= ' <div class="name">'. l($room->title, "node/$room->nid").'</div>';
+      $description .= ' <div class="name">'. l($room->title, "node/$room->nid") .'</div>';
 
       if ($room->body) {
         $description .= ' <div class="description">'. $room->body ."</div>\n";
@@ -1196,20 +1194,20 @@ function chatroom_chat_register_user($ch
   global $user;
   $cache_file = _chatroom_get_cache_file("chat.$chat_id");
   chatroom_chat_update_cache($cache_file);
-  $result = db_query_range("
-    SELECT coid FROM {chatroom_online_list}
+  $count = db_result(db_query_range("
+    SELECT COUNT(coid) FROM {chatroom_online_list}
     WHERE ccid = %d AND uid = %d AND session_id = '%s'
-  ", $chat_id, $user->uid, session_id(), 0, 1);
-  if (db_num_rows($result)) {
+  ", $chat_id, $user->uid, session_id(), 0, 1));
+  if ($count) {
     chatroom_chat_update_online_time($chat_id);
   }
   else {
     $is_admin = user_access('administer chats');
-    $result = db_query_range("
-      SELECT coid FROM {chatroom_online_list}
+    $count = db_result(db_query_range("
+      SELECT COUNT(coid) FROM {chatroom_online_list}
       WHERE ccid = %d AND session_id = '%s'
-    ", $chat_id, session_id(), 0, 1);
-    if (db_num_rows($result)) {
+    ", $chat_id, session_id(), 0, 1));
+    if ($count) {
       db_query("
         UPDATE {chatroom_online_list} SET uid = %d, is_admin = %d
         WHERE ccid = %d AND session_id = '%s'
@@ -1218,7 +1216,7 @@ function chatroom_chat_register_user($ch
     else {
       db_lock_table('chatroom_online_list');
       $result = db_query("SELECT COALESCE(MAX(guest_id) + 1, 1) FROM {chatroom_online_list} WHERE ccid = %d", $chat_id);
-      if ($result && db_num_rows($result)) {
+      if ($result) {
         db_query("
           INSERT INTO {chatroom_online_list}
           (ccid, uid, is_admin, session_id, guest_id, modified)
@@ -1239,7 +1237,7 @@ function chatroom_chat_settings($chat) {
   $cache_file = _chatroom_get_cache_file("chat.{$chat->ccid}");
   $cache_timestamp = @filemtime($cache_file);
   $users = chatroom_chat_get_online_list($chat->ccid, $cache_timestamp, 0);
-  if (variable_get('configurable_timezones', 1) && $user->uid && strlen($user->timezone)) {
+  if (variable_get('configurable_timezones', 1) && $user->uid && drupal_strlen($user->timezone)) {
     $timezone = $user->timezone;
   }
   else {
@@ -1274,11 +1272,13 @@ function chatroom_chat_settings($chat) {
     $js['smileysMarker'] = '------';
   }
   $drupal_js = drupal_add_js();
-  foreach ($drupal_js['setting'] as $setting) {
-    if (is_array($setting['chatroom'])) {
-      foreach ($js as $key => $value) {
-        if (array_key_exists($key, $setting['chatroom'])) {
-          unset($js[$key]);
+  if (isset($drupal_js['setting']) && is_array($drupal_js['setting'])) {
+    foreach ($drupal_js['setting'] as $setting) {
+      if (is_array($setting['chatroom'])) {
+        foreach ($js as $key => $value) {
+          if (array_key_exists($key, $setting['chatroom'])) {
+            unset($js[$key]);
+          }
         }
       }
     }
@@ -1411,7 +1411,7 @@ function chatroom_chat_archive($chat_id 
  */
 function chatroom_form_chat_delete($chat_id = NULL) {
   $form = array();
-  $form['chat_id'] = array (
+  $form['chat_id'] = array(
     '#type' => 'value',
     '#value' => $chat_id,
   );
@@ -1429,10 +1429,10 @@ function chatroom_form_chat_delete($chat
  * @param array $form_values
  * @return string
  */
-function chatroom_form_chat_delete_submit($form_id, $form_values) {
-  $chat = chatroom_chat_get_from_id($form_values['chat_id']);
-  chatroom_chat_delete($form_values['chat_id']);
-  return "node/$chat->nid";
+function chatroom_form_chat_delete_submit($form, &$form_state) {
+  $chat = chatroom_chat_get_from_id($form_state['values']['chat_id']);
+  chatroom_chat_delete($form_state['values']['chat_id']);
+  $form_state['redirect'] = "node/$chat->nid";
 }
 
 /**
@@ -1442,7 +1442,7 @@ function chatroom_form_chat_delete_submi
  * @return array
  */
 function chatroom_form_chat_archive($chat_id) {
-  $form['chat_id'] = array (
+  $form['chat_id'] = array(
     '#type' => 'value',
     '#value' => $chat_id,
   );
@@ -1460,14 +1460,14 @@ function chatroom_form_chat_archive($cha
  * @param array $form_values
  * @return string
  */
-function chatroom_form_chat_archive_submit($form_id, $form_values) {
-  chatroom_archive_chat($form_values['chat_id']);
-  file_delete(_chatroom_get_cache_file('chat.'. $form_values['chat_id']));
+function chatroom_form_chat_archive_submit($form, &$form_state) {
+  chatroom_archive_chat($form_state['values']['chat_id']);
+  file_delete(_chatroom_get_cache_file('chat.'. $form_state['values']['chat_id']));
   db_query("
     INSERT INTO {chatroom_msg_archive} (cmid, ccid, uid, msg_type, msg, session_id, recipient, modified)
     SELECT * FROM {chatroom_msg} WHERE ccid = %d
-  ", $form_values['chat_id']);
-  $chat = chatroom_chat_get_from_id($form_values['chat_id']);
+  ", $form_state['values']['chat_id']);
+  $chat = chatroom_chat_get_from_id($form_state['values']['chat_id']);
   chatroom_block_update_cache('chatrooms');
   chatroom_block_update_cache('chats');
 }
@@ -1497,6 +1497,7 @@ function theme_chatroom_chat_archive($ch
   else {
     $html = '<p>'. l(t('Join !chat', array('!chat' => $chat->chatname)), "chatrooms/chat/$chat->ccid") .'</p>';
   }
+  $previous = '';
   if ($msgs = chatroom_get_all_msgs($chat->ccid)) {
     $html .= '<div id="chatroom-container-archive"><table><tbody valign="top">';
     foreach ($msgs as $msg) {
@@ -1709,8 +1710,9 @@ function chatroom_chat_old_msg_limit($ch
  */
 function _chatroom_variable_get($name, $default) {
   $result = db_query_range("SELECT value FROM {variable} WHERE name = '%s'", $name, 0, 1);
-  if (db_num_rows($result)) {
-    $default = unserialize(db_result($result));
+  $data = db_result($result);
+  if (!empty($data)) {
+    $default = unserialize($data);
   }
   return $default;
 }
@@ -1740,7 +1742,7 @@ function chatroom_smileys_filter_process
         }
       }
     }
-    $text = substr($text, 1, -1);
+    $text = drupal_substr($text, 1, -1);
   }
   return $text;
 }
@@ -1822,7 +1824,7 @@ function _chatroom_get_cache_file($type)
 function chatroom_get_site_online_list($uid) {
   $users = array();
   $time_period = 2 * _chatroom_variable_get('chatroom_block_update_interval', 5);
-  $result = db_query("SELECT uid, name FROM {users} WHERE access >= %d AND uid != 0", time() - $time_period);
+  $result = db_query("SELECT uid, name FROM {users} WHERE access >= %d AND uid <> 0", time() - $time_period);
   while ($user = db_fetch_object($result)) {
     if ($uid != $user->uid) {
       $users[] = $user;
@@ -1844,7 +1846,7 @@ function chatroom_is_banned_user($crid) 
     $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));
+    $result = db_result(db_query_range("SELECT COUNT(crid) FROM {chatroom_ban_list} WHERE crid = %d AND uid = %d", $crid, $user->uid, 0, 1));
   }
   return $result;
 }
@@ -1878,10 +1880,8 @@ function chatroom_get_chatroom_list($arc
     $result = db_query($sql);
   }
   $rooms = array();
-  if (db_num_rows($result) > 0) {
-    while ($room = db_fetch_object($result)) {
-      $rooms[] = $room;
-    }
+  while ($room = db_fetch_object($result)) {
+    $rooms[] = $room;
   }
   return $rooms;
 }
@@ -1937,3 +1937,48 @@ function chatroom_chat_get_online_list($
   return $users;
 }
 
+/**
+ * Implementation of hook_theme().
+ */
+function chatroom_theme() {
+  $theme['chatroom_block_commands'] = array(
+    'arguments' => array(),
+  );
+  $theme['chatroom_block_chats'] = array(
+    'arguments' => array(),
+  );
+  $theme['chatroom_block_rooms'] = array(
+    'arguments' => array(),
+  );
+  $theme['chatroom_block_chat_online_list'] = array(
+    'arguments' => array(),
+  );
+  $theme['chatroom_block_site_online_list'] = array(
+    'arguments' => array('uid'),
+  );
+  $theme['chatroom_display'] = array(
+    'arguments' => array('tree'),
+  );
+  $theme['chatroom_list'] = array(
+    'arguments' => array('tree'),
+  );
+  $theme['chatroom_chat_kicked_user'] = array(
+    'arguments' => array('chat'),
+  );
+  $theme['chatroom_chat_banned_user'] = array(
+    'arguments' => array('chat'),
+  );
+  $theme['chatroom_chat'] = array(
+    'arguments' => array('chat'),
+  );
+  $theme['chatroom_chat_board'] = array(
+    'arguments' => array(),
+  );
+  $theme['chatroom_chat_textentry'] = array(
+    'arguments' => array(),
+  );
+  $theme['chatroom_chat_archive'] = array(
+    'arguments' => array('chat'),
+  );
+  return $theme;
+}
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	19 May 2008 09:39:14 -0000
@@ -188,8 +188,8 @@ function chatroom_smileys($smileys_base)
   if (
     is_dir($smileys_base) && // Is a directory
     (
-      substr($smileys_base, 0, strlen('modules')) == 'modules' || // in the modules directory
-      substr($smileys_base, 0, strlen('sites')) == 'sites' // or in the sites directory.
+      drupal_substr($smileys_base, 0, drupal_strlen('modules')) == 'modules' || // in the modules directory
+      drupal_substr($smileys_base, 0, drupal_strlen('sites')) == 'sites' // or in the sites directory.
     ) &&
     strpos($smileys_base, '..') === FALSE // and path does not contain "..".
   ) {
