Index: CHANGELOG.txt =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/autoassignrole/CHANGELOG.txt,v retrieving revision 1.4 diff -u -p -r1.4 CHANGELOG.txt --- CHANGELOG.txt 18 Oct 2010 23:26:15 -0000 1.4 +++ CHANGELOG.txt 18 Oct 2010 23:40:55 -0000 @@ -7,3 +7,4 @@ autoassignrole 7.0, xxxx-xx-xx (developm admin created accounts - [#937678] Use Case - Administrator sets roles for automatic assignment - [#944880] Administrator toggles allowing user to select role +- [#944922] Administrator sets roles that will be visible to the end user Index: autoassignrole.admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/autoassignrole/autoassignrole.admin.inc,v retrieving revision 1.3 diff -u -p -r1.3 autoassignrole.admin.inc --- autoassignrole.admin.inc 18 Oct 2010 23:26:15 -0000 1.3 +++ autoassignrole.admin.inc 18 Oct 2010 23:40:55 -0000 @@ -92,5 +92,20 @@ function autoassignrole_user_settings() '#options' => array(1 => t('Enabled'), 0 => t('Disabled')), ); + // We can disregard the authenticated user role since it is assigned to each + // user by Drupal. + $roles = user_roles(TRUE); + unset($roles[DRUPAL_AUTHENTICATED_RID]); + + if ($roles) { + $form['autoassignrole_user_roles'] = array( + '#type' => 'checkboxes', + '#title' => t('Roles'), + '#default_value' => variable_get('autoassignrole_user_roles', array()), + '#description' => t('Check the specific roles the user will have the option of choosing. The Authenticated User role is automatically assigned by Drupal core and can not be edited.'), + '#options' => $roles, + ); + } + return system_settings_form($form); } Index: autoassignrole.test =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/autoassignrole/autoassignrole.test,v retrieving revision 1.4 diff -u -p -r1.4 autoassignrole.test --- autoassignrole.test 18 Oct 2010 23:26:15 -0000 1.4 +++ autoassignrole.test 18 Oct 2010 23:40:55 -0000 @@ -206,4 +206,40 @@ class AutoassignroleAdminSettingsTestCas 'autoassignrole_user_active has been disabled' ); } + + /** + * Test admin setting functionality for autoassignrole_user_roles. + * @see http://drupal.org/node/944922 + */ + function testAdminUserRolesSettings() { + // Create a new user who can access the administration settings + $this->drupalLogin($this->admin_user); + + // Check that the user can see the admin settings page. + $this->drupalGet('admin/config/autoassignrole/user'); + + // Verify that there are roles exposed. + $this->assertField( + 'autoassignrole_user_roles[3]', + 'Looking for the autoassignrole_user_roles checkboxes.' + ); + + // Verify that a checkbox for each of our valid roles shows on the page. + foreach ($this->roles as $rid => $role) { + $edit["autoassignrole_user_roles[$rid]"] = $rid; + } + + // Check each of our roles and submit the form. + $this->drupalPost( + 'admin/config/autoassignrole/user', + $edit, + t('Save configuration') + ); + + // Verify the checked value was saved for each of our roles. + $roles = variable_get("autoassignrole_user_roles", array()); + foreach ($this->roles as $rid => $role) { + $this->assertEqual(TRUE, array_key_exists($rid, $roles), 'Verifying that role (rid:' . $rid . ') was activated.'); + } + } }