You are here

function theme_filter_perms_admin_by_module in Filter Permissions 6

1 string reference to 'theme_filter_perms_admin_by_module'
filter_perms_theme_registry_alter in ./filter_perms.module
Implementation of hook_theme_registry_alter().

File

./filter_perms.module, line 239
This module adds a role and module filter to the user permissions page. Best used when you have an unruly amount of roles or permissions on your site and want to more efficiently manage them without loading a gigantic grid of checkboxes.

Code

function theme_filter_perms_admin_by_module($menu_items) {
  $stripe = 0;
  $output = '';
  $container = array(
    'left' => '',
    'right' => '',
  );
  $flip = array(
    'left' => 'right',
    'right' => 'left',
  );
  $position = 'left';

  // Iterate over all modules
  foreach ($menu_items as $module => $block) {
    list($description, $items) = $block;

    // Output links
    if (count($items)) {
      if (isset($items['-1'])) {
        $items['-1'] = str_replace('#module-', '/', $items['-1']);
      }
      $block = array();
      $block['title'] = $module;
      $block['content'] = theme('item_list', $items);
      $block['description'] = t($description);
      if ($block_output = theme('admin_block', $block)) {
        if (!isset($block['position'])) {

          // Perform automatic striping.
          $block['position'] = $position;
          $position = $flip[$position];
        }
        $container[$block['position']] .= $block_output;
      }
    }
  }
  $output = '<div class="admin clear-block">';
  foreach ($container as $id => $data) {
    $output .= '<div class="' . $id . ' clear-block">';
    $output .= $data;
    $output .= '</div>';
  }
  $output .= '</div>';
  return $output;
}