You are here

function eck__bundle__list in Entity Construction Kit (ECK) 7.3

Same name and namespace in other branches
  1. 7.2 eck.bundle.inc \eck__bundle__list()

Page call back for the bundle overview table.

to see and manipulate all created label of a given type.

Parameters

string $entity_type: The name of the entity type.

1 string reference to 'eck__bundle__list'
eck__bundle__menu in ./eck.bundle.inc
This function creates the menu items relevant to bundle administration.

File

./eck.bundle.inc, line 183

Code

function eck__bundle__list($entity_type) {
  $path = eck__entity_type__path();
  $entity_type = entity_type_load($entity_type);

  // Check that the user has permissions to view bundle lists.
  if (eck_access('list', 'bundle') || eck_access('list', "bundle", $entity_type)) {
    $header = array(
      t('Type'),
      array(
        'data' => t('Operations'),
        'colspan' => '1',
      ),
    );
    $rows = array();
    $bundles = Bundle::loadByEntityType($entity_type);
    usort($bundles, 'eck_alphabetical_cmp');
    foreach ($bundles as $bundle) {
      $bundle_label = $bundle->label;
      $admin_info = get_bundle_admin_info($entity_type->name, $bundle->name);
      $uri = $admin_info['path'];
      $allowed_operations = '';

      // Check that the user has permissions to delete.
      if (eck_access('delete', 'bundle', $bundle)) {
        $allowed_operations = l(t('delete'), $uri . "/delete");
      }
      if (eck_access('list', 'entity') || eck_access('list', 'entity', $bundle)) {
        $rows[] = array(
          l($bundle_label, url($uri, array(
            'absolute' => TRUE,
          ))),
          $allowed_operations,
        );
      }
      else {
        $rows[] = array(
          $bundle_label,
          $allowed_operations,
        );
      }
    }
    $build['bundle_table'] = array(
      '#theme' => 'table',
      '#header' => $header,
      '#rows' => $rows,
    );
  }
  return $build;
}