function registration_access_people in Entity Registration 7
Same name and namespace in other branches
- 8 registration.module \registration_access_people()
Determine people types user may register for an entity.
This will take into account if a user already has a registration for a host entity.
Parameters
object $registration: A fully loaded registration object.
object $account: (optional) An user object, or omit for logged in user.
Return value
array Array keyed with people types, with descriptions.
3 calls to registration_access_people()
- RegistrationStandardTestCase::testRegistrationForm in tests/
registration.test - Tests for the registration add/edit form.
- registration_access in ./
registration.module - Access callback: Entity API for Registration entities.
- registration_form in includes/
registration.forms.inc - Form callback: create or edit a registration.
File
- ./
registration.module, line 1527
Code
function registration_access_people(Registration $registration, $account = NULL) {
$account = isset($account) ? $account : $GLOBALS['user'];
$people = array();
// Me:
$settings = registration_entity_settings($registration->entity_type, $registration->entity_id);
$allow_multiple = !empty($settings['settings']['multiple_registrations']) && $settings['settings']['multiple_registrations'];
if ($account->uid && user_access("create {$registration->type} registration self", $account) && ($account->uid === $registration->user_uid || (!registration_is_registered($registration, NULL, $account->uid) || $allow_multiple))) {
$people[REGISTRATION_REGISTRANT_TYPE_ME] = t('Myself');
}
// Other users:
if (user_access("create {$registration->type} registration other users", $account)) {
$people[REGISTRATION_REGISTRANT_TYPE_USER] = t('Other account');
}
$user_is_anonymous = empty($account->uid) || $account->uid == 0;
// Other anonymous people:
if (user_access("create {$registration->type} registration other anonymous", $account) && !$user_is_anonymous) {
$people[REGISTRATION_REGISTRANT_TYPE_ANON] = t('Other person');
}
// Anonymous self-registration:
if ($user_is_anonymous && user_access("create {$registration->type} registration")) {
$people[REGISTRATION_REGISTRANT_TYPE_ANON] = t('Myself');
}
return $people;
}