function theme_user_admin_roles

Returns HTML for the role order and new role form.

Parameters

$variables: An associative array containing:

  • form: A render element representing the form.

Related topics

File

drupal/core/modules/user/user.admin.inc, line 904
Admin page callback file for the user module.

Code

function theme_user_admin_roles($variables) {
  $form = $variables['form'];
  $header = array(
    t('Name'),
    t('Weight'),
    t('Operations'),
  );
  foreach (element_children($form['roles']) as $rid) {
    $row = array();
    foreach (element_children($form['roles'][$rid]) as $column) {
      $row[] = drupal_render($form['roles'][$rid][$column]);
    }
    $rows[] = array(
      'data' => $row,
      'class' => array(
        'draggable',
      ),
    );
  }

  // Distribute the role add form into table columns.
  $form['role']['name']['#title_display'] = 'invisible';
  unset($form['role']['name']['#description']);
  unset($form['role']['rid']['#description']);
  $actions = $form['role']['actions'];
  unset($form['role']['actions']);
  unset($form['role']['weight']);
  $row = array();
  $row[] = drupal_render($form['role']);

  // Empty placeholder for the weight column.
  $row[] = '';
  $row[] = array(
    'data' => drupal_render($actions),
    'colspan' => 2,
  );
  $rows[] = array(
    'data' => $row,
  );
  drupal_add_tabledrag('user-roles', 'order', 'sibling', 'role-weight');
  $output = theme('table', array(
    'header' => $header,
    'rows' => $rows,
    'attributes' => array(
      'id' => 'user-roles',
    ),
  ));
  $output .= drupal_render_children($form);
  return $output;
}