function social_event_manager_or_organizer in Open Social 8.6
Same name and namespace in other branches
- 8.9 modules/social_features/social_event/social_event.module \social_event_manager_or_organizer()
- 8.5 modules/social_features/social_event/social_event.module \social_event_manager_or_organizer()
- 8.7 modules/social_features/social_event/social_event.module \social_event_manager_or_organizer()
- 8.8 modules/social_features/social_event/social_event.module \social_event_manager_or_organizer()
- 10.3.x modules/social_features/social_event/social_event.module \social_event_manager_or_organizer()
- 10.0.x modules/social_features/social_event/social_event.module \social_event_manager_or_organizer()
- 10.1.x modules/social_features/social_event/social_event.module \social_event_manager_or_organizer()
- 10.2.x modules/social_features/social_event/social_event.module \social_event_manager_or_organizer()
Check if the user is allowed to manage Enrollments.
Parameters
\Drupal\node\NodeInterface|null $node: The node the current user could be organizer of.
bool $skip_trusted_roles: Should we skip CM/SM with the manage everything enrollments.
Return value
bool If the user is actually a manager or organizer.
8 calls to social_event_manager_or_organizer()
- EventAnEnrollManager::getGuestName in modules/
social_features/ social_event/ modules/ social_event_an_enroll/ src/ EventAnEnrollManager.php - Returns guest name.
- EventEnrollmentEntityDeleteAction::access in modules/
social_features/ social_event/ modules/ social_event_managers/ src/ Plugin/ Action/ EventEnrollmentEntityDeleteAction.php - SocialEventManagersAddEnrolleeForm::submitForm in modules/
social_features/ social_event/ modules/ social_event_managers/ src/ Form/ SocialEventManagersAddEnrolleeForm.php - Form submission handler.
- SocialEventManagersSendEmail::access in modules/
social_features/ social_event/ modules/ social_event_managers/ src/ Plugin/ Action/ SocialEventManagersSendEmail.php - social_event_managers_entity_access in modules/
social_features/ social_event/ modules/ social_event_managers/ social_event_managers.module - Implements hook_entity_access().
File
- modules/
social_features/ social_event/ social_event.module, line 81 - The Social event module.
Code
function social_event_manager_or_organizer(NodeInterface $node = NULL, $skip_trusted_roles = FALSE) {
$account = \Drupal::currentUser();
// Allow if user has the manage everything permission.
// We can skip this to make sure we truly only check organizer & managers
// used for context in notifications.
if ($skip_trusted_roles === FALSE && $account
->hasPermission('manage everything enrollments')) {
return TRUE;
}
if ($node === NULL) {
/** @var \Drupal\node\NodeInterface $node */
$node = \Drupal::routeMatch()
->getParameter('node');
// Or if it's an organizer for the node.
if (!$node instanceof NodeInterface) {
$node = \Drupal::entityTypeManager()
->getStorage('node')
->load($node);
}
// If we are altering / deleting an Event Enrollment check if user
// is manager or organizer from the referenced node.
$event_enrollment = \Drupal::routeMatch()
->getParameter('event_enrollment');
if ($event_enrollment instanceof EventEnrollmentInterface) {
$node = $event_enrollment->field_event->entity;
}
}
if ($node !== NULL && $node
->bundle() === 'event' && !$node->field_event_managers
->isEmpty()) {
foreach ($node->field_event_managers
->getValue() as $value) {
if ($value && $value['target_id'] === $account
->id()) {
return TRUE;
}
}
}
return FALSE;
}