Index: CHANGELOG.txt =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/autoassignrole/CHANGELOG.txt,v retrieving revision 1.2 diff -u -p -r1.2 CHANGELOG.txt --- CHANGELOG.txt 10 Oct 2010 21:35:33 -0000 1.2 +++ CHANGELOG.txt 18 Oct 2010 03:54:01 -0000 @@ -1,7 +1,8 @@ -// $Id +/* $Id$ */ autoassignrole 7.0, xxxx-xx-xx (development version) ------------------------ - [#937468] Use Case - Administrator enables/disables automatic assignment - [#937666] Use Case - Administrator enables/disables automatic assignment of admin created accounts +- [#937678] Use Case - Administrator sets roles for automatic assignment Index: README.txt =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/autoassignrole/README.txt,v retrieving revision 1.5 diff -u -p -r1.5 README.txt --- README.txt 10 Oct 2010 21:03:35 -0000 1.5 +++ README.txt 18 Oct 2010 03:54:01 -0000 @@ -1,4 +1,4 @@ -; $Id $ +/* $Id$ */ Auto Assign Role ================================================================================ Index: autoassignrole.admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/autoassignrole/autoassignrole.admin.inc,v retrieving revision 1.1 diff -u -p -r1.1 autoassignrole.admin.inc --- autoassignrole.admin.inc 10 Oct 2010 21:35:33 -0000 1.1 +++ autoassignrole.admin.inc 18 Oct 2010 03:54:01 -0000 @@ -45,6 +45,7 @@ function autoassignrole_auto_settings() Enabled to allow this functionality or Disabled to not allow.'), '#options' => array(1 => t('Enabled'), 0 => t('Disabled')), ); + $form['autoassignrole_admin_active'] = array( '#type' => 'radios', '#title' => t('Automatic role assignment for admin created accounts'), @@ -54,5 +55,24 @@ function autoassignrole_auto_settings() Enabled to allow this functionality or Disabled to not allow.'), '#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_auto_roles'] = array( + '#type' => 'checkboxes', + '#title' => t('Roles'), + '#default_value' => variable_get('autoassignrole_auto_roles', array()), + '#description' => t('Check the specific Roles the user will automatically + be assigned to when created by an administrator or through the new user + registration process. 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.2 diff -u -p -r1.2 autoassignrole.test --- autoassignrole.test 10 Oct 2010 21:35:33 -0000 1.2 +++ autoassignrole.test 18 Oct 2010 03:54:01 -0000 @@ -26,6 +26,11 @@ class AutoassignroleAdminSettingsTestCas 'administer autoassignrole', 'access administration pages', )); + $permissions = array('access content'); + $this->drupalCreateRole($permissions); + + $this->roles = user_roles(TRUE); + unset($this->roles[DRUPAL_AUTHENTICATED_RID]); } /** @@ -119,4 +124,40 @@ class AutoassignroleAdminSettingsTestCas 'autoassignrole_admin_active has been disabled' ); } + + /** + * Test admin setting functionality for autoassignrole_auto_roles. + * @see http://drupal.org/node/937678 + */ + function testAutoRolesSettings() { + // 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/auto'); + + // Verify that there are roles exposed. + $this->assertField( + 'autoassignrole_auto_roles[3]', + 'Looking for the autoassignrole_auto_roles checkboxes.' + ); + + // Verify that a checkbox for each of our valid roles shows on the page. + foreach ($this->roles as $rid => $role) { + $edit["autoassignrole_auto_roles[$rid]"] = $rid; + } + + // Check each of our roles and submit the form. + $this->drupalPost( + 'admin/config/autoassignrole/auto', + $edit, + t('Save configuration') + ); + + // Verify the checked value was saved for each of our roles. + $roles = variable_get("autoassignrole_auto_roles", array()); + foreach ($this->roles as $rid => $role) { + $this->assertEqual(TRUE, array_key_exists($rid, $roles), 'Verifying that role (rid:' . $rid . ') was activated.'); + } + } }