You are here

function roleassign_admin_form in RoleAssign 7

Same name and namespace in other branches
  1. 7.2 roleassign.admin.inc \roleassign_admin_form()

Returns a system settings form to administer RoleAssign.

Allows the administrator to select which roles will be available to assign for users with the <code>assign roles</code> permission.

Return value

array|null

1 string reference to 'roleassign_admin_form'
roleassign_menu in ./roleassign.module
Implements hook_menu().

File

./roleassign.admin.inc, line 17
Allows site administrators to further delegate the task of managing user's roles.

Code

function roleassign_admin_form() {

  // To admister roleassign, 'administer permissions' permission is required.
  if (!user_access('administer permissions')) {
    return NULL;
  }

  // Get all available roles except for 'anonymous user'
  // and 'authenticated user'.
  $roles = user_roles(TRUE);
  unset($roles[DRUPAL_AUTHENTICATED_RID]);

  // Show checkboxes with roles that can be delegated if any.
  if ($roles) {
    $form['roleassign_roles'] = array(
      '#type' => 'checkboxes',
      '#title' => t('Roles'),
      '#options' => $roles,
      '#default_value' => variable_get('roleassign_roles', array()),
      '#description' => t('Select roles that should be available for assignment.'),
    );
  }
  else {
    $form['roleassign_roles'] = array(
      '#type' => 'markup',
      '#value' => '<p>No assignable roles available. You have to ' . l(t('create roles'), 'admin/people/permissions/roles') . ' that can be assigned.</p>',
    );
  }

  // Return system settings form.
  return system_settings_form($form);
}