perf(entities): loads more entities with a single query

This optimizes elgg_get_entities() to automatically add joins to load entities
in fewer queries. It also improves get_entity() by using elgg_get_entities
internally.

Fixes #7662, #7659