function farm_group_members in farmOS 7
Load all members of a group.
Parameters
FarmAsset $group: The group to load members from.
int $time: Unix timestamp limiter. Only logs before this time will be included. Defaults to the current time. Set to 0 to load the absolute last.
bool|null $done: Whether or not to only show logs that are marked as "done". TRUE will limit to logs that are done, and FALSE will limit to logs that are not done. If this is set to NULL, no filtering will be applied. Defaults to TRUE.
bool $archived: Whether or not to include archived member assets. Defaults to FALSE.
Return value
array Returns an array of the group's member assets, keyed by asset ID.
3 calls to farm_group_members()
- farm_group_members_count_recursive in modules/
farm/ farm_group/ farm_group.farm_area.inc - Recursively count group members.
- farm_livestock_asset_inventory in modules/
farm/ farm_livestock/ farm_livestock.module - Calculate the inventory for a given animal or group asset.
- farm_livestock_weight_group_report in modules/
farm/ farm_livestock/ farm_livestock_weight/ farm_livestock_weight.module - Generate Animal Weight Group Report
2 string references to 'farm_group_members'
- farm_group_farm_ui_entity_views in modules/
farm/ farm_group/ farm_group.module - Implements hook_farm_ui_entity_views().
- farm_group_views_default_views in modules/
farm/ farm_group/ farm_group.views_default.inc - Implements hook_views_default_views().
File
- modules/
farm/ farm_group/ farm_group.module, line 676
Code
function farm_group_members(FarmAsset $group, $time = REQUEST_TIME, $done = TRUE, $archived = FALSE) {
/**
* @todo
* Merge/abstract with farm_movement_area_assets().
*/
// Start an empty array of members.
$members = array();
// If the group doesn't have an id, bail.
if (empty($group->id)) {
return $members;
}
// Build a query to find all members of the group.
$query = farm_group_members_query($group->id, $time, $done, $archived);
// Execute the query to get a list of asset IDs.
$result = $query
->execute();
// Iterate through the results.
foreach ($result as $row) {
// If the asset ID is empty, skip it.
if (empty($row->asset_id)) {
continue;
}
// If the asset has already been loaded, skip it.
if (array_key_exists($row->asset_id, $members)) {
continue;
}
// Load the asset.
$members[$row->asset_id] = farm_asset_load($row->asset_id);
}
// Return the array of members.
return $members;
}