You are here

function multiple_registration_user_admin_roles in Multiple Registration 7

Returns HTML for the role order and new role form.

Parameters

array $variables: An associative array containing:

  • form: A render element representing the form.

Return value

string

Throws

Exception

1 string reference to 'multiple_registration_user_admin_roles'
multiple_registration_theme_registry_alter in ./multiple_registration.module
Implements hook_theme_registry_alter().

File

./multiple_registration.module, line 116
Add ability to create several registration pages.

Code

function multiple_registration_user_admin_roles(array $variables) {
  $form = $variables['form'];
  $header = array(
    t('Name'),
    t('Weight'),
    array(
      'data' => t('Operations'),
      'colspan' => 3,
    ),
  );
  foreach (element_children($form['roles']) as $rid) {
    $name = $form['roles'][$rid]['#role']->name;
    $row = array();
    if (in_array($rid, array(
      DRUPAL_ANONYMOUS_RID,
      DRUPAL_AUTHENTICATED_RID,
    ))) {
      $row[] = t('@name <em>(locked)</em>', array(
        '@name' => $name,
      ));
      $row[] = drupal_render($form['roles'][$rid]['weight']);
      $row[] = '';
      $row[] = l(t('edit permissions'), 'admin/people/permissions/' . $rid);
      $row[] = '';
    }
    else {
      $row[] = check_plain($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);
      if ($rid != variable_get('user_admin_role')) {
        if (!variable_get('multiple_registration_url_' . $rid, '')) {
          $row[] = l(t('add own registration page'), 'admin/config/people/multiple_registration/' . $rid . '/add', array(
            'query' => array(
              'destination' => current_path(),
            ),
          ));
        }
        else {
          $row[] = l(t('remove own registration page'), 'admin/config/people/multiple_registration/' . $rid . '/remove', array(
            'query' => array(
              'destination' => current_path(),
            ),
          ));
        }
      }
      else {
        $row[] = '';
      }
    }
    $rows[] = array(
      'data' => $row,
      'class' => array(
        'draggable',
      ),
    );
  }
  $rows[] = array(
    array(
      'data' => drupal_render($form['name']) . drupal_render($form['add']),
      'colspan' => 4,
      'class' => 'edit-name',
    ),
  );
  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;
}