You are here

function theme_flag_form_roles in Flag 7.3

Same name and namespace in other branches
  1. 6.2 includes/flag.admin.inc \theme_flag_form_roles()
  2. 7.2 includes/flag.admin.inc \theme_flag_form_roles()

Output the access options for roles in a table.

1 theme call to theme_flag_form_roles()
flag_form in includes/flag.admin.inc
Add/Edit flag page.

File

includes/flag.admin.inc, line 735
Contains administrative pages for creating, editing, and deleting flags.

Code

function theme_flag_form_roles($variables) {
  $element = $variables['element'];
  $header = array(
    array(
      'class' => array(
        'checkbox',
      ),
      'data' => t('Flag'),
    ),
    array(
      'class' => array(
        'checkbox',
      ),
      'data' => t('Unflag'),
    ),
    t('Role'),
  );
  $rows = array();
  foreach (element_children($element['flag']) as $role) {
    $row = array();
    $role_name = $element['flag'][$role]['#title'];
    unset($element['flag'][$role]['#title']);
    unset($element['unflag'][$role]['#title']);
    $element['flag'][$role]['#attributes']['class'] = array(
      'flag-access',
    );
    $element['unflag'][$role]['#attributes']['class'] = array(
      'unflag-access',
    );
    $row[] = array(
      'class' => array(
        'checkbox',
      ),
      'data' => drupal_render($element['flag'][$role]),
    );
    $row[] = array(
      'class' => array(
        'checkbox',
      ),
      'data' => drupal_render($element['unflag'][$role]),
    );
    $row[] = $role_name;
    $rows[] = $row;
  }
  return theme('table', array(
    'header' => $header,
    'rows' => $rows,
    'attributes' => array(
      'class' => array(
        'flag-admin-table',
      ),
      'id' => 'flag-roles',
    ),
  ));
}