function farm_group_farm_area_link_alter in farmOS 7
Implements hook_farm_area_link_alter().
File
- modules/
farm/ farm_group/ farm_group.farm_area.inc, line 9
Code
function farm_group_farm_area_link_alter(&$link, $entity_info) {
// We are only altering the link for group assets. Otherwise, bail.
if (!($entity_info['entity_type'] == 'farm_asset' && $entity_info['bundle'] == 'group')) {
return;
}
// If there aren't any entity IDs, bail.
if (empty($entity_info['entity_ids'])) {
return;
}
// Load each of the groups.
$groups = array();
foreach ($entity_info['entity_ids'] as $id) {
$group = farm_asset_load($id);
if (!empty($group)) {
$groups[] = $group;
}
}
// Recursively count all group members.
$member_count = 0;
foreach ($groups as $group) {
$member_count += farm_group_members_count_recursive($group);
}
// Alter the link to add the member count.
if (!empty($member_count)) {
$link['title'] .= ' (' . t('@count members', array(
'@count' => $member_count,
)) . ')';
}
}