| 1 |
<?php |
<?php |
| 2 |
// $Id: role_weights.module,v 1.12.2.11 2009/06/08 12:35:57 leafishpaul Exp $ |
// $Id: role_weights.module,v 1.12.2.12 2009/06/08 12:44:02 leafishpaul Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 6 |
* Allows users to specify weights for user roles. |
* Allows users to specify weights for user roles. |
| 7 |
*/ |
*/ |
| 8 |
|
|
| 9 |
|
/** |
| 10 |
|
* Implementation of hook_help(). |
| 11 |
|
*/ |
| 12 |
|
function role_weights_help($path) { |
| 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 <a href="@roles">Roles</a> and <a href="@permissions">Access Control</a> by visiting the <a href="@roleweights">Role Weights configuration page</a>.', array('@roles' => url('admin/user/roles'), '@permissions' => url('admin/user/access'), '@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($may_cache) { |
| 29 |
|
if ($may_cache) { |
| 30 |
|
$items[] = array( |
| 31 |
|
'path' => 'admin/settings/role_weights', |
| 32 |
|
'title' => t('Role Weights'), |
| 33 |
|
'description' => t("Enable sorting roles by weight on the Roles and Permissions configuration pages."), |
| 34 |
|
'callback' => 'drupal_get_form', |
| 35 |
|
'callback arguments' => array('role_weights_settings_form'), |
| 36 |
|
'access' => user_access('administer users'), |
| 37 |
|
'type' => MENU_NORMAL_ITEM, |
| 38 |
|
); |
| 39 |
|
} |
| 40 |
|
return $items; |
| 41 |
|
} |
| 42 |
|
|
| 43 |
|
/** |
| 44 |
|
* Form callback for the admin settings form. |
| 45 |
|
*/ |
| 46 |
|
function role_weights_settings_form() { |
| 47 |
|
$form = array(); |
| 48 |
|
|
| 49 |
|
$form['role_weights_reorder_forms'] = array( |
| 50 |
|
'#type' => 'checkbox', |
| 51 |
|
'#title' => t('Enable sort by role weights'), |
| 52 |
|
'#default_value' => variable_get('role_weights_reorder_forms', FALSE), |
| 53 |
|
'#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>'), |
| 54 |
|
); |
| 55 |
|
|
| 56 |
|
return system_settings_form($form); |
| 57 |
|
} |
| 58 |
|
|
| 59 |
/** |
/** |
| 60 |
* Implementation of hook_form_alter(). |
* Implementation of hook_form_alter(). |