Commit 8e611f00 authored by Klaus Purer's avatar Klaus Purer
Browse files

Issue #1320852: Fixed machine name form element, added machine name column to...

Issue #1320852: Fixed machine name form element, added machine name column to the role overview table.
parent 4d36d558
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -17,25 +17,28 @@
function theme_role_export_user_admin_roles($variables) {
  $form = $variables['form'];

  $header = array(t('Name'), t('Weight'), array('data' => t('Operations'), 'colspan' => 2));
  $header = array(t('Name'), t('Machine name'), t('Weight'), array('data' => t('Operations'), 'colspan' => 2));
  foreach (element_children($form['roles']) as $rid) {
    $name = $form['roles'][$rid]['#role']->name;
    $machine_name = $form['roles'][$rid]['#role']->machine_name;
    $row = array();
    if (in_array($rid, array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID))) {
      $row[] = t('@name <em>(locked)</em>', array('@name' => $name));
      $row[] = '';
      $row[] = drupal_render($form['roles'][$rid]['weight']);
      $row[] = '';
      $row[] = l(t('edit permissions'), 'admin/people/permissions/' . $rid);
    }
    else {
      $row[] = check_plain($name);
      $row[] = check_plain($machine_name);
      $row[] = drupal_render($form['roles'][$rid]['weight']);
      $row[] = l(t('edit role'), 'admin/people/permissions/roles/edit/' . $rid);
      $row[] = l(t('edit permissions'), 'admin/people/permissions/' . $rid);
    }
    $rows[] = array('data' => $row, 'class' => array('draggable'));
  }
  $rows[] = array(array('data' => drupal_render($form['name']) . drupal_render($form['machine_name']) . drupal_render($form['add']), 'colspan' => 4, 'class' => 'edit-name'));
  $rows[] = array(array('data' => drupal_render($form['name']) . drupal_render($form['machine_name']) . drupal_render($form['add']), 'colspan' => 5, 'class' => 'edit-name'));

  drupal_add_tabledrag('user-roles', 'order', 'sibling', 'role-weight');

+9 −1
Original line number Diff line number Diff line
@@ -15,6 +15,14 @@
function role_export_form_alter(&$form, &$form_state, $form_id) {
  switch ($form_id) {
    case 'user_admin_roles':
      // Add the machine name to the role objects in the form.
      $roles = role_export_roles();
      foreach ($form['roles'] as $key => &$element) {
        if (is_numeric($key)) {
          $element['#role'] = $roles[$key];
        }
      }
      $form['#theme'] = array('role_export_user_admin_roles');
      drupal_add_css(drupal_get_path('module', 'role_export') . '/role_export.css');
      $form['name']['#description'] = t('The human-readable name of this role.<br />This text will be displayed as part of the list on the <em>Roles</em> page.');
      $form['machine_name'] = array(
@@ -81,7 +89,7 @@ function role_export_submit($form, &$form_state) {
 */
function role_export_theme() {
  return array(
    'user_admin_roles' => array(
    'role_export_user_admin_roles' => array(
      'render element' => 'form',
      'file' => 'role_export.admin.inc',
      'function' => 'theme_role_export_user_admin_roles',