--- ../roledelay/roledelay.module	2006-07-26 09:36:09.000000000 -0700
+++ roledelay.module	2007-01-19 09:43:28.000000000 -0800
@@ -74,6 +74,21 @@ function roledelay_settings() {
     '#options' => $increments,
     '#description' => t('The number to increment the wait period type by.')
     );
+   
+  //  Integration option with logintoboggan, if it is enabled 
+    if (module_exist('logintoboggan')) {
+      $form['other'] = array(
+        '#type' => 'fieldset',
+        '#title' => 'Other',
+      );
+      $form['other']['logintoboggan_trigger'] = array(
+        '#type' => 'radios',
+        '#title' => t('Start roledelay timer when logintoboggan verifies user'),
+        '#default_value' => variable_get('logintoboggan_trigger', 0),
+        '#options' => array(t('disabled'), t('enabled')),
+        '#description' => t("If you're using logintoboggan to let a newly registrated user login immediately with a non-authenticated role, you may want to enable this option.  Otherwise, users could achieve delayed roles without ever verifying via logintoboggan. This may help prevent spambots from infiltrating the site."),
+        );
+    }
 
   return $form;
 }
@@ -83,7 +98,7 @@ function roledelay_settings() {
  * hook_user() implementation
  */
 function roledelay_user($op, &$edit, &$user, $category = NULL) {
-  if($op == 'insert' && (variable_get('roledelay_role1', 'none') != 'none')) {
+  if($op == 'insert' && (variable_get('roledelay_role1', 'none') != 'none') && (variable_get('logintoboggan_trigger', 0) == 0)) {
     // calculate the timestamp when the stage will be reached
     $wait = $user->created + ((variable_get('roledelay_increment1', '1')+1) * variable_get('roledelay_period1', '3600'));
     db_query("INSERT INTO {roledelay1} (uid, waitstamp) VALUES (%d, %d)", $user->uid, $wait);
@@ -95,6 +110,21 @@ function roledelay_user($op, &$edit, &$u
 }
 
 /**
+ * hook_logintoboggan() implementation
+ */
+function roledelay_logintoboggan($op, &$user) {
+  if($op == 'update' && (variable_get('roledelay_role1', 'none') != 'none') && (variable_get('logintoboggan_trigger', 0) == 1)) {
+    // calculate the timestamp when the stage will be reached
+    $wait = time() + ((variable_get('roledelay_increment1', '1')+1) * variable_get('roledelay_period1', '3600'));
+    db_query("INSERT INTO {roledelay1} (uid, waitstamp) VALUES (%d, %d)", $user->uid, $wait);
+    if(variable_get('roledelay_role2', 'none') != 'none') {
+      $wait = time() + ((variable_get('roledelay_increment2', '1')+1) * variable_get('roledelay_period2', '3600'));
+      db_query("INSERT INTO {roledelay2} (uid, waitstamp) VALUES (%d, %d)", $user->uid, $wait);
+    }
+  }
+}
+
+/**
  * hook_cron() implementation
  */
 function roledelay_cron() {
