Index: role_weights.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/role_weights/role_weights.module,v retrieving revision 1.23.2.2 diff -u -r1.23.2.2 role_weights.module --- role_weights.module 8 Jun 2009 12:36:17 -0000 1.23.2.2 +++ role_weights.module 8 Jun 2009 16:05:05 -0000 @@ -7,6 +7,37 @@ */ /** + * Implementation of hook_help(). + */ +function role_weights_help($path, $arg) { + switch ($path) { + case 'admin/help#role_weights': + $output = '

'. t('Role Weights is a small utility module to allow site admins to specify weights for user roles. Once installed, users with administer users permission can set weights for roles on the Roles configuration page.', array('@roles' => url('admin/user/roles'))) .'

'; + $output .= '

'. t('Admins can optionally enable sorting roles by weight on the Roles and Permissions configuration pages on the Role Weights configuration page.', array('@roles' => url('admin/user/roles'), '@permissions' => url('admin/user/permissions'), '@roleweights' => url('admin/settings/role_weights'))) .'

'; + $output .= '

'. t('For more information visit Role Weights module page on drupal.org.') .'

'; + return $output; + + case 'admin/settings/role_weights': + return t('

Configure how Role Weights affects the sorting of various core configuration pages. To set role weights, edit the relevant role on the Roles configuration page.

', array('@roles' => url('admin/user/roles'))); + } +} + +/** + * Implementation of hook_menu(). + */ +function role_weights_menu() { + $items['admin/settings/role_weights'] = array( + 'title' => 'Role Weights', + 'description' => "Enable sorting roles by weight on the Roles and Permissions configuration pages.", + 'page callback' => 'drupal_get_form', + 'page arguments' => array('role_weights_settings_form'), + 'access arguments' => array('administer users'), + 'type' => MENU_NORMAL_ITEM, + ); + return $items; +} + +/** * Implementation of hook_theme(). */ function role_weights_theme($existing, $type, $theme, $path) { @@ -18,6 +49,23 @@ } /** + * Form callback for the admin settings form. + */ +function role_weights_settings_form() { + $form = array(); + + $form['role_weights_reorder_forms'] = array( + '#type' => 'checkbox', + '#title' => t('Enable sort by role weights'), + '#default_value' => variable_get('role_weights_reorder_forms', FALSE), + '#description' => t('Enable sorting roles by weight on the Roles (admin/user/roles) and Permissions (admin/user/permissions) pages. Please note that this setting will override Drupal\'s default alphabetical sorting: if enabled and role weights are not set (or are equal), sorting will be less than satisfactory. There is an issue open for this on drupal.org'), + ); + + return system_settings_form($form); +} + + +/** * Implementation of hook_form_alter(). * * User.module's role handling is not fully Forms API