? allowreselect.patch Index: user_selectable_roles.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/user_selectable_roles/user_selectable_roles.module,v retrieving revision 1.1.4.6 diff -u -p -r1.1.4.6 user_selectable_roles.module --- user_selectable_roles.module 2 Sep 2009 23:34:45 -0000 1.1.4.6 +++ user_selectable_roles.module 22 Sep 2009 20:11:22 -0000 @@ -98,6 +98,12 @@ function user_selectable_roles_admin_for '#default_value' => variable_get('user_selectable_roles_editing', 0), '#options' => $options, ); + $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; if checked in combination with the "Registration and user account forms" option above, the user will be able to switch between roles at will, which could be a security risk in some setups.'), + ); return system_settings_form($form); } @@ -156,6 +162,16 @@ function user_selectable_roles_user($op, } // fall through to insert case case 'insert': + if (!variable_get('user_selectable_roles_allowreselect', 1)) { + if (count($account->roles) != count(array_diff($account->roles, $user_selectable_roles))) { + return; + } + } // multiple choice checkboxes if (is_array($edit['user_selectable_roles'])) { $roles = array_filter($edit['user_selectable_roles']); @@ -176,6 +192,16 @@ function user_selectable_roles_user($op, break; case 'form': if (!isset($account->uid) || variable_get('user_selectable_roles_editing', 0)) { + if (!variable_get('user_selectable_roles_allowreselect', 1)) { + if (count($account->roles) != count(array_diff($account->roles, $user_selectable_roles))) { + return; + } + } $user_roles = $account->roles; // remove anonymous and authenticated roles unset($user_roles[DRUPAL_ANONYMOUS_RID]); @@ -271,4 +297,4 @@ function user_selectable_roles_validatio form_set_error('user_selectable_roles][user_selectable_roles', t('You must select one !label.', array('!label' => format_plural(variable_get('user_selectable_roles_mode', 0), $user_selectable_roles_label[1], $user_selectable_roles_label[0])))); } } -} \ No newline at end of file +}