You are here

function regcode_og_label in Registration codes 7

Same name and namespace in other branches
  1. 7.2 regcode_og/regcode_og.module \regcode_og_label()

Helper function that returns the labels of multiple groups or a single group.

Parameters

array $gids: This can be an array of group ids or just a single group id.

Return value

array $labels The label for each group.

3 calls to regcode_og_label()
regcode_og_create in regcode_og/regcode_og.module
Form: Create form for og assignment rules.
regcode_og_rules_page in regcode_og/regcode_og.module
List all of the rules as a HTML table.
regcode_og_settings in regcode_og/regcode_og.module
Form: Settings form for an og assignment rule.

File

regcode_og/regcode_og.module, line 310
Install, uninstall and scheme functions for the regcode_og module.

Code

function regcode_og_label($gids) {
  $labels = array();

  // We may want to get the label of a single group by just passing a gid.
  $gids = !is_array($gids) ? array(
    $gids,
  ) : $gids;

  // Load the entities.
  $entities = entity_load_multiple_by_name('node', $gids);
  foreach ($entities as $id => $entity) {

    // Set the label for the current entity.
    $labels[$id] = entity_label('node', $entity);

    // Allow altering the entity label. This is useful if we have sub-groups and
    // those sub-groups have the same name. This will allow appending something
    // to the label to differentiate between them.
    drupal_alter('regcode_og_label', $labels, $entity);
  }
  return $labels;
}