You are here

function theme_flag_form_roles in Flag 6.2

Same name and namespace in other branches
  1. 7.3 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 551
Contains administrative pages for creating, editing, and deleting flags.

Code

function theme_flag_form_roles($element) {
  drupal_add_css(drupal_get_path('module', 'flag') . '/theme/flag-admin.css', 'module', 'all', FALSE);
  drupal_add_js(drupal_get_path('module', 'flag') . '/theme/flag-admin.js', 'module', 'header', FALSE, TRUE, FALSE);
  $header = array(
    array(
      'class' => 'checkbox',
      'data' => t('Flag'),
    ),
    array(
      'class' => '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'] = 'flag-access';
    $element['unflag'][$role]['#attributes']['class'] = 'unflag-access';
    $row[] = array(
      'class' => 'checkbox',
      'data' => drupal_render($element['flag'][$role]),
    );
    $row[] = array(
      'class' => 'checkbox',
      'data' => drupal_render($element['unflag'][$role]),
    );
    $row[] = $role_name;
    $rows[] = $row;
  }
  $element['#children'] = theme('table', $header, $rows, array(
    'class' => 'flag-admin-table',
    'id' => 'flag-roles',
  ));
  return theme('form_element', $element, $element['#children']);
}