Index: invite.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/invite/invite.info,v
retrieving revision 1.1.2.5.2.1
diff -u -p -r1.1.2.5.2.1 invite.info
--- invite.info	10 Jul 2008 10:18:06 -0000	1.1.2.5.2.1
+++ invite.info	18 Aug 2008 14:49:30 -0000
@@ -1,5 +1,6 @@
 ; $Id: invite.info,v 1.1.2.5.2.1 2008/07/10 10:18:06 smk Exp $
 name = Invite
 description = "Allow your users to send and track invitations to join your site."
-dependencies = token
+dependencies[] = token
 package = Invite
+core = 6.x
Index: invite.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/invite/invite.install,v
retrieving revision 1.3.2.26.2.7
diff -u -p -r1.3.2.26.2.7 invite.install
--- invite.install	10 Jul 2008 10:18:06 -0000	1.3.2.26.2.7
+++ invite.install	19 Aug 2008 12:40:59 -0000
@@ -5,70 +5,116 @@
  * Install the initial schema.
  */
 function invite_install() {
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      db_query("
-        CREATE TABLE {invite} (
-          reg_code varchar(8) NOT NULL default '',
-          email varchar(100) NOT NULL default '',
-          uid int(10) NOT NULL default '0',
-          invitee int(10) NOT NULL default '0',
-          created int(10) NOT NULL default '0',
-          expiry int(10) NOT NULL default '0',
-          joined int(10) NOT NULL default '0',
-          canceled tinyint(1) NOT NULL default '0',
-          resent tinyint(3) NOT NULL default '0',
-          data text NOT NULL,
-          UNIQUE (reg_code),
-          KEY (email),
-          KEY (uid)
-        ) /*!40100 DEFAULT CHARACTER SET utf8 */;"
-      );
-      db_query("
-        CREATE TABLE {invite_notifications} (
-          uid int(10) NOT NULL default '0',
-          invitee int(10) NOT NULL default '0',
-          UNIQUE (uid, invitee)
-        ) /*!40100 DEFAULT CHARACTER SET utf8 */;"
-      );
-      break;
-
-    case 'pgsql':
-      db_query("
-        CREATE TABLE {invite} (
-          reg_code VARCHAR(8) NOT NULL DEFAULT '',
-          email VARCHAR(100) NOT NULL DEFAULT '',
-          uid INTEGER NOT NULL DEFAULT 0,
-          invitee INTEGER NOT NULL DEFAULT 0,
-          created INTEGER NOT NULL DEFAULT 0,
-          expiry INTEGER NOT NULL DEFAULT 0,
-          joined INTEGER NOT NULL DEFAULT 0,
-          canceled SMALLINT NOT NULL DEFAULT 0,
-          resent SMALLINT NOT NULL DEFAULT 0,
-          data TEXT NOT NULL DEFAULT '',
-          UNIQUE (reg_code)
-        )"
-      );
-      db_query("CREATE INDEX {invite}_email_idx ON {invite}(email)");
-      db_query("CREATE INDEX {invite}_uid_idx ON {invite}(uid)");
-      db_query("
-        CREATE TABLE {invite_notifications} (
-          uid INTEGER NOT NULL DEFAULT 0,
-          invitee INTEGER NOT NULL DEFAULT 0,
-          UNIQUE (uid, invitee)
-        )"
-      );
-      break;
-  }
+  drupal_install_schema('invite');
+}
+
+function invite_schema() {
+  $schema['invite'] = array(
+    'description' => t('The base table for invites.'),
+    'fields' => array(
+      'reg_code' => array(
+        'description' => t('Stores the issued registration code and acts as primary identifier for a invite.'),
+        'type' => 'varchar',
+        'length' => 8,
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'email' => array(
+        'description' => t('Stores the e-mail the invite has been addressed to.'),
+        'type' => 'varchar',
+        'length' => 100,
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'uid' => array(
+        'description' => t('Stores the user id of the inviter.'),
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'invitee' => array(
+        'description' => t('Stores the user id of the invitee upon registration.'),
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'created' => array(
+        'description' => t('Stores the creation time of the invite.'),
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'expiry' => array(
+        'description' => t('Stores the expiry time of the invite.'),
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'joined' => array(
+        'description' => t('Will be filled with the time the invite was accepted upon registration.'),
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'canceled' => array(
+        'description' => t('Stores whether the invite has been withdrawn.'),
+        'type' => 'int',
+        'size' => 'tiny',
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'resent' => array(
+        'description' => t('Stores how many times the invite has been resent.'),
+        'type' => 'int',
+        'size' => 'tiny',
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'data' => array(
+        'description' => t('Stores auxiliary data.'),
+        'type' => 'text',
+        'not null' => TRUE,
+      ),
+    ),
+    'unique keys' => array(
+      'reg_code' => array('reg_code'),
+    ),
+    'indexes' => array(
+      'email' => array('email'),
+      'uid'   => array('uid'),
+    ),
+  );
+
+  $schema['invite_notifications'] = array(
+    'description' => t('Stores notifications of inviters.'),
+    'fields' => array(
+      'uid' => array(
+        'description' => t('Stores the user id to be notified (inviter).'),
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'invitee' => array(
+        'description' => t('Stores the user id of the invitee.'),
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+    ),
+    'unique keys' => array(
+      'uid_invitee' => array('uid', 'invitee'),
+    )
+  );
+
+  return $schema;
 }
 
 /**
  * Implementation of hook_uninstall().
  */
 function invite_uninstall() {
-  // Drop database table
-  db_query('DROP TABLE {invite}');
+  // Drop database schema.
+  drupal_uninstall_schema('invite');
 
   // Delete variables
   $sql = "DELETE from {variable} WHERE name LIKE '%s%%'";
@@ -118,112 +164,6 @@ function _invite_add_permission($rid, $p
   }
 }
 
-function invite_update_1() {
-  $ret = array();
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      $ret[] = update_sql("ALTER TABLE {invite} CHANGE reg_code reg_code VARCHAR(64) UNIQUE NOT NULL");
-      $ret[] = update_sql("ALTER TABLE {invite} ADD INDEX reg_code_idx (reg_code)");
-      break;
-  }
-  return $ret;
-}
-
-/**
- * Drop duplicate index on reg_code. Add index for uid.
- */
-function invite_update_2() {
-  $ret = array();
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      $ret[] = update_sql("ALTER TABLE {invite} DROP INDEX reg_code_idx");
-      $ret[] = update_sql("ALTER TABLE {invite} ADD INDEX (uid)");
-      break;
-    case 'pgsql':
-      $ret[] = update_sql("DROP INDEX reg_code_idx");
-      $ret[] = update_sql("CREATE INDEX {invite}_uid_idx ON {invite} (uid)");
-      break;
-  }
-  return $ret;
-}
-
-/**
- * Clean up invites originating from deleted users.
- */
-function invite_update_3() {
-  $ret = array();
-  $result = db_query("SELECT DISTINCT i.uid FROM {invite} i LEFT JOIN {users} u ON i.uid = u.uid WHERE u.uid IS NULL");
-  $count = db_num_rows($result);
-  $sql = "DELETE FROM {invite} WHERE uid = %d";
-  if (!variable_get('invite_allow_join_delete', 0)) {
-    $sql .= " AND timestamp != 0";
-  }
-  while ($inviter = db_fetch_object($result)) {
-    db_query($sql, $inviter->uid);
-  }
-  $ret[] = array(
-    'query' => strtr('%count orphaned invites have been deleted.', array('%count' => $count)),
-    'success' => TRUE
-  );
-  return $ret;
-}
-
-/**
- * Add notification after an invited user registers.
- */
-function invite_update_4() {
-  $ret = array();
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      $ret[] = update_sql("ALTER TABLE {invite} CHANGE received received tinyint(3) unsigned NOT NULL default '0'");
-      break;
-    case 'pgsql':
-      db_change_column($ret, 'invite', 'received', 'received', 'SMALLINT', array('not null' => TRUE));
-      break;
-  }
-  // Prevent displaying a whole bunch of messages for old invites
-  $ret[] = update_sql("UPDATE {invite} SET received = 1 WHERE mid <> 0");
-  return $ret;
-}
-
-/**
- * Save invite message text.
- */
-function invite_update_5() {
-  $ret = array();
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      $ret[] = update_sql("ALTER TABLE {invite} ADD COLUMN message TEXT NOT NULL default ''");
-      break;
-    case 'pgsql':
-      db_add_column($ret, 'invite', 'message', 'TEXT', array('not null' => TRUE, 'default' => "''"));
-      break;
-  }
-  return $ret;
-}
-
-/**
- * Clean up invitations of deleted users.
- */
-function invite_update_6() {
-  $ret = array();
-  if (variable_get('invite_allow_join_delete', 0)) {
-    $result = db_query("SELECT i.mid FROM {invite} i LEFT JOIN {users} u ON i.mid = u.uid WHERE u.uid IS NULL");
-    $count = db_num_rows($result);
-    while ($invitee = db_fetch_object($result)) {
-      db_query("DELETE FROM {invite} WHERE mid = %d", $invitee->mid);
-    }
-    $ret[] = array(
-      'query' => strtr('%count orphaned invites have been deleted.', array('%count' => $count)),
-      'success' => TRUE
-    );
-  }
-  return $ret;
-}
 
 /**
  * Switch to token.module.
@@ -237,7 +177,7 @@ function invite_update_7() {
     'query' => 'The message tokens for the invite module have been successfully updated.',
     'success' => TRUE
   );
-  drupal_set_message(strtr('Please note that invite now depends on the %token module.', array('%token' => l('token', 'http://drupal.org/project/token', array('target' => '_blank'), NULL, NULL, TRUE))), 'error');
+  drupal_set_message(strtr('Please note that invite now depends on the %token module.', array('%token' => l('token', 'http://drupal.org/project/token', array('attributes' => array('target' => '_blank'), 'absolute' => TRUE)))), 'error');
   return $ret;
 }
 
@@ -246,32 +186,19 @@ function invite_update_7() {
  */
 function invite_update_8() {
   $ret = array();
-
-  // Add column data first
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      $ret[] = update_sql("ALTER TABLE {invite} ADD COLUMN data TEXT NOT NULL");
-      break;
-    case 'pgsql':
-      db_add_column($ret, 'invite', 'data', 'TEXT', array('not null' => TRUE, 'default' => "''"));
-      break;
-  }
+  db_change_field($ret, 'invite', 'message', 'data', array('type' => 'text', 'not null' => TRUE, 'default' => ''));
 
   // Convert existing messages
-  $result = db_query("SELECT reg_code, message FROM {invite} WHERE message <> ''");
+  $result = db_query("SELECT reg_code, data FROM {invite} WHERE data <> ''");
   while ($row = db_fetch_object($result)) {
     if (substr($row->message, 0, 2) == 'a:') {
       // Already serialized
       continue;
     }
-    $data = array('subject' => NULL, 'message' => $row->message);
+    $data = array('subject' => NULL, 'message' => $row->data);
     db_query("UPDATE {invite} SET data = '%s' WHERE reg_code = '%s'", serialize($data), $row->reg_code);
   }
 
-  // Finally drop column message
-  $ret[] = update_sql("ALTER TABLE {invite} DROP message");
-
   return $ret;
 }
 
@@ -376,26 +303,13 @@ function invite_update_12() {
  */
 function invite_update_200() {
   $ret = array();
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      $ret[] = update_sql("ALTER TABLE {invite} DROP PRIMARY KEY, ADD INDEX email (email)");
-      $ret[] = update_sql("ALTER TABLE {invite} CHANGE mid invitee int(10) NOT NULL default '0'");
-      $ret[] = update_sql("ALTER TABLE {invite} CHANGE timestamp joined int(10) NOT NULL default '0'");
-      $ret[] = update_sql("ALTER TABLE {invite} ADD created int(10) NOT NULL default '0'");
-      $ret[] = update_sql("ALTER TABLE {invite} ADD canceled tinyint(1) NOT NULL default '0'");
-      $ret[] = update_sql("ALTER TABLE {invite} ADD resent tinyint(3) NOT NULL default '0'");
-      break;
-    case 'pgsql':
-      $ret[] = update_sql("ALTER TABLE {invite} DROP CONSTRAINT {invite}_pkey");
-      $ret[] = update_sql("CREATE INDEX {invite}_email_idx ON {invite}(email)");
-      db_change_column($ret, 'invite', 'mid', 'invitee', 'INTEGER', array('not null' => TRUE, 'default' => 0));
-      db_change_column($ret, 'invite', 'timestamp', 'joined', 'INTEGER', array('not null' => TRUE, 'default' => 0));
-      db_add_column($ret, 'invite', 'created', 'INTEGER', array('default' => 0, 'not null' => TRUE));
-      db_add_column($ret, 'invite', 'canceled', 'SMALLINT', array('default' => 0, 'not null' => TRUE));
-      db_add_column($ret, 'invite', 'resent', 'SMALLINT', array('default' => 0, 'not null' => TRUE));
-      break;
-  }
+  db_drop_primary_key($ret, 'invite');
+  db_add_index($ret, 'invite', 'email', array('email'));
+  db_change_field($ret, 'invite', 'mid', 'invitee', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
+  db_change_field($ret, 'invite', 'timestamp', 'joined', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
+  db_add_field($ret, 'invite', 'created', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
+  db_add_field($ret, 'invite', 'cancelled', array('type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
+  db_add_field($ret, 'invite', 'resent', array('type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
   return $ret;
 }
 
@@ -404,31 +318,32 @@ function invite_update_200() {
  */
 function invite_update_201() {
   $ret = array();
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      $ret[] = update_sql("
-        CREATE TABLE {invite_notifications} (
-          uid int(10) NOT NULL default '0',
-          invitee int(10) NOT NULL default '0',
-          KEY (uid)
-        ) /*!40100 DEFAULT CHARACTER SET utf8 */;"
-      );
-      break;
-    case 'pgsql':
-      $ret[] = update_sql("
-        CREATE TABLE {invite_notifications} (
-          uid INTEGER NOT NULL DEFAULT 0,
-          invitee INTEGER NOT NULL DEFAULT 0
-        )"
-      );
-      $ret[] = update_sql("CREATE INDEX {invite_notifications}_uid_idx ON {invite_notifications}(uid)");
-      break;
-  }
+  db_create_table($ret, 'invite_notifications', array(
+    'description' => t('Stores notifications of inviters.'),
+    'fields' => array(
+      'uid' => array(
+        'description' => t('Stores the user id to be notified (inviter).'),
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'invitee' => array(
+        'description' => t('Stores the user id of the invitee.'),
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+    ),
+    'indexes' => array(
+      'uid' => array('uid'),
+    )
+  ));
   // Convert old data
-  db_query("INSERT INTO {invite_notifications} (uid, invitee) SELECT uid, invitee FROM {invite} WHERE joined != 0 AND received = 0");
+  db_query("INSERT INTO {invite_notifications} (uid, invitee) SELECT uid, invitee FROM {invite} WHERE joined <> 0 AND received = 0");
   // Drop old column
-  $ret[] = update_sql("ALTER TABLE {invite} DROP received");
+  db_drop_field($ret, 'invite', 'received');
   return $ret;
 }
 
@@ -437,16 +352,8 @@ function invite_update_201() {
  */
 function invite_update_202() {
   $ret = array();
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      $ret[] = update_sql("ALTER TABLE {invite_notifications} DROP INDEX uid,  ADD UNIQUE uid_invitee (uid, invitee)");
-      break;
-
-    case 'pgsql':
-      $ret[] = update_sql("DROP INDEX {invite_notifications}_uid_idx");
-      $ret[] = update_sql("CREATE UNIQUE INDEX {invite_notifications}_uid_invitee_key ON {invite_notifications}(uid, invitee)");
-      break;
-  }
+  db_drop_index($ret, 'invite_notifications', 'uid');
+  db_add_unique_key($ret, 'invite_notifications', 'uid_invitee', array('uid', 'invitee'));
   return $ret;
 }
+
Index: invite.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/invite/invite.module,v
retrieving revision 1.10.2.93.2.27
diff -u -p -r1.10.2.93.2.27 invite.module
--- invite.module	19 Aug 2008 12:58:52 -0000	1.10.2.93.2.27
+++ invite.module	19 Aug 2008 13:50:35 -0000
@@ -24,38 +24,25 @@ require_once drupal_get_path('module', '
 
 /**
  * Implementation of hook_help().
- *
- * Returns appropriate help text for all three invite status pages.
- */
-function invite_help($section) {
-  if (arg(0) == 'user' && is_numeric(arg(1)) && arg(2) == 'invites') {
-    return _invite_user_help($section, arg(1));
-  }
-  else if ($section == 'admin/help#invite') {
-    return _invite_module_help();
-  }
-}
-
-/**
- * Display introductory text on user profile overview pages.
- *
- * @param $section
- *   The section to display help for.
- * @param $uid
- *   A user profile id.
  */
-function _invite_user_help($section, $uid) {
-  switch ($section) {
-    case "user/$uid/invites":
-    case "user/$uid/invites/accepted":
+function invite_help($path, $arg) {
+  switch ($path) {
+    // Display module help
+    case 'admin/help#invite':
+      return _invite_module_help();
+
+    // Display introductory text on user profile pages
+    case 'user/%/invites':
+    case 'user/%/invites/accepted':
       $output = '<p>'. t("The invitations shown on this page have been used to join the site. Clicking on an e-mail address takes you to the user's profile page.");
       break;
-    case "user/$uid/invites/pending":
+    case 'user/%/invites/pending':
       $output = '<p>'. t("The invitations shown on this page haven't been accepted yet.");
       break;
-    case "user/$uid/invites/expired":
+    case 'user/%/invites/expired':
       $output = '<p>'. t('The invitations shown on this page have not been used to register on the site within the expiration period of @count days.', array('@count' => variable_get('invite_expiry', 30)));
       break;
+
     default:
       return;
   }
@@ -77,6 +64,25 @@ function _invite_module_help() {
 }
 
 /**
+ * Implementation of hook_theme().
+ */
+function invite_theme() {
+  return array(
+    'invite_form' => array(
+      'arguments' => array('form' => NULL),
+    ),
+    'invite_user_overview' => array(
+      'arguments' => array('items' => NULL),
+      'file' => 'invite_admin.inc',
+    ),
+    'invite_token_help' => array(
+      'arguments' => array('type' => NULL, 'prefix' => NULL, 'suffix' => NULL),
+      'file' => 'invite_token.inc',
+    ),
+  );
+}
+
+/**
  * Implementation of hook_perm().
  */
 function invite_perm() {
@@ -89,140 +95,166 @@ function invite_perm() {
 }
 
 /**
- * Implementation of hook_menu().
+ * Implements hook_init().
  */
-function invite_menu($may_cache) {
+function invite_init() {
   global $user;
-  $items = array();
 
-  $send_access = user_access('send invitations');
-  $track_access = user_access('track invitations');
-  $admin_access = user_access('administer site configuration');
-
-  if ($may_cache) {
-    $items[] = array(
-      'path' => 'admin/user/invite',
-      'title' => t('Invites'),
-      'callback' => 'invite_admin_overview',
-      'access' => $admin_access,
-      'type' => MENU_NORMAL_ITEM,
-    );
-    $items[] = array(
-      'path' => 'admin/user/invite/list',
-      'title' => t('Inviters'),
-      'access' => $admin_access,
-      'type' => MENU_DEFAULT_LOCAL_TASK,
-      'weight' => -5,
-    );
-    $items[] = array(
-      'path' => 'admin/user/invite/settings',
-      'title' => t('Settings'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => 'invite_settings',
-      'access' => $admin_access,
-      'type' => MENU_LOCAL_TASK,
-      'weight' => 5,
-    );
-    $items[] = array(
-      'path' => 'invite',
-      'title' => variable_get('invite_page_title', t('Invite a friend')),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('invite_form', 'page', array()),
-      'access' => $send_access,
-      'type' => MENU_NORMAL_ITEM,
-    );
-    $items[] = array(
-      'path' => 'invite/accept',
-      'callback' => 'invite_controller',
-      'access' => TRUE,
-      'type' => MENU_CALLBACK,
-    );
-    $items[] = array(
-      'path' => 'invite/withdraw',
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('invite_cancel'),
-      'access' => $track_access,
-      'type' => MENU_CALLBACK,
-    );
+  // Notify current user about newly joined invitees.
+  if (!empty($user->invite_sent) && !module_invoke('throttle', 'status')) {
+    invite_notify($user->uid);
   }
-  else {
-    // Notify current user about newly joined invitees.
-    if (!empty($user->invite_sent) && !module_invoke('throttle', 'status')) {
-      invite_notify($user->uid);
-    }
+}
 
-    if (arg(0) == 'user' && is_numeric(arg(1)) && arg(1) == $user->uid) {
-      $items[] = array(
-        'path' => 'user/'. arg(1) .'/invites',
-        'title' => t('Track invitations'),
-        'callback' => 'invite_user_overview',
-        'access' => $track_access,
-        'type' => MENU_LOCAL_TASK,
-      );
-      $items[] = array(
-        'path' => 'user/'. arg(1) .'/invites/accepted',
-        'title' => t('Accepted'),
-        'callback' => 'invite_user_overview',
-        'callback arguments' => array('accepted'),
-        'access' => $track_access,
-        'type' => MENU_DEFAULT_LOCAL_TASK,
-        'weight' => -5,
-      );
-      $items[] = array(
-        'path' => 'user/'. arg(1) .'/invites/pending',
-        'title' => t('Pending'),
-        'callback' => 'invite_user_overview',
-        'callback arguments' => array('pending'),
-        'access' => $track_access,
-        'type' => MENU_LOCAL_TASK,
-      );
-      $items[] = array(
-        'path' => 'user/'. arg(1) .'/invites/expired',
-        'title' => t('Expired'),
-        'callback' => 'invite_user_overview',
-        'callback arguments' => array('expired'),
-        'access' => $track_access,
-        'type' => MENU_LOCAL_TASK,
-        'weight' => 5,
-      );
-      $items[] = array(
-        'path' => 'user/'. arg(1) .'/invites/new',
-        'title' => t('New invitation'),
-        'callback' => 'drupal_get_form',
-        'callback arguments' => array('invite_form', 'page', array()),
-        'access' => $send_access,
-        'type' => MENU_LOCAL_TASK,
-        'weight' => 10,
-      );
-    }
-    else if (arg(2) == 'invite' && arg(3) == 'details' && arg(4)) {
-      if ($account = user_load(array('uid' => arg(4)))) {
-        $items[] = array(
-          'path' => 'admin/user/invite/details/'. arg(4),
-          'title' => t('Invitees of @name', array('@name' => $account->name)),
-          'callback' => 'invite_admin_details',
-          'callback arguments' => array(arg(4)),
-          'access' => $admin_access,
-          'type' => MENU_LOCAL_TASK,
-        );
-      }
-    }
-    else if (arg(0) == 'invite' && arg(1) == 'resend' && arg(2)) {
-      $items[] = array(
-        'path' => 'invite/resend/'. arg(2),
-        'title' => t('Resend invitation'),
-        'callback' => 'invite_resend',
-        'callback arguments' => array(arg(2)),
-        'access' => $send_access,
-        'type' => MENU_CALLBACK,
-      );
-    }
-  }
+/**
+ * Implementation of hook_menu().
+ */
+function invite_menu() {
+  // Admin menu items
+  $items['admin/user/invite'] = array(
+    'title' => 'Invites',
+    'page callback' => 'invite_admin_overview',
+    'access arguments' => array('administer site configuration'),
+    'type' => MENU_NORMAL_ITEM,
+    'file' => 'invite_admin.inc',
+  );
+  $items['admin/user/invite/list'] = array(
+    'title' => 'Inviters',
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+    'weight' => -10,
+  );
+  $items['admin/user/invite/settings'] = array(
+    'title' => 'Settings',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('invite_settings'),
+    'access arguments' => array('administer site configuration'),
+    'type' => MENU_LOCAL_TASK,
+    'weight' => 10,
+    'file' => 'invite_admin.inc',
+  );
+  $items['admin/user/invite/details/%user'] = array(
+    'title callback' => 'invite_admin_details_page_title',
+    'title arguments' => array(4),
+    'page callback' => 'invite_admin_details',
+    'page arguments' => array(4),
+    'access arguments' => array('administer site configuration'),
+    'type' => MENU_LOCAL_TASK,
+    'file' => 'invite_admin.inc',
+  );
+
+  // Frontend menu items
+  $items['invite'] = array(
+    'title' => t('Invite a friend'),
+    'title callback' => 'invite_page_title',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('invite_form', 'page', array()),
+    'access arguments' => array('send invitations'),
+    'type' => MENU_NORMAL_ITEM,
+  );
+  $items['invite/accept/%invite'] = array(
+    'page callback' => 'invite_accept',
+    'page arguments' => array(2),
+    'access callback' => TRUE,
+    'type' => MENU_CALLBACK,
+  );
+  $items['invite/withdraw'] = array(
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('invite_cancel'),
+    'access arguments' => array('track invitations'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['invite/resend/%invite'] = array(
+    'title' => 'Resend invitation',
+    'page callback' => 'invite_resend',
+    'page arguments' => array(2),
+    'access arguments' => array('send invitations'),
+    'type' => MENU_CALLBACK,
+  );
+
+  // User profile tabs
+  $items['user/%user/invites'] = array(
+    'title' => 'Track invitations',
+    'page callback' => 'invite_user_overview',
+    'access callback' => 'invite_access_callback',
+    'access arguments' => array('track invitations', 1),
+    'type' => MENU_LOCAL_TASK,
+    'file' => 'invite_admin.inc',
+  );
+  $items['user/%user/invites/accepted'] = array(
+    'title' => 'Accepted',
+    'page callback' => 'invite_user_overview',
+    'page arguments' => array('accepted'),
+    'access callback' => 'invite_access_callback',
+    'access arguments' => array('track invitations', 1),
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+    'weight' => -5,
+    'file' => 'invite_admin.inc',
+  );
+  $items['user/%user/invites/pending'] = array(
+    'title' => 'Pending',
+    'page callback' => 'invite_user_overview',
+    'page arguments' => array('pending'),
+    'access callback' => 'invite_access_callback',
+    'access arguments' => array('track invitations', 1),
+    'type' => MENU_LOCAL_TASK,
+    'file' => 'invite_admin.inc',
+  );
+  $items['user/%user/invites/expired'] = array(
+    'title' => 'Expired',
+    'page callback' => 'invite_user_overview',
+    'page arguments' => array('expired'),
+    'access callback' => 'invite_access_callback',
+    'access arguments' => array('track invitations', 1),
+    'type' => MENU_LOCAL_TASK,
+    'weight' => 5,
+    'file' => 'invite_admin.inc',
+  );
+  $items['user/%user/invites/new'] = array(
+    'title' => 'New invitation',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('invite_form', 'page', array()),
+    'access callback' => 'invite_access_callback',
+    'access arguments' => array('send invitations', 1),
+    'type' => MENU_LOCAL_TASK,
+    'weight' => 10,
+  );
 
   return $items;
 }
 
 /**
+ * Title callback allowing for customization of the invite page title.
+ *
+ * @param $title
+ *   The default page title, ie. non-overridden.
+ */
+function invite_page_title($title) {
+  return variable_get('invite_page_title', $title);
+}
+
+/**
+ * Title callback for the user details administration page.
+ *
+ * @param $account
+ */
+function invite_admin_details_page_title($account) {
+  return t('Invitees of @name', array('@name' => $account->name));
+}
+
+/**
+ * Access callback ensuring the user profile tabs are visible only to their
+ * owner.
+ *
+ * @param $permission
+ *   Required permission to view the item.
+ * @param $account
+ *   A user object.
+ */
+function invite_access_callback($permission, $account) {
+  return ($account->uid == $GLOBALS['user']->uid && user_access($permission));
+}
+
+/**
  * Displays a notification message when an invited user has registered.
  *
  * @param $uid
@@ -241,19 +273,16 @@ function invite_notify($uid) {
 
 /**
  * Menu callback; handle incoming requests for accepting an invite.
+ *
+ * @param $invite
+ *   A (unvalidated) invite object.
  */
-function invite_controller() {
+function invite_accept($invite) {
   global $user;
 
-  if (!$user->uid) {
-    // User not logged in.
-    $invite = invite_load(arg(2));
-
-    // Check for a valid invite code.
-    if (invite_validate($invite)) {
-      $_SESSION[INVITE_SESSION] = $invite->reg_code;
-      drupal_goto('user/register');
-    }
+  if (!$user->uid && invite_validate($invite)) {
+    $_SESSION[INVITE_SESSION] = $invite->reg_code;
+    drupal_goto('user/register');
   }
 
   drupal_goto();
@@ -262,7 +291,7 @@ function invite_controller() {
 /**
  * Implementation of hook_form_alter().
  */
-function invite_form_alter($form_id, &$form) {
+function invite_form_alter(&$form, $form_state, $form_id) {
   switch ($form_id) {
     case 'user_admin_settings':
       // Add new registration mode.
@@ -312,7 +341,7 @@ function invite_form_alter($form_id, &$f
       // Remove temptation for non members to try and register.
       if (variable_get('user_register', 1) === '1-inviteonly') {
         $new_items = array();
-        $new_items[] = l(t('Request new password'), 'user/password', array('title' => t('Request new password via e-mail.')));
+        $new_items[] = l(t('Request new password'), 'user/password', array('attributes' => array('title' => t('Request new password via e-mail.'))));
         $form['links']['#value'] = theme('item_list', $new_items);
       }
       break;
@@ -394,7 +423,7 @@ function invite_user($op, &$edit, &$acco
         }
       }
       if ($invite) {
-        invite_accept($invite, $account);
+        _invite_accept($invite, $account);
 
         // Flag the inviting user, this triggers status notifications and
         // saves us some queries otherwise.
@@ -420,7 +449,7 @@ function invite_user($op, &$edit, &$acco
  * @param $account
  *   The user object of the invitee.
  */
-function invite_accept($invite, $account) {
+function _invite_accept($invite, $account) {
   // Update the invitation record.
   db_query("UPDATE {invite} SET email = '%s', invitee = %d, joined = %d WHERE reg_code = '%s'", $account->mail, $account->uid, time(), $invite->reg_code);
   // Delete all invites to these e-mail addresses, except this one.
@@ -500,10 +529,11 @@ function invite_delete($uid) {
  */
 function invite_block($op = 'list', $delta = 0, $edit = array()) {
   if ($op == 'list') {
-    $blocks[0] = array('info' => t('Invite a friend'));
+    $blocks[0] = array('info' => t('Invite a friend'), 'cache' => BLOCK_CACHE_PER_ROLE);
     return $blocks;
   }
   else if ($op == 'view') {
+    $block = array();
     switch ($delta) {
       case 0:
         if (user_access('send invitations')) {
@@ -528,7 +558,7 @@ function invite_block($op = 'list', $del
  * @return
  *   A form definition.
  */
-function invite_form($op = 'page', $edit = array()) {
+function invite_form(&$form_state, $op = 'page', $edit = array()) {
   global $user;
 
   if (!is_array($edit)) {
@@ -812,7 +842,7 @@ function invite_block_form($remaining_in
  */
 function theme_invite_form($form) {
   $output = '';
-  $op = $form['#parameters'][1];
+  $op = $form['#parameters'][2];
 
   if ($op == 'page') {
     // Show form elements.
@@ -852,15 +882,15 @@ function theme_invite_form($form) {
  * Filters out e-mails that are already registered or have been invited before.
  * Checks the invite limit of the user and the max. number of invites per turn.
  */
-function invite_form_validate($form_id, &$edit) {
+function invite_form_validate($form, &$form_state) {
   global $user;
 
-  $emails = _invite_get_emails($edit['email']);
+  $emails = _invite_get_emails($form_state['values']['email']);
 
-  if (!$edit['resent']) {
+  if (!$form_state['values']['resent']) {
     if (count($emails) > 0) {
       // Filter out already registered users, but pass validation.
-      $failed_emails = _invite_validate_emails("SELECT mail AS email FROM {users} WHERE mail IN (%s)", $emails);
+      $failed_emails = _invite_validate_emails("SELECT mail AS email FROM {users} WHERE mail IN (". db_placeholders($emails, 'varchar') .")", $emails);
       if (count($failed_emails)) {
         $error = format_plural(count($failed_emails), 'The following recipient is already a member:', 'The following recipients are already members:') .'<br />';
         foreach ($failed_emails as $key => $email) {
@@ -872,7 +902,7 @@ function invite_form_validate($form_id, 
       }
 
       // Filter out already invited users, but pass validation.
-      $failed_emails = _invite_validate_emails("SELECT email FROM {invite} WHERE email IN (%s) AND uid = %d AND canceled = 0", $emails, $user->uid);
+      $failed_emails = _invite_validate_emails("SELECT email FROM {invite} WHERE email IN (". db_placeholders($emails, 'varchar') .") AND uid = %d AND canceled = 0", $emails, $user->uid);
       if (count($failed_emails)) {
         $error = format_plural(count($failed_emails), 'You did already invite the following recipient:', 'You did already invite the following recipients:') .'<br />';
         $error .= implode(', ', array_map('check_plain', $failed_emails));
@@ -887,8 +917,8 @@ function invite_form_validate($form_id, 
       }
 
       // Check invite limit, fail to let the user choose which ones to send.
-      if (isset($edit['remaining_invites']) && count($emails) > $edit['remaining_invites']) {
-        form_set_error('email', format_plural($edit['remaining_invites'], 'You have only 1 invite left.', 'You have only @count invites left.'));
+      if (isset($form_state['values']['remaining_invites']) && count($emails) > $form_state['values']['remaining_invites']) {
+        form_set_error('email', format_plural($form_state['values']['remaining_invites'], 'You have only 1 invite left.', 'You have only @count invites left.'));
         return;
       }
 
@@ -901,7 +931,7 @@ function invite_form_validate($form_id, 
   }
 
   // Save valid emails.
-  form_set_value(array('#parents' => array('valid_emails')), $emails);
+  $form_state['values']['valid_emails'] = $emails;
 }
 
 /**
@@ -953,21 +983,20 @@ function _invite_get_emails($string) {
  *   The list of e-mail addresses to validate. When this function returns, all
  *   invalid e-mails have already been removed.
  * @param ...
- *   More arguments.
+ *   More query arguments.
  * @return
- *   The list of failed e-mail addresses.
+ *   An array of invalid e-mail addresses.
  */
 function _invite_validate_emails($sql, &$emails) {
   $failed_emails = array();
+  // Build query arguments.
   $args = func_get_args();
-  array_shift($args);
-  array_shift($args);
-  array_unshift($args, "'". implode("','", array_map('db_escape_string', $emails)) ."'");
-  $result = db_query(vsprintf($sql, $args));
+  $args = array_merge($emails, array_slice($args, 2));
+  $result = db_query($sql, $args);
   while ($row = db_fetch_object($result)) {
     $failed_emails[] = $row->email;
   }
-  // Leave only valid emails.
+  // Keep only valid e-mails.
   $emails = array_diff($emails, $failed_emails);
   return $failed_emails;
 }
@@ -975,8 +1004,11 @@ function _invite_validate_emails($sql, &
 /**
  * Forms API callback; process submitted form data.
  */
-function invite_form_submit($form_id, $edit) {
-  global $user;
+function invite_form_submit($form, &$form_state) {
+  global $user, $language;
+
+  // Set this now, so other modules can change it later.
+  $form_state['redirect'] = 'invite';
 
   $failed_emails = array();
   $num_failed = $num_succeeded = 0;
@@ -987,29 +1019,39 @@ function invite_form_submit($form_id, $e
     $num_failed = count($failed_emails);
   }
 
-  $subject = isset($edit['subject']) ? trim($edit['subject']) : invite_get_subject();
-  $message = isset($edit['message']) ? trim($edit['message']) : NULL;
+  $subject = isset($form_state['values']['subject']) ? trim($form_state['values']['subject']) : invite_get_subject();
+  $message = isset($form_state['values']['message']) ? trim($form_state['values']['message']) : NULL;
+
+  if (!variable_get('invite_use_users_email', 0)) {
+    $from = variable_get('invite_manual_from', '');
+  }
+  else if ($user->uid) {
+    $from = $user->mail;
+  }
+  if (!$from) {
+    // Never pass an empty string to drupal_mail()
+    $from = NULL;
+  }
 
-  foreach ($edit['valid_emails'] as $email) {
+  foreach ($form_state['values']['valid_emails'] as $email) {
     // Create the invite object.
-    $code = $edit['reg_code'] ? $edit['reg_code'] : invite_generate_code();
+    $code = $form_state['values']['reg_code'] ? $form_state['values']['reg_code'] : invite_generate_code();
     $invite = _invite_substitutions(array(
       'email' => $email,
       'code'  => $code,
-      'resent'  => $edit['resent'],
+      'resent'  => $form_state['values']['resent'],
       'data'  => array('subject' => $subject, 'message' => $message),
     ));
 
-    // Perform token replacement on mail body.
-    $body = token_replace_multiple(t(_invite_get_mail_template()), _invite_token_types($invite));
-
     // Send e-mail.
-    if (invite_send_invite($email, $subject, $body)) {
+    $params = array('invite' => $invite);
+    $message = drupal_mail('invite', 'invite', $email, $language, $params, $from, TRUE);
+    if (1 || $message['result']) {
       // Save invite.
       invite_save($invite);
 
       // Notify other modules.
-      if (!$edit['resent']) {
+      if (!$form_state['values']['resent']) {
         $args = array('inviter' => $invite->inviter, 'email' => $invite->email, 'code' => $invite->code);
         module_invoke_all('invite', 'invite', $args);
       }
@@ -1027,9 +1069,9 @@ function invite_form_submit($form_id, $e
   }
 
   if ($num_succeeded) {
-    if (isset($edit['remaining_invites'])) {
+    if (isset($form_state['values']['remaining_invites'])) {
       // Update user property if user is limited.
-      user_save($user, array('invites' => $edit['remaining_invites'] - $num_succeeded));
+      user_save($user, array('invites' => $form_state['values']['remaining_invites'] - $num_succeeded));
     }
     $message = format_plural($num_succeeded, 'Your invitation has been successfully sent. You will be notified when the invitee joins the site.', '@count invitations have been successfully sent. You will be notified when any invitee joins the site.');
     drupal_set_message($message);
@@ -1040,10 +1082,8 @@ function invite_form_submit($form_id, $e
   }
   else if (user_access('track invitations') && $user->uid) {
     // Everything went well: redirect to pending invites page.
-    return "user/$user->uid/invites/pending";
+    $form_state['redirect'] = "user/$user->uid/invites/pending";
   }
-
-  return 'invite';
 }
 
 /**
@@ -1075,63 +1115,29 @@ function invite_generate_code() {
 }
 
 /**
- * Sends an invite to the specified e-mail address.
- *
- * @param $recipient
- *   The recipient's e-mail address.
- * @param $subject
- *   The e-mail subject.
- * @param $body
- *   The e-mail body.
+ * Implementation of hook_mail().
  */
-function invite_send_invite($recipient, $subject, $body) {
+function invite_mail($key, &$message, $params) {
   global $user;
 
-  $headers = array();
+  $invite = $params['invite'];
 
-  // Prevent e-mail looking like spam to SPF-enabled MTAs.
-  // @see http://drupal.org/node/133789
-  $from_site = variable_get('site_mail', ini_get('sendmail_from'));
-  if ($from_site) {
-    $headers['Sender'] = $headers['Return-Path'] = $headers['Errors-To'] = $from_site;
+  // Override Reply-To address.
+  if (!variable_get('invite_use_users_email_replyto', 0)) {
+    $reply_to = variable_get('invite_manual_reply_to', '');
   }
-
-  // Manual settings override custom settings below.
-  // Note: default value must be NULL to comply with legacy Drupal versions.
-  $from = variable_get('invite_manual_from', NULL);
-  $reply_to = variable_get('invite_manual_reply_to', NULL);
-
-  // Set custom From and Reply-To headers.
-  if (!$from) {
-    if ($user->uid && variable_get('invite_use_users_email', 0)) {
-      $from = $user->mail;
-    }
-    else if ($from_site) {
-      $from = $from_site;
-    }
-  }
-  if (!$reply_to) {
-    if ($user->uid && variable_get('invite_use_users_email_replyto', 0)) {
-      $reply_to = $user->mail;
-    }
-    else if ($from_site) {
-      $reply_to = $from_site;
-    }
+  else if ($user->uid) {
+    $reply_to = $user->mail;
   }
   if ($reply_to) {
-    $headers['Reply-To'] = $reply_to;
+    $message['headers']['Reply-To'] = $reply_to;
   }
 
-  if (!($success = drupal_mail('invite-mail', $recipient, $subject, wordwrap($body, 72), $from, $headers))) {
-    static $error_shown = FALSE;
-    if (!$error_shown) {
-      drupal_set_message(t('Problems occurred while sending the invitation(s). Please contact the site administrator.'), 'error');
-      $error_shown = TRUE;
-    }
-    watchdog('invite', t('Failed sending invitation. To: @email From: @from', array('@email' => '<'. $recipient .'>', '@from' => '<'. $from .'>')));
-  }
+  $message['subject'] = $invite->data['subject'];
 
-  return $success;
+  $template = t(_invite_get_mail_template());
+  $tokens = _invite_token_types($invite);
+  $message['body'][] = token_replace_multiple($template, $tokens);
 }
 
 /**
@@ -1194,7 +1200,7 @@ function invite_cancel($origin, $code) {
     }
   }
   else {
-    watchdog('invite', t('Detected malicious attempt to delete an invitation.'), WATCHDOG_WARNING, l(t('view'), 'user/'. $user->uid));
+    watchdog('invite', 'Detected malicious attempt to delete an invitation.', array(), WATCHDOG_WARNING, l(t('view'), 'user/'. $user->uid));
     drupal_access_denied();
   }
 
@@ -1204,8 +1210,8 @@ function invite_cancel($origin, $code) {
 /**
  * Submit handler to delete an invitation.
  */
-function invite_cancel_submit($form_id, $form_values) {
-  $invite = $form_values['invite'];
+function invite_cancel_submit($form, $form_state) {
+  $invite = $form_state['values']['invite'];
 
   db_query("UPDATE {invite} SET canceled = 1 WHERE reg_code = '%s'", $invite->reg_code);
   drupal_set_message(t('Invitation to %email has been withdrawn.', array('%email' => $invite->email)));
@@ -1218,21 +1224,18 @@ function invite_cancel_submit($form_id, 
 /**
  * Menu callback; resend an expired invite.
  *
- * @param $code
- *   Registration code of invitate to resend.
+ * @param $invite
+ *   An invitate object.
  */
-function invite_resend($code) {
+function invite_resend($invite) {
   global $user;
 
-  $invite = invite_load($code);
-
   // Inviter must match current user and invitation must have expired.
   if ($invite->uid == $user->uid && $invite->expiry < time()) {
     return drupal_get_form('invite_form', 'page', $invite);
   }
-  else {
-    drupal_access_denied();
-  }
+
+  return drupal_access_denied();
 }
 
 /**
@@ -1257,47 +1260,6 @@ function invite_count($uid, $op) {
 }
 
 /**
- * Menu callback; return a list of all users that have invited someone.
- */
-function invite_admin_overview() {
-  require_once drupal_get_path('module', 'invite') .'/invite_admin.inc';
-  return _invite_admin_overview();
-}
-
-/**
- * Menu callback; return a list of invites by a user.
- *
- * @param $uid
- *   A user id.
- */
-function invite_admin_details($uid) {
-  require_once drupal_get_path('module', 'invite') .'/invite_admin.inc';
-  return _invite_admin_details($uid);
-}
-
-/**
- * Menu callback; display invite settings form.
- *
- * @return
- *   A form definition array.
- */
-function invite_settings() {
-  require_once drupal_get_path('module', 'invite') .'/invite_admin.inc';
-  return _invite_settings();
-}
-
-/**
- * Menu callback; display an overview of sent invitations.
- *
- * @param $page
- *   Which invites to list: accepted, pending, or expired.
- */
-function invite_user_overview($page = 'accepted') {
-  require_once drupal_get_path('module', 'invite') .'/invite_admin.inc';
-  return _invite_user_overview($page);
-}
-
-/**
  * Implementation of hook_disable().
  */
 function invite_disable() {
Index: invite_admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/invite/Attic/invite_admin.inc,v
retrieving revision 1.1.2.4
diff -u -p -r1.1.2.4 invite_admin.inc
--- invite_admin.inc	10 Jul 2008 10:27:28 -0000	1.1.2.4
+++ invite_admin.inc	19 Aug 2008 13:17:16 -0000
@@ -4,10 +4,10 @@
 /**
  * Menu callback; display invite settings form.
  */
-function _invite_settings() {
+function invite_settings() {
   $roles = user_roles(0, 'send invitations');
   if (count($roles) == 0) {
-    drupal_set_message(t('Please enable the <em>send invitations</em> permission for at least one role. This can be done on the <a href="!admin-user-access">Access control page</a>.', array('!admin-user-access' => url('admin/user/access'))));
+    drupal_set_message(t('Please enable the <em>send invitations</em> permission for at least one role. This can be done on the <a href="!permissions-url">Permissions page</a>.', array('!permissions-url' => url('admin/user/permissions'))));
   }
   $target_roles = user_roles(1);
 
@@ -40,7 +40,7 @@ function _invite_settings() {
   $form['role'] = array(
     '#type' => 'fieldset',
     '#title' => t('Role settings'),
-    '#description' => t('Note: Permission related settings can be found at the <a href="!admin-user-access">Access control page</a>.', array('!admin-user-access' => url('admin/user/access'))),
+    '#description' => t('Note: Permission related settings can be found at the <a href="!permissions-url">Permissions page</a>.', array('!permissions-url' => url('admin/user/permissions'))),
     '#collapsible' => TRUE,
     '#collapsed' => TRUE,
   );
@@ -134,13 +134,13 @@ function _invite_settings() {
   $form['email']['advanced']['invite_manual_from'] = array(
     '#type' => 'textfield',
     '#title' => t('Manually override <em>From</em> e-mail address'),
-    '#default_value' => variable_get('invite_manual_from', NULL),
+    '#default_value' => variable_get('invite_manual_from', ''),
     '#description' => t('The e-mail address the invitation e-mail is sent from.'),
   );
   $form['email']['advanced']['invite_manual_reply_to'] = array(
     '#type' => 'textfield',
     '#title' => t('Manually override <em>Reply-To</em> e-mail address'),
-    '#default_value' => variable_get('invite_manual_reply_to', NULL),
+    '#default_value' => variable_get('invite_manual_reply_to', ''),
     '#description' => t('The e-mail address you want recipients to reply to.'),
   );
 
@@ -165,7 +165,7 @@ function _invite_settings() {
 /**
  * Return a list of all users that have invited someone.
  */
-function _invite_admin_overview() {
+function invite_admin_overview() {
   $header = array(
     array('data' => t('Username'), 'field' => 'u1.name', 'sort' => 'asc'),
     array('data' => t('Total'), 'field' => 'invites'),
@@ -175,7 +175,7 @@ function _invite_admin_overview() {
     t('Remaining'),
     t('Operations'),
   );
-  
+
   $now = time();
   $filter = $filter_args = $query = NULL;
   $output = drupal_get_form('invite_admin_filter_form');
@@ -190,7 +190,7 @@ function _invite_admin_overview() {
   $count_sql  = "SELECT COUNT(DISTINCT i.uid) FROM {invite} i". $filter;
   $result = pager_query($sql, 50, 0, $count_sql, $filter_args);
   $rows = array();
-  
+
   while ($row = db_fetch_object($result)) {
     $cells = array();
     $cells[] = theme('username', $row);
@@ -200,10 +200,10 @@ function _invite_admin_overview() {
     $cells[] = invite_count($row->uid, 'expired');
     $remaining = invite_get_remaining_invites($row);
     $cells[] = ($remaining == INVITE_UNLIMITED) ? '&infin;' : $remaining;
-    $cells[] = l(t('details'), "admin/user/invite/details/$row->uid", array(), $query);
+    $cells[] = l(t('details'), "admin/user/invite/details/$row->uid", array('query' => $query));
     $rows[] = $cells;
   }
-  
+
   $output .= theme('table', $header, $rows, array('id' => 'invite'));
   if (!$rows) {
     $output .= t('No inviters found.');
@@ -228,7 +228,7 @@ function invite_admin_filter_form() {
   $form['filter']['filter'] = array(
     '#type' => 'textfield',
     '#title' => t('Find an invited user'),
-    '#default_value' => $_SESSION[INVITE_ADMIN_SESSION],
+    '#default_value' => isset($_SESSION[INVITE_ADMIN_SESSION]) ? $_SESSION[INVITE_ADMIN_SESSION] : '',
     '#autocomplete_path' => 'user/autocomplete',
     '#size' => 20,
   );
@@ -239,22 +239,22 @@ function invite_admin_filter_form() {
   return $form;
 }
 
-function invite_admin_filter_form_submit($form_id, $form_values) {
-  if ($form_values['filter']) {
-    $_SESSION[INVITE_ADMIN_SESSION] = $form_values['filter'];
+function invite_admin_filter_form_submit($form, &$form_state) {
+  if ($form_state['values']['filter']) {
+    $_SESSION[INVITE_ADMIN_SESSION] = $form_state['values']['filter'];
   }
 }
 
 /**
  * Return a list of invites by a user.
  *
- * @param $uid
- *   A user id.
+ * @param $account
+ *   A user object.
  */
-function _invite_admin_details($uid) {
+function invite_admin_details($account) {
   $now = time();
   $status_sort = '';
-  if ($_GET['order'] == t('Status')) {
+  if (isset($_GET['order']) && $_GET['order'] == t('Status')) {
     $sort = db_escape_string($_GET['sort']);
     if ($_GET['sort'] == 'asc') {
       $status_sort = "IF(i.joined != 0, 0, 1) $sort, IF(i.expiry < $now, 0, 1) $sort, i.canceled";
@@ -270,19 +270,19 @@ function _invite_admin_details($uid) {
     array('data' => t('Expires'), 'field' => 'i.expiry'),
     array('data' => t('Status'), 'field' => $status_sort),
   );
-  
+
   $output = '';
   $filter = $filter_args = NULL;
   if (isset($_GET['filter']) && $_GET['filter'] != '') {
     $filter = " AND LOWER(u.name) LIKE '%s%%'";
     $filter_args = $_GET['filter'];
-    $output .= drupal_get_form('invite_admin_details_filter_form', $uid, $_GET['filter']);
+    $output .= drupal_get_form('invite_admin_details_filter_form', $account->uid, $_GET['filter']);
   }
   $sql  = "SELECT i.email, i.invitee AS uid, u.name, i.created, i.expiry, i.joined, i.canceled FROM {invite} i LEFT JOIN {users} u ON u.uid = i.invitee AND u.uid <> 0 WHERE i.uid = %d". $filter;
   $sql .= tablesort_sql($header);
-  $result = pager_query($sql, 50, 0, NULL, $uid, $filter_args);
+  $result = pager_query($sql, 50, 0, NULL, $account->uid, $filter_args);
   $rows = array();
-  
+
   while ($row = db_fetch_object($result)) {
     $cells = array();
     $cells[] = check_plain($row->email);
@@ -322,7 +322,7 @@ function invite_admin_details_filter_for
     '#value' => t('Clear'),
     '#prefix' => ' ',
   );
-  return $form;  
+  return $form;
 }
 
 /**
@@ -331,7 +331,7 @@ function invite_admin_details_filter_for
  * @param $page
  *   Which invites to list: accepted, pending, or expired.
  */
-function _invite_user_overview($page = 'accepted') {
+function invite_user_overview($page = 'accepted') {
   global $user;
 
   $rows = array();
Index: invite_cancel_account.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/invite/invite_cancel_account.info,v
retrieving revision 1.1.2.1.2.1
diff -u -p -r1.1.2.1.2.1 invite_cancel_account.info
--- invite_cancel_account.info	10 Jul 2008 10:27:28 -0000	1.1.2.1.2.1
+++ invite_cancel_account.info	18 Aug 2008 14:49:46 -0000
@@ -1,5 +1,6 @@
 ; $Id: invite_cancel_account.info,v 1.1.2.1.2.1 2008/07/10 10:27:28 smk Exp $
 name = Cancel User Accounts
 description = "Allows your users to terminate user accounts by withdrawing their invitation. WARNING - This module is put into effect when you enable it."
-dependencies = invite
+dependencies[] = invite
 package = Invite
+core = 6.x
Index: invite_stats.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/invite/invite_stats.info,v
retrieving revision 1.1.2.2.2.1
diff -u -p -r1.1.2.2.2.1 invite_stats.info
--- invite_stats.info	10 Jul 2008 10:27:28 -0000	1.1.2.2.2.1
+++ invite_stats.info	18 Aug 2008 14:49:51 -0000
@@ -1,5 +1,6 @@
 ; $Id: invite_stats.info,v 1.1.2.2.2.1 2008/07/10 10:27:28 smk Exp $
 name = Invite Statistics
 description = "Displays some statistics about sent invitations."
-dependencies = invite
+dependencies[] = invite
 package = Invite
+core = 6.x
Index: invite_stats.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/invite/invite_stats.module,v
retrieving revision 1.1.2.1.2.5
diff -u -p -r1.1.2.1.2.5 invite_stats.module
--- invite_stats.module	10 Jul 2008 10:27:28 -0000	1.1.2.1.2.5
+++ invite_stats.module	19 Aug 2008 12:38:49 -0000
@@ -7,6 +7,20 @@
  */
 
 /**
+ * Implementation of hook_theme().
+ */
+function invite_stats_theme() {
+  return array(
+    'invite_stats_ranking' => array(
+      'arguments' => array('inviters' => NULL, 'rank' => 1),
+    ),
+    'invite_stats_count' => array(
+      'arguments' => array('count' => NULL),
+    ),
+  );
+}
+
+/**
  * Implementation of hook_perm().
  */
 function invite_stats_perm() {
@@ -121,7 +135,11 @@ function invite_stats_display_user_rank(
   $user_invite_stats_count = db_result(db_query("SELECT COUNT(*) FROM {invite} WHERE uid = %d AND joined <> 0", $uid));
 
   // Calculate user's rank.
-  $rank = 1 + db_num_rows(db_query("SELECT DISTINCT COUNT(uid) FROM {invite} WHERE joined <> 0 GROUP BY uid HAVING COUNT(uid) > %d", $user_invite_stats_count));
+  $result = db_query("SELECT DISTINCT COUNT(uid) FROM {invite} WHERE joined <> 0 GROUP BY uid HAVING COUNT(uid) > %d", $user_invite_stats_count);
+  $rank = 1;
+  while ($row = db_fetch_array($result)) {
+    $rank++;
+  }
 
   // Fetch users with more invites.
   $i = 0;
Index: invite_token.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/invite/invite_token.inc,v
retrieving revision 1.1.2.1.2.3
diff -u -p -r1.1.2.1.2.3 invite_token.inc
--- invite_token.inc	10 Jul 2008 10:28:44 -0000	1.1.2.1.2.3
+++ invite_token.inc	18 Aug 2008 14:46:51 -0000
@@ -12,7 +12,7 @@ function invite_token_values($type = 'al
     $values['invite-mail']        = $object->email;
     $values['invite-message']     = check_plain($object->data['message']);
     $values['invite-message-raw'] = $object->data['message'];
-    $values['join-link']          = url('invite/accept/'. $object->code, NULL, NULL, TRUE);
+    $values['join-link']          = url('invite/accept/'. $object->code, array('absolute' => TRUE));
   }
   return $values;
 }
@@ -52,11 +52,11 @@ function theme_invite_token_help($type =
   foreach ((array)$type as $t) {
     $full_list = array_merge($full_list, token_get_list($t));
   }
-  
+
   $headers = array(t('Token'), t('Replacement value'));
   $rows = array();
   foreach ($full_list as $key => $category) {
-    $rows[] = array(array('data' => drupal_ucfirst($key) . ' ' . t('tokens'), 'class' => 'region', 'colspan' => 2));
+    $rows[] = array(array('data' => drupal_ucfirst($key) .' '. t('tokens'), 'class' => 'region', 'colspan' => 2));
     foreach ($category as $token => $description) {
       $row = array();
       $row[] = $prefix . $token . $suffix;
