? allowreselect.patch
Index: user_selectable_roles.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/user_selectable_roles/user_selectable_roles.install,v
retrieving revision 1.1
diff -u -p -r1.1 user_selectable_roles.install
--- user_selectable_roles.install	19 Oct 2008 04:25:08 -0000	1.1
+++ user_selectable_roles.install	2 Dec 2009 19:27:17 -0000
@@ -16,4 +16,5 @@ function user_selectable_roles_uninstall
   variable_del('user_selectable_roles_label');
   variable_del('user_selectable_roles_mode');
   variable_del('user_selectable_roles_required');
+  variable_del('user_selectable_roles_allowreselect');
 }
Index: user_selectable_roles.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/user_selectable_roles/user_selectable_roles.module,v
retrieving revision 1.1
diff -u -p -r1.1 user_selectable_roles.module
--- user_selectable_roles.module	19 Oct 2008 04:25:08 -0000	1.1
+++ user_selectable_roles.module	2 Dec 2009 19:27:17 -0000
@@ -99,6 +99,12 @@ function user_selectable_roles_admin_for
     '#default_value' => variable_get('user_selectable_roles_required', 0),
     '#description' => t('Check if user is required to select at least one role.'),
   );
+  $form['user_selectable_roles_allowreselect'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('User can select roles more than once'),
+    '#default_value' => variable_get('user_selectable_roles_allowreselect', 1),
+    '#description' => t('Select whether the user can select roles more than once.'),
+  );
 
   return system_settings_form($form);
 }
@@ -150,6 +156,12 @@ function user_selectable_roles_user($op,
         user_selectable_roles_save($user_selectable_roles, $edit, $user);
         break;
       case 'form':
+        if (!variable_get('user_selectable_roles_allowreselect', 1)) {
+          if (count($user->roles) != count(array_diff($user->roles, $user_selectable_roles))) {
+            // User has already selected role(s), and is not allowed to reselect.
+            return;
+          }
+        }
         $user_roles = $user->roles;
         // remove anonymous and authenticated roles
         unset($user_roles[DRUPAL_ANONYMOUS_RID]);
@@ -246,6 +258,13 @@ function user_selectable_roles_validatio
  *
  */
 function user_selectable_roles_save($user_selectable_roles, $edit, $user) {
+  if (!variable_get('user_selectable_roles_allow_reselect', 1)) {
+    if (count($user->roles) != count(array_diff($user->roles, $user_selectable_roles))) {
+      // User has already selected role(s), and is not allowed to reselect.
+      return;
+    }
+  }
+
   // delete existing user-selected roles (if any)
   foreach ($user_selectable_roles as $rid => $name) {
     db_query("DELETE FROM {users_roles} WHERE uid = %d AND rid = %d", $user->uid, $rid);
@@ -263,4 +282,4 @@ function user_selectable_roles_save($use
     // single selection dropdown
     db_query("INSERT INTO {users_roles} (uid, rid) VALUES (%d, %d)", $user->uid, $edit['user_selectable_roles']);
   }
-}
\ No newline at end of file
+}
