You are here

function theme_merci_permissions_form in MERCI (Manage Equipment Reservations, Checkout and Inventory) 6

Same name and namespace in other branches
  1. 8.2 modules/merci_permissions/merci_permissions.module \theme_merci_permissions_form()
  2. 6.2 modules/merci_permissions/merci_permissions.module \theme_merci_permissions_form()
  3. 7.2 modules/merci_permissions/merci_permissions.module \theme_merci_permissions_form()

File

modules/merci_permissions/merci_permissions.module, line 32
Provides functions for resetting permissions on the permission page.

Code

function theme_merci_permissions_form($form) {
  $roles = user_roles();
  foreach (element_children($form['permission']) as $key) {

    // Don't take form control structures
    if (is_array($form['permission'][$key])) {
      $row = array();

      // Module name
      if (is_numeric($key)) {
        $row[] = array(
          'data' => t('@module', array(
            '@module' => drupal_render($form['permission'][$key]),
          )),
          'class' => 'module',
          'id' => 'module-' . $form['permission'][$key]['#value'],
          'colspan' => count($form['role_names']) + 1,
        );
      }
      else {
        $row[] = array(
          'data' => drupal_render($form['permission'][$key]),
          'class' => 'permission',
        );
        foreach (element_children($form['checkboxes']) as $rid) {
          if (is_array($form['checkboxes'][$rid])) {
            $row[] = array(
              'data' => drupal_render($form['checkboxes'][$rid][$key]),
              'class' => 'checkbox',
              'title' => $roles[$rid] . ' : ' . t($key),
            );
          }
        }
      }
      $rows[] = $row;
    }
  }
  $header[] = t('');
  foreach (element_children($form['role_names']) as $rid) {
    if (is_array($form['role_names'][$rid])) {
      $header[] = array(
        'data' => drupal_render($form['role_names'][$rid]),
        'class' => 'checkbox',
      );
    }
  }
  $output = theme('table', $header, $rows, array(
    'id' => 'permissions',
  ));
  $output .= drupal_render($form);
  return $output;
}