Index: modules/user/user.module =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.module,v retrieving revision 1.745 diff -u -p -r1.745 user.module --- modules/user/user.module 11 Jan 2007 08:52:45 -0000 1.745 +++ modules/user/user.module 15 Jan 2007 23:56:49 -0000 @@ -10,6 +10,15 @@ define('USERNAME_MAX_LENGTH', 60); define('EMAIL_MAX_LENGTH', 64); /** + * Default value for user_sort_access_perms variable + * + * A return value of TRUE implements the historical behavior: A module's + * access permissions are sorted alphabetically on the admin/user/access + * page and in user_filter(). + */ +define('USER_DEFAULT_PERMSORT', TRUE); + +/** * Invokes hook_user() in every module. * * We cannot use module_invoke() for this, because the arguments need to @@ -1805,7 +1814,9 @@ function user_admin_perm($rid = NULL) { $form['permission'][] = array( '#value' => $module, ); - asort($permissions); + if (variable_get('user_sort_access_perms', USER_DEFAULT_PERMSORT) ) { + asort($permissions); + } foreach ($permissions as $perm) { $options[$perm] = ''; $form['permission'][$perm] = array('#value' => t($perm)); @@ -2283,13 +2294,13 @@ function user_multiple_delete_confirm_su function user_admin_settings() { // User registration settings. - $form['registration'] = array('#type' => 'fieldset', '#title' => t('User registration settings')); + $form['registration'] = array('#type' => 'fieldset', '#title' => t('User registration settings'), '#collapsible' => TRUE, '#collapsed' => FALSE); $form['registration']['user_register'] = array('#type' => 'radios', '#title' => t('Public registrations'), '#default_value' => variable_get('user_register', 1), '#options' => array(t('Only site administrators can create new user accounts.'), t('Visitors can create accounts and no administrator approval is required.'), t('Visitors can create accounts but administrator approval is required.'))); $form['registration']['user_email_verification'] = array('#type' => 'checkbox', '#title' => t('Require e-mail verification when a visitor creates an account'), '#default_value' => variable_get('user_email_verification', TRUE), '#description' => t('If this box is checked, new users will be required to validate their e-mail address prior to logging into to the site, and will be assigned a system-generated password. With it unchecked, users will be logged in immediately upon registering, and may select their own passwords during registration.')); $form['registration']['user_registration_help'] = array('#type' => 'textarea', '#title' => t('User registration guidelines'), '#default_value' => variable_get('user_registration_help', ''), '#description' => t("This text is displayed at the top of the user registration form. It's useful for helping or instructing your users.")); // User e-mail settings. - $form['email'] = array('#type' => 'fieldset', '#title' => t('User e-mail settings')); + $form['email'] = array('#type' => 'fieldset', '#title' => t('User e-mail settings'),'#collapsible' => TRUE, '#collapsed' => TRUE); $form['email']['user_mail_welcome_subject'] = array('#type' => 'textfield', '#title' => t('Subject of welcome e-mail'), '#default_value' => _user_mail_text('welcome_subject'), '#maxlength' => 180, '#description' => t('Customize the subject of your welcome e-mail, which is sent to new members upon registering.') .' '. t('Available variables are:') .' !username, !site, !password, !uri, !uri_brief, !mailto, !date, !login_uri, !edit_uri, !login_url.'); $form['email']['user_mail_welcome_body'] = array('#type' => 'textarea', '#title' => t('Body of welcome e-mail'), '#default_value' => _user_mail_text('welcome_body'), '#rows' => 15, '#description' => t('Customize the body of the welcome e-mail, which is sent to new members upon registering.') .' '. t('Available variables are:') .' !username, !site, !password, !uri, !uri_brief, !mailto, !login_uri, !edit_uri, !login_url.'); $form['email']['user_mail_admin_subject'] = array('#type' => 'textfield', '#title' => t('Subject of welcome e-mail (user created by administrator)'), '#default_value' => _user_mail_text('admin_subject'), '#maxlength' => 180, '#description' => t('Customize the subject of your welcome e-mail, which is sent to new member accounts created by an administrator.') .' '. t('Available variables are:') .' !username, !site, !password, !uri, !uri_brief, !mailto, !date, !login_uri, !edit_uri, !login_url.'); @@ -2305,7 +2316,7 @@ function user_admin_settings() { file_check_directory($picture_path, 1, 'user_picture_path'); } - $form['pictures'] = array('#type' => 'fieldset', '#title' => t('Pictures')); + $form['pictures'] = array('#type' => 'fieldset', '#title' => t('Pictures'),'#collapsible' => TRUE, '#collapsed' => TRUE); $form['pictures']['user_pictures'] = array('#type' => 'radios', '#title' => t('Picture support'), '#default_value' => variable_get('user_pictures', 0), '#options' => array(t('Disabled'), t('Enabled')), '#description' => t('Enable picture support.')); $form['pictures']['user_picture_path'] = array('#type' => 'textfield', '#title' => t('Picture image path'), '#default_value' => variable_get('user_picture_path', 'pictures'), '#size' => 30, '#maxlength' => 255, '#description' => t('Subdirectory in the directory %dir where pictures will be stored.', array('%dir' => file_directory_path() .'/'))); $form['pictures']['user_picture_default'] = array('#type' => 'textfield', '#title' => t('Default picture'), '#default_value' => variable_get('user_picture_default', ''), '#size' => 30, '#maxlength' => 255, '#description' => t('URL of picture to display for users with no custom picture selected. Leave blank for none.')); @@ -2313,6 +2324,22 @@ function user_admin_settings() { $form['pictures']['user_picture_file_size'] = array('#type' => 'textfield', '#title' => t('Picture maximum file size'), '#default_value' => variable_get('user_picture_file_size', '30'), '#size' => 15, '#maxlength' => 10, '#description' => t('Maximum file size for pictures, in kB.')); $form['pictures']['user_picture_guidelines'] = array('#type' => 'textarea', '#title' => t('Picture guidelines'), '#default_value' => variable_get('user_picture_guidelines', ''), '#description' => t("This text is displayed at the picture upload form in addition to the default guidelines. It's useful for helping or instructing your users.")); + // Access-control sorting settings + $form['access_sorting']= array( + '#type' => 'fieldset', + '#title' => t('Access permissions sorting'), + '#collapsible' => TRUE, + '#collapsed' + => !!variable_get('user_sort_access_perms', USER_DEFAULT_PERMSORT), + ); + $form['access_sorting']['user_sort_access_perms'] = array( + '#type' => 'checkbox', + '#title' => t('Sort access control permissions'), + '#return_value' => 1, + '#default_value' + => variable_get('user_sort_access_perms', USER_DEFAULT_PERMSORT), + '#description' => t('If checked, permissions for each module will be sorted alphabetically on the ') . l(t('Access control page'),'admin/user/access') . ' ' . t('and in the') . ' ' . l(t('user selection filters'), 'admin/user/user') . ".",); + return system_settings_form($form); } @@ -2369,6 +2396,8 @@ function user_help($section) { ', array('@permissions' => url('admin/user/access'))); case 'admin/user/search': return '
'. t('Enter a simple pattern ("*" may be used as a wildcard match) to search for a username. For example, one may search for "br" and Drupal might return "brian", "brad", and "brenda".') .'
'; + case 'admin/user/settings': + return '' . t('Change lots o\' settings here.') . '
'; case 'user/help#user': $site = variable_get('site_name', 'Drupal'); @@ -2474,7 +2503,9 @@ function user_filters() { $t_module = t('module'); foreach (module_list() as $module) { if ($permissions = module_invoke($module, 'perm')) { - asort($permissions); + if (variable_get('user_sort_access_perms', USER_DEFAULT_PERMSORT) ) { + asort($permissions); + } foreach ($permissions as $permission) { $options["$module $t_module"][$permission] = t($permission); } @@ -2652,4 +2683,3 @@ function user_forms() { $forms['user_admin_new_role']['callback'] = 'user_admin_role'; return $forms; } -