Index: imap_auth.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imap_auth/imap_auth.module,v
retrieving revision 1.5
diff -u -p -r1.5 imap_auth.module
--- imap_auth.module	3 Sep 2007 04:04:55 -0000	1.5
+++ imap_auth.module	17 Jan 2008 20:10:12 -0000
@@ -130,6 +130,17 @@ function imap_auth_auth($username, $pass
   return $login;
 }
 
+function imap_auth_user($op, &$edit, &$account, $category = NULL) {
+  $roles = variable_get('imap_auth_roles', array());
+  if ($op == 'insert' && $edit['authname_imap_auth'] && !empty($roles)) {
+    foreach ($roles as $rid => $value) {
+      if ($value) {
+        $edit['roles'][$rid] = TRUE;
+      }
+    }
+  }
+}
+
 /**
  * Implementation of hook_info().
  */
@@ -168,7 +179,16 @@ function imap_auth_admin_settings() {
     '#description' =>  t('Valid servers to authenticate from. Use asterisk(*) as wildcard for any server, or restrict to some servers adding one service per row in the form <em>server_alias,string_mailbox</em>. See !readme for detailed instructions.<br />Example: <em>mycompany.com,{mail.mycompany.com:143/imap/notls}INBOX</em>',
                          array('!readme' => l('README.txt', 'http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/imap_auth/README.txt?view=markup', array('target' => '_blank')))),
   );
-
+  $roles = user_roles(1);
+  unset($roles[DRUPAL_AUTHENTICATED_RID]);
+  if ($roles) {
+    $form['imap_auth_roles'] = array(
+      '#type' => 'checkboxes',
+      '#title' => t('Roles'),
+      '#default_value' => variable_get('imap_auth_roles', array()),
+      '#options' => $roles,
+      '#description' => t('Users logging for the first time through IMAP auth receive the combined permissions of the %au role, and all roles selected here.', array('%au' => t('authenticated user'))));
+  }
   return system_settings_form($form);
 }
 
