--- rolesignup.module.ori Sat Jan 20 16:49:48 2007 +++ rolesignup.module Thu Nov 01 13:18:26 2007 @@ -15,6 +15,17 @@ function rolesignup_menu($may_cache) { 'title' => t('Register'), 'type' => MENU_LOCAL_TASK); + if ($may_cache) { + $items[] = array( + 'path' => 'admin/settings/rolesignup', + 'title' => t('Role Signup'), + 'description' => t('Add descriptions to the user roles, for display on the role select page.'), + 'callback' => 'drupal_get_form', + 'callback arguments' => array('rolesignup_admin_settings'), + 'access' => user_access('administer site configuration'), + ); + } + return $items; } @@ -73,9 +84,27 @@ function rolesignup_user($op, &$edit, &$ function theme_rolelist($roles) { $output = t("

Please select what type of account you would like

"); $output .= "\n"; return $output; @@ -91,3 +120,65 @@ function theme_select_role() { return $output; } +/** + * Implementation of hook_admin_settings() + */ +function rolesignup_admin_settings() { + $roles = user_roles(); + drupal_set_title(t('Role descriptions')); + $form['rolesignup-intro'] = array( + '#value' => t('You may enter a description for each of the available roles. The description will be displayed on the role selection page. You can leave the description blank if you want to.'), + '#weight' => -4, + ); + + foreach ($roles as $roleid => $role) { + + $form['rolesignup'. role_safe($role) .'-fs'] = array( + '#type' => 'fieldset', + '#title' => $role, + '#collapsible' => TRUE, + '#collapsed' => TRUE, + '#weight' => -2, + ); + $form['rolesignup'. role_safe($role) .'-fs'][role_safe($role) .'-title'] = array( + '#type' => 'textfield', + '#title' => t('Enter the title you want displayed for the !rolename role', array('!rolename' => $role)), + '#size' => 60, + '#maxlength' => 128, + '#attributes' => array( + 'class' => 'role-title', + ), + '#default_value' => variable_get(role_safe($role) .'-title', ''), + ); + $form['rolesignup'. role_safe($role) .'-fs'][role_safe($role) .'-description'] = array( + '#type' => 'textarea', + '#title' => t('Enter description for the %rolename role', array('%rolename' => $role)), + '#attributes' => array( + 'class' => 'role-description', + ), + '#default_value' => variable_get(role_safe($role) .'-description', ''), + ); + $form['rolesignup-sort'] = array( + '#type' => 'radios', + '#title' => t('Choose the sort order of the roles'), + '#options' => array( + '0' => t('None'), + '1' => t('Ascending role ID numbers (1, 2, 3)'), + '2' => t('Descending role ID numbers (3, 2, 1)'), + '3' => t('Alphabetical (A-Z)'), + '4' => t('Reverse alphabetical (Z-A)'), + ), + '#default_value' => variable_get('rolesignup-sort', ''), + '#weight' => -1, + ); + } + return system_settings_form($form); +} + +/** + * Replaces spaces with underscores for role names + **/ +function role_safe($role) { + $role_safe = str_replace(' ', '_', $role); + return $role_safe; +}