You are here

function theme_block_access_admin_list in Block Access 6.2

Same name and namespace in other branches
  1. 6 block_access.theme.inc \theme_block_access_admin_list()
  2. 7 block_access.theme.inc \theme_block_access_admin_list()

Theme function for the admin list form.

File

./block_access.theme.inc, line 11
Themes for block_access module.

Code

function theme_block_access_admin_list($form) {
  $header = array(
    t('Module'),
    t('Current Settings'),
    t('Operations'),
  );
  $rows = array();
  foreach ($form['list'] as $key => $element) {
    if (is_numeric($key)) {
      $row = array();
      $module = $element['name']['#value'];
      $row[] = $module;
      $roles = block_access_get_module($module);
      if (empty($roles)) {
        $row[] = 'None';
      }
      else {
        $names = user_roles();
        $output = '<ul>';
        foreach ($roles as $rid => $perms) {
          $role = $names[$rid];
          $output .= '<li>' . $role . '<ul>';
          foreach ($perms as $perm) {
            $output .= '<li>' . $perm . '</li>';
          }
          $output .= '</ul></li>';
        }
        $output .= '</ul>';
        $row[] = $output;
      }
      $row[] = l(t('edit'), BLOCK_ACCESS_SETTINGS . '/edit/' . $module);
      $rows[] = array(
        'data' => $row,
      );
      unset($form['list'][$key]);
    }
  }
  if (empty($rows)) {
    $rows[] = array(
      array(
        'data' => t('No modules found.'),
        'colspan' => 2,
      ),
    );
    array_pop($header);
  }
  $form['list']['table'] = array(
    '#value' => theme('table', $header, $rows, array(
      'id' => 'block_access-list-table',
    )),
  );
  return 'This is a list of modules which expose blocks. Here you can define default permissions on a per module basis to be used when new blocks get created.' . drupal_render($form);
}