--- role_weights.module.ORIGINAL 2009-05-21 09:08:27.000000000 +0200
+++ role_weights.module 2009-05-21 14:49:29.000000000 +0200
@@ -7,6 +7,51 @@
*/
/**
+ * Implementation of hook_help().
+ * @return
+ * Help text for section.
+ */
+function role_weights_help($path, $arg) {
+ if ($path == 'admin/help#role_weights') {
+ $txt = 'A small utility module to allow site admins to specify certain weights for user roles. Its not much use on its own, more of a helper module for other modules which require this functionality.
+Installation
+========================================
+1. Upload the role_weights directory to your modules directory.
+2. Enable the module under Administer -> Site building -> Modules.
+3. Visit Administer -> User management -> Roles and choose the \'edit\' link next to a role to change a role\'s weight.
+Advanced settings
+========================================
+Once installed, site admins can enable sorting roles by weight on the Roles configuration
+(/admin/user/roles) and Access Control (/admin/user/pages/access) pages selecting a checkbox on Administer -> User management -> Role Weights.
+Caveat: currently this setting will override Drupal\'s default sorting (alphabetical). So,
+if this variable is set and a roles all have equal weight then the sorting will be less
+than satisfactory. There is an issue for this published here.
+Notes
+========================================
+CAUTION! Do NOT allow lower-level roles to edit role weights if another module is relying
+on it to control any higher-level stuff like access permissions, site settings and development modules. I wouldn\'t really advise this in the first place - this module is intended for simple selection of roles based on weights for use in, for example, theming usernames & profiles or choosing the \'highest\' from multiple roles.
+For more information, visit: Role Weights module page on Drupal site.
';
+ return '
'. t($txt) .'
'; + } +} + +/** + * Implementation of hook_menu(). + */ +function role_weights_menu() { + $items['admin/user/role_weights'] = array( + 'title' => 'Role Weights', + 'description' => "Enable sorting roles by weight on the Roles configuration +(/admin/user/roles) and Access Control (/admin/user/pages/access) 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) { @@ -320,3 +365,21 @@ function role_weights_token_list($type = return $tokens; } } + +/** + * 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 configuration +(/admin/user/roles) and Access Control (/admin/user/pages/access) pages.') + ); + +// return $form; + return system_settings_form($form); +}