? drupalvb.patch
Index: drupalvb.admin-pages.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drupalvb/drupalvb.admin-pages.inc,v
retrieving revision 1.6
diff -u -p -r1.6 drupalvb.admin-pages.inc
--- drupalvb.admin-pages.inc	1 May 2008 20:47:26 -0000	1.6
+++ drupalvb.admin-pages.inc	13 Jun 2008 20:40:01 -0000
@@ -125,11 +125,11 @@ function drupalvb_settings_database() {
   return $form;
 }
 
-function drupalvb_settings_database_submit($form_id, $form_values) {
-  $url = $form_values['scheme'] .'://'. $form_values['user'] .':'. $form_values['pass'] .'@'. $form_values['host'] .'/'. $form_values['path'];
+function drupalvb_settings_database_submit($form, &$form_state) {
+  $url = $form_state['values']['scheme'] .'://'. $form_state['values']['user'] .':'. $form_state['values']['pass'] .'@'. $form_state['values']['host'] .'/'. $form_state['values']['path'];
   variable_set('drupalvb_db', $url);
   variable_set('drupalvb_db_is_default', (is_array($GLOBALS['db_url']) ? $GLOBALS['db_url']['default'] == $url : $GLOBALS['db_url'] == $url));
-  variable_set('drupalvb_db_prefix', $form_values['db_prefix']);
+  variable_set('drupalvb_db_prefix', $form_state['values']['db_prefix']);
 }
 
 /**
@@ -166,8 +166,8 @@ function drupalvb_settings_actions() {
 /**
  * Form submit callback for action form.
  */
-function drupalvb_settings_actions_submit($form_id, $form_values) {
-  switch ($form_values['action']) {
+function drupalvb_settings_actions_submit($form, &$form_state) {
+  switch ($form_state['values']['action']) {
     case 'export':
       drupalvb_export_drupal_users();
       drupal_set_message(t('Drupal users have been exported to vBulletin.'));
Index: drupalvb.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drupalvb/drupalvb.inc,v
retrieving revision 1.11
diff -u -p -r1.11 drupalvb.inc
--- drupalvb.inc	1 May 2008 19:55:08 -0000	1.11
+++ drupalvb.inc	13 Jun 2008 20:40:02 -0000
@@ -157,15 +157,6 @@ function drupalvb_db_query($query) {
 }
 
 /**
- * Returns the last insert id.
- *
- * Borrowed from Drupal 6.
- */
-function db_last_insert_id($table, $field) {
-  return db_result(drupalvb_db_query('SELECT LAST_INSERT_ID()'));
-}
-
-/**
  * Initialize DrupalvB's user mapping table upon installation.
  *
  * Note: We can't do this in a single query, because Drupal's and vB's tables
Index: drupalvb.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drupalvb/drupalvb.info,v
retrieving revision 1.3
diff -u -p -r1.3 drupalvb.info
--- drupalvb.info	30 Apr 2008 01:19:57 -0000	1.3
+++ drupalvb.info	13 Jun 2008 20:40:02 -0000
@@ -1,3 +1,4 @@
 ; $Id: drupalvb.info,v 1.3 2008/04/30 01:19:57 sun Exp $
 name = Drupal vB
 description = Integrate your Drupal site with vBulletin forums.
+core=6.x
Index: drupalvb.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drupalvb/drupalvb.install,v
retrieving revision 1.5
diff -u -p -r1.5 drupalvb.install
--- drupalvb.install	1 May 2008 22:52:15 -0000	1.5
+++ drupalvb.install	13 Jun 2008 20:40:02 -0000
@@ -5,100 +5,34 @@
  * Implementation of hook_install().
  */
 function drupalvb_install() {
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      db_query("CREATE TABLE {drupalvb_users} (
-          uid int(10) unsigned NOT NULL default '0',
-          userid int(10) unsigned NOT NULL default '0',
-          PRIMARY KEY (uid),
-          KEY userid (userid)
-        ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
-
-      require_once drupal_get_path('module', 'drupalvb') .'/drupalvb.inc';
-      _drupalvb_init_user_map();
-      break;
-  }
-}
-
-/**
- * Implementation of hook_uninstall().
- *
- * @todo Variable clean-up.
- */
-function drupalvb_uninstall() {
-  db_query("DROP TABLE {drupalvb_users}");
+  drupal_install_schema('drupalvb');
+  require_once drupal_get_path('module', 'drupalvb') .'/drupalvb.inc';
+  _drupalvb_init_user_map();
 }
 
 /**
- * Move vB database url from settings.php into a variable.
+ * Implementation of hook_schema().
  */
-function drupalvb_update_5100() {
-  global $db_url;
-  
-  $ret = array();
-  if (is_array($db_url) && !empty($db_url['vbulletin'])) {
-    variable_set('drupalvb_db', $db_url['vbulletin']);
-  }
-  else {
-    variable_set('drupalvb_db', $db_url);
-  }
-  require_once drupal_get_path('module', 'drupalvb') .'/drupalvb.inc.php';
-  $config = drupalvb_get_config();
-  variable_set('drupalvb_db_prefix', $config['Database']['tableprefix']);
-  return $ret;
-}
+function drupalvb_schema() {
+  $schema['drupalvb_users'] = array(
+    'fields' => array(
+      'uid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'userid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+    ),
+    'primary key' => array('uid'),
+    'indexes' => array(
+      'userid' => array('userid')
+    ),
+  );
 
-/**
- * Install user id mapping table.
- */
-function drupalvb_update_5200() {
-  $ret = array();
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      $ret[] = update_sql("CREATE TABLE {drupalvb_users} (
-          uid int(10) unsigned NOT NULL default '0',
-          userid int(10) unsigned NOT NULL default '0',
-          PRIMARY KEY (uid),
-          KEY userid (userid)
-        ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
-
-      require_once drupal_get_path('module', 'drupalvb') .'/drupalvb.inc';
-      _drupalvb_init_user_map();
-      break;
-  }
-  return $ret;
+  return $schema;
 }
 
 /**
- * Update block configuration variables.
+ * Implementation of hook_uninstall().
+ *
+ * @todo Variable clean-up.
  */
-function drupalvb_update_5201() {
-  $ret = array();
-  // Recent threads/posts.
-  variable_set('drupalvb_block_recent_type', variable_get('drupalvb_block_0_type', 'threads'));
-  variable_del('drupalvb_block_0_type');
-  variable_set('drupalvb_block_recent_count', variable_get('drupalvb_block_0', 5));
-  variable_del('drupalvb_block_0');
-  variable_set('drupalvb_block_recent_limit', variable_get('drupalvb_block_0_limit', 7));
-  variable_del('drupalvb_block_0_limit');
-  $authors = (variable_get('drupalvb_block_0_name', 'no') == 'no' ? 0 : 1);
-  variable_set('drupalvb_block_recent_authors', $authors);
-  variable_del('drupalvb_block_0_name');
-  $ret[] = update_sql("UPDATE {blocks} SET delta = 'recent' WHERE module = 'drupalvb' AND delta = 0");
-  $ret[] = update_sql("UPDATE {blocks_roles} SET delta = 'recent' WHERE module = 'drupalvb' AND delta = 0");
-  // User info.
-  variable_set('drupalvb_block_user', variable_get('drupalvb_block_1', array('newposts' => 'newposts', 'recent' => 'recent', 'online' => 'online', 'pms' => 'pms')));
-  variable_del('drupalvb_block_1');
-  $ret[] = update_sql("UPDATE {blocks} SET delta = 'user' WHERE module = 'drupalvb' AND delta = 1");
-  $ret[] = update_sql("UPDATE {blocks_roles} SET delta = 'user' WHERE module = 'drupalvb' AND delta = 1");
-  // Overall statistics.
-  variable_set('drupalvb_block_stats', variable_get('drupalvb_block_2', array('threads' => 'threads', 'posts' => 'posts', 'tmembers' => 'tmembers', 'amembers' => 'amembers')));
-  variable_del('drupalvb_block_2');
-  $ret[] = update_sql("UPDATE {blocks} SET delta = 'stats' WHERE module = 'drupalvb' AND delta = 2");
-  $ret[] = update_sql("UPDATE {blocks_roles} SET delta = 'stats' WHERE module = 'drupalvb' AND delta = 2");
-  
-  return $ret;
+function drupalvb_uninstall() {
+  drupal_uninstall_schema('drupalvb');
 }
-
Index: drupalvb.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drupalvb/drupalvb.module,v
retrieving revision 1.24
diff -u -p -r1.24 drupalvb.module
--- drupalvb.module	8 May 2008 10:03:30 -0000	1.24
+++ drupalvb.module	13 Jun 2008 20:40:02 -0000
@@ -13,8 +13,8 @@ require_once drupal_get_path('module', '
 /**
  * Implementation of hook_help().
  */
-function drupalvb_help($section) {
-  switch ($section) {
+function drupalvb_help($path, $arg) {
+  switch ($path) {
     case 'admin/settings#description':
       return t('Allows basic integration of Drupal with a vBulletin forum.');
 
@@ -40,56 +40,48 @@ function drupalvb_help($section) {
 /**
  * Implementation of menu_hook().
  */
-function drupalvb_menu($may_cache) {
+function drupalvb_menu() {
   $items = array();
-  if ($may_cache) {
-    $items[] = array(
-      'path' => 'admin/settings/drupalvb',
-      'title' => t('Drupal vB integration'),
-      'callback' => 'drupalvb_settings',
-      'callback arguments' => array('integration'),
-      'description' => t('Configure integration of Drupal with vBulletin forum.'),
-      'access' => user_access('administer drupalvb'),
-    );
-    $items[] = array(
-      'path' => 'admin/settings/drupalvb/integration',
-      'title' => t('Integration'),
-      'type' => MENU_DEFAULT_LOCAL_TASK,
-      'weight' => -10,
-    );
-    $items[] = array(
-      'path' => 'admin/settings/drupalvb/database',
-      'title' => t('Database'),
-      'callback' => 'drupalvb_settings',
-      'callback arguments' => array('database'),
-      'access' => user_access('administer drupalvb'),
-      'type' => MENU_LOCAL_TASK,
-    );
-    $items[] = array(
-      'path' => 'admin/settings/drupalvb/actions',
-      'title' => t('Actions'),
-      'callback' => 'drupalvb_settings',
-      'callback arguments' => array('actions'),
-      'access' => user_access('administer drupalvb'),
-      'type' => MENU_LOCAL_TASK,
-      'weight' => 10,
-    );
-    $items[] = array(
-      'path' => 'admin/settings/drupalvb/variables',
-      'title' => t('Variables'),
-      'callback' => 'drupalvb_settings',
-      'callback arguments' => array('variables'),
-      'access' => user_access('access devel information'),
-      'type' => MENU_LOCAL_TASK,
-      'weight' => 88,
-    );
-    $items[] = array(
-      'path' => 'drupalvb/pms',
-      'callback' => 'drupalvb_private_messages',
-      'access' => user_access('access content'),
-      'type' => MENU_CALLBACK,
-    );
-  }
+  $items['admin/settings/drupalvb'] = array(
+    'title' => 'Drupal vB integration',
+    'page callback' => 'drupalvb_settings',
+    'page arguments' => array('integration'),
+    'description' => 'Configure integration of Drupal with vBulletin forum.',
+    'access arguments' => array('administer drupalvb'),
+  );
+  $items['admin/settings/drupalvb/integration'] = array(
+    'title' => 'Integration',
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+    'weight' => -10,
+  );
+  $items['admin/settings/drupalvb/database'] = array(
+    'title' => 'Database',
+    'page callback' => 'drupalvb_settings',
+    'page arguments' => array('database'),
+    'access arguments' => array('administer drupalvb'),
+    'type' => MENU_LOCAL_TASK,
+  );
+  $items['admin/settings/drupalvb/actions'] = array(
+    'title' => 'Actions',
+    'page callback' => 'drupalvb_settings',
+    'page arguments' => array('actions'),
+    'access arguments' => array('administer drupalvb'),
+    'type' => MENU_LOCAL_TASK,
+    'weight' => 10,
+  );
+  $items['admin/settings/drupalvb/variables'] = array(
+    'title' => 'Variables',
+    'page callback' => 'drupalvb_settings',
+    'page arguments' => array('variables'),
+    'access arguments' => array('access devel information'),
+    'type' => MENU_LOCAL_TASK,
+    'weight' => 88,
+  );
+  $items['drupalvb/pms'] = array(
+    'page callback' => 'drupalvb_private_messages',
+    'access arguments' => array('access content'),
+    'type' => MENU_CALLBACK,
+  );
   return $items;
 }
 
@@ -154,7 +146,7 @@ function drupalvb_auth($username, $passw
         'authname_drupalvb' => $username,
       );
       $user = user_save('', $userinfo);
-      watchdog('user', t('New external user: %user using module %module.', array('%user' => $name, '%module' => $module)), WATCHDOG_NOTICE, l(t('edit'), 'user/'. $user->uid .'/edit'));
+      watchdog('user', 'New external user: %user using module %module.', array('%user' => $name, '%module' => $module), WATCHDOG_NOTICE, l(t('edit'), 'user/'. $user->uid .'/edit'));
       return TRUE;
     }
   }
@@ -207,7 +199,7 @@ function drupalvb_user_login($account) {
   }
   else {
     drupal_set_message(t('Login to forums failed.'), 'error');
-    watchdog('drupalvb', t('Login failed for forum user %user.', array('%user' => $account->name)), WATCHDOG_ERROR);
+    watchdog('drupalvb', 'Login failed for forum user %user.', array('%user' => $account->name), WATCHDOG_ERROR);
     return FALSE;
   }
 }
@@ -228,11 +220,11 @@ function drupalvb_user_logout($account) 
     drupalvb_db_query("UPDATE {user} SET lastvisit = %d WHERE username = '%s'", time(), $userinfo['username']);
     drupalvb_db_query("DELETE FROM {session} WHERE userid = '%s'", $userinfo['userid']);
     $num = TRUE;
-    watchdog('drupalvb', t('Forum session closed for user %username (@uid).', array('%username' => $userinfo['username'], '@uid' => $userinfo['userid'])));
+    watchdog('drupalvb', 'Forum session closed for user %username (@uid).', array('%username' => $userinfo['username'], '@uid' => $userinfo['userid']));
   }
   // If the user doesn't exist... then how the heck did they log in??
   if (!$num) {
-    watchdog('drupalvb', t('Attempt to logout forum user %user who does not exist!', array('%user' => $account->name)), WATCHDOG_ERROR);
+    watchdog('drupalvb', 'Attempt to logout forum user %user who does not exist!', array('%user' => $account->name), WATCHDOG_ERROR);
   }
 
   // Remove all vB cookies for current user.
@@ -301,7 +293,7 @@ function drupalvb_user_update($account, 
     }
     else {
       drupal_set_message(t('Update failed. Notifying system administrator.'), 'error');
-      watchdog('drupalvb', t('Failed to update a forum account for user %user.', array('%user' => $account->name)), WATCHDOG_ERROR);
+      watchdog('drupalvb', 'Failed to update a forum account for user %user.', array('%user' => $account->name), WATCHDOG_ERROR);
     }
   }
 
@@ -326,7 +318,7 @@ function drupalvb_user_delete($account) 
     db_query("DELETE FROM {drupalvb_users} WHERE userid = %d", $userid);
   }
   else {
-    watchdog('drupalvb', t('Attempt to delete user %user who does not exist!', array('%user' => $account->name)), WATCHDOG_ERROR);
+    watchdog('drupalvb', 'Attempt to delete user %user who does not exist!', array('%user' => $account->name), WATCHDOG_ERROR);
   }
 }
 
@@ -535,13 +527,24 @@ function drupalvb_block($op = 'list', $d
 }
 
 /**
+ * Implementation of hook_theme().
+ */
+function drupalvb_theme() {
+  return array(
+    'drupalvb_block_recent' => array(
+      'arguments' => array('recent' => NULL, 'vb_options' => NULL),
+    ),
+  );
+}
+
+/**
  * Generate HTML for Recent threads/posts block.
  */
 function theme_drupalvb_block_recent($recent, $vb_options) {
   $items = array();
   $display_authors = variable_get('drupalvb_block_recent_authors', 0);
   foreach ($recent as $item) {
-    $items[] = l($item['title'], $item['url'], array(), $item['query'], $item['fragment']) . ($display_authors ? ' <em>'. $item['name'] .'</em>' : '');
+    $items[] = l($item['title'], $item['url'], array('query' => $item['query'], 'fragment' => $item['fragment']) . ($display_authors ? ' <em>'. $item['name'] .'</em>' : ''));
   }
   $output = theme('item_list', $items);
   $output .= l(t('View the forum'), $vb_options['bburl']);
