function registration_get_registrations in Entity Registration 7.2
Same name and namespace in other branches
- 8.2 registration.module \registration_get_registrations()
Load registrations for a host entity, optionally filtered to a particular registrant email.
Parameters
string $entity_type: Host entity type.
object $entity_id: Host entity id.
string $registrant_mail: Registrant mail - optional.
array $states: List of names of States to look for.
Return value
array List of registrations.
1 call to registration_get_registrations()
- registration_is_registered in ./
registration.module - Determine if a person has an active registration for a host entity.
File
- ./
registration.module, line 1570
Code
function registration_get_registrations($entity_type, $entity_id, $registrant_mail = NULL, $states = NULL) {
$entity = entity_load_single($entity_type, $entity_id);
$registration_type = registration_get_types(registration_get_entity_registration_type($entity_type, $entity));
if (!$states) {
$states = registration_get_active_states();
}
$query = db_select('registration', 'r')
->fields('r', array(
'registration_id',
))
->condition('entity_type', $entity_type)
->condition('entity_id', $entity_id)
->condition('state', $states, 'IN');
// There's a registrant with this email, check to see if they are registered.
$registrant = registration_registrant_load_by_mail($registration_type, $registrant_mail);
if ($registrant) {
$query
->condition(db_or()
->condition('anon_mail', $registrant_mail)
->condition('registrant_id', $registrant
->getIdentifier()));
}
else {
$query
->condition('anon_mail', $registrant_mail);
}
$result = $query
->execute()
->fetchCol();
if ($result) {
return entity_load('registration', $result);
}
return array();
}