| 1 |
<?php |
<?php |
| 2 |
// $Id: role_weights.module,v 1.23.2.3 2009/06/09 16:03:15 leafishpaul Exp $ |
// $Id: role_weights.module,v 1.26 2009/06/09 16:05:26 leafishpaul Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 7 |
*/ |
*/ |
| 8 |
|
|
| 9 |
/** |
/** |
| 10 |
|
* Implementation of hook_help(). |
| 11 |
|
*/ |
| 12 |
|
function role_weights_help($path, $arg) { |
| 13 |
|
switch ($path) { |
| 14 |
|
case 'admin/help#role_weights': |
| 15 |
|
$output = '<p>'. t('Role Weights is a small utility module to allow site admins to specify weights for user roles. Once installed, users with <em>administer users</em> permission can set weights for roles on the <a href="@roles">Roles configuration page</a>.', array('@roles' => url('admin/user/roles'))) .'</p>'; |
| 16 |
|
$output .= '<p>'. t('Admins can optionally enable sorting roles by weight on the <a href="@roles">Roles</a> and <a href="@permissions">Permissions</a> configuration pages on the <a href="@roleweights">Role Weights configuration page</a>.', array('@roles' => url('admin/user/roles'), '@permissions' => url('admin/user/permissions'), '@roleweights' => url('admin/settings/role_weights'))) .'</p>'; |
| 17 |
|
$output .= '<p>'. t('For more information visit <a href="http://drupal.org/project/role_weights">Role Weights module page on drupal.org</a>.') .'</p>'; |
| 18 |
|
return $output; |
| 19 |
|
|
| 20 |
|
case 'admin/settings/role_weights': |
| 21 |
|
return t('<p>Configure how Role Weights affects the sorting of various core configuration pages. To set role weights, edit the relevant role on the <a href="@roles">Roles configuration page</a>.</p>', array('@roles' => url('admin/user/roles'))); |
| 22 |
|
} |
| 23 |
|
} |
| 24 |
|
|
| 25 |
|
/** |
| 26 |
|
* Implementation of hook_menu(). |
| 27 |
|
*/ |
| 28 |
|
function role_weights_menu() { |
| 29 |
|
$items['admin/settings/role_weights'] = array( |
| 30 |
|
'title' => 'Role Weights', |
| 31 |
|
'description' => "Enable sorting roles by weight on the Roles and Permissions configuration pages.", |
| 32 |
|
'page callback' => 'drupal_get_form', |
| 33 |
|
'page arguments' => array('role_weights_settings_form'), |
| 34 |
|
'access arguments' => array('administer users'), |
| 35 |
|
'type' => MENU_NORMAL_ITEM, |
| 36 |
|
); |
| 37 |
|
return $items; |
| 38 |
|
} |
| 39 |
|
|
| 40 |
|
/** |
| 41 |
* Implementation of hook_theme(). |
* Implementation of hook_theme(). |
| 42 |
*/ |
*/ |
| 43 |
function role_weights_theme($existing, $type, $theme, $path) { |
function role_weights_theme($existing, $type, $theme, $path) { |
| 49 |
} |
} |
| 50 |
|
|
| 51 |
/** |
/** |
| 52 |
|
* Form callback for the admin settings form. |
| 53 |
|
*/ |
| 54 |
|
function role_weights_settings_form() { |
| 55 |
|
$form = array(); |
| 56 |
|
|
| 57 |
|
$form['role_weights_reorder_forms'] = array( |
| 58 |
|
'#type' => 'checkbox', |
| 59 |
|
'#title' => t('Enable sort by role weights'), |
| 60 |
|
'#default_value' => variable_get('role_weights_reorder_forms', FALSE), |
| 61 |
|
'#description' => t('Enable sorting roles by weight on the Roles (admin/user/roles) and Permissions (admin/user/permissions) pages. <em>Please note that this setting will override Drupal\'s default alphabetical sorting: if enabled and role weights are <strong>not</strong> set (or are equal), sorting will be less than satisfactory. There is an <a href="http://drupal.org/node/368088">issue open for this on drupal.org</a></em>'), |
| 62 |
|
); |
| 63 |
|
|
| 64 |
|
return system_settings_form($form); |
| 65 |
|
} |
| 66 |
|
|
| 67 |
|
/** |
| 68 |
* Implementation of hook_form_alter(). |
* Implementation of hook_form_alter(). |
| 69 |
* |
* |
| 70 |
* User.module's role handling is not fully Forms API |
* User.module's role handling is not fully Forms API |