1 user.theme.inc theme_user_admin_permissions($variables)

Returns HTML for the administer permissions page.

Parameters

$variables: An associative array containing:

  • form: A render element representing the form.

Related topics

File

core/modules/user/user.theme.inc, line 106
Theme functions for the User module.

Code

function theme_user_admin_permissions($variables) {
  $form = $variables['form'];

  $roles = user_roles();
  foreach (element_children($form['permission']) as $key) {
    $row = array(
      'data' => array(),
    );

    // Hide the permission (or module) name and description element, since the
    // individual properties will be pulled out in each row.
    hide($form['permission'][$key]);

    // Module name row.
    if (is_numeric($key)) {
      $module_text = '<div class="permission-module-name table-filter-text-source">' . $form['permission'][$key]['#markup'] . '</div>';
      $row['class'] = array('module-row');
      $row['data'][] = array(
        'data' => $module_text,
        'class' => array('module'),
        'id' => 'module-' . $form['permission'][$key]['#id'],
        'colspan' => count($form['roles']['#value']) + 1,
      );
    }
    // Permission row.
    else {
      $permission_text = '<div class="permission-name table-filter-text-source">' . $form['permission'][$key]['#markup'] . '</div>';
      $permission_text .= $form['permission'][$key]['#description'];

      $row['data'][] = array(
        'data' => $permission_text,
        'class' => array('permission', 'table-filter-text'),
        'id' => $form['permission'][$key]['#id'],
      );
      foreach (element_children($form['checkboxes']) as $role_name) {
        $form['checkboxes'][$role_name][$key]['#title'] = $roles[$role_name] . ': ' . $form['permission'][$key]['#markup'];
        $form['checkboxes'][$role_name][$key]['#title_display'] = 'attribute';
        $row['data'][] = array(
          'data' => backdrop_render($form['checkboxes'][$role_name][$key]),
          'class' => array('checkbox'),
        );
      }
    }
    $rows[] = $row;
  }
  $header[] = (t('Permission'));
  foreach (element_children($form['role_names']) as $role_name) {
    $header_cell = array(
      'data' => backdrop_render($form['role_names'][$role_name]),
      'class' => array('checkbox'),
    );
    // Output a role description if present as a title attribute on the cell.
    if (isset($form['role_names'][$role_name]['#description'])) {
      $header_cell['title'] = check_plain(strip_tags($form['role_names'][$role_name]['#description']));
    }
    $header[] = $header_cell;
  }

  $output = backdrop_render($form['filter']);
  // Wrap the table in its own class so that we can make it horizontally
  // scrollable.
  $output .= '<div class="permissions-matrix">';
  $output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'permissions')));
  $output .= '</div>';
  $output .= backdrop_render_children($form);
  return $output;
}