You are here

function theme_og_ui_user_admin_permissions in Organic groups 7

Theme the administer permissions page.

File

og_ui/og_ui.admin.inc, line 637
Admin settings for Organic groups module.

Code

function theme_og_ui_user_admin_permissions($variables) {
  $form = $variables['form'];
  $gid = !empty($form['group']['#value']->gid) ? $form['group']['#value']->gid : 0;
  $roles = og_roles($gid);
  foreach (element_children($form['permission']) as $key) {
    $row = array();

    // Module name.
    if (is_numeric($key)) {
      $row[] = array(
        'data' => drupal_render($form['permission'][$key]),
        'class' => array(
          'module',
        ),
        'id' => 'module-' . $form['permission'][$key]['#id'],
        'colspan' => count($form['role_names']['#value']) + 1,
      );
    }
    else {

      // Permission row.
      $row[] = array(
        'data' => drupal_render($form['permission'][$key]),
        'class' => array(
          'permission',
        ),
      );
      foreach (element_children($form['checkboxes']) as $rid) {
        $row[] = array(
          'data' => drupal_render($form['checkboxes'][$rid][$key]),
          'class' => array(
            'checkbox',
          ),
          'title' => $roles[$rid] . ' : ' . t($key),
        );
      }
    }
    $rows[] = $row;
  }
  $header[] = t('Permission');
  foreach (element_children($form['role_names']) as $rid) {
    $header[] = array(
      'data' => drupal_render($form['role_names'][$rid]),
      'class' => array(
        'checkbox',
      ),
    );
  }
  $output = theme('table', array(
    'header' => $header,
    'rows' => $rows,
    'attributes' => array(
      'id' => 'permissions',
    ),
  ));
  $output .= drupal_render_children($form);
  return $output;
}