private function FlexibleGroupJoinPermissionAccessCheck::calculateJoinPermission in Open Social 8.7
Same name and namespace in other branches
- 8.9 modules/social_features/social_group/modules/social_group_flexible_group/src/Access/FlexibleGroupJoinPermissionAccessCheck.php \Drupal\social_group_flexible_group\Access\FlexibleGroupJoinPermissionAccessCheck::calculateJoinPermission()
- 8.6 modules/social_features/social_group/modules/social_group_flexible_group/src/Access/FlexibleGroupJoinPermissionAccessCheck.php \Drupal\social_group_flexible_group\Access\FlexibleGroupJoinPermissionAccessCheck::calculateJoinPermission()
- 8.8 modules/social_features/social_group/modules/social_group_flexible_group/src/Access/FlexibleGroupJoinPermissionAccessCheck.php \Drupal\social_group_flexible_group\Access\FlexibleGroupJoinPermissionAccessCheck::calculateJoinPermission()
- 10.3.x modules/social_features/social_group/modules/social_group_flexible_group/src/Access/FlexibleGroupJoinPermissionAccessCheck.php \Drupal\social_group_flexible_group\Access\FlexibleGroupJoinPermissionAccessCheck::calculateJoinPermission()
- 10.0.x modules/social_features/social_group/modules/social_group_flexible_group/src/Access/FlexibleGroupJoinPermissionAccessCheck.php \Drupal\social_group_flexible_group\Access\FlexibleGroupJoinPermissionAccessCheck::calculateJoinPermission()
- 10.1.x modules/social_features/social_group/modules/social_group_flexible_group/src/Access/FlexibleGroupJoinPermissionAccessCheck.php \Drupal\social_group_flexible_group\Access\FlexibleGroupJoinPermissionAccessCheck::calculateJoinPermission()
- 10.2.x modules/social_features/social_group/modules/social_group_flexible_group/src/Access/FlexibleGroupJoinPermissionAccessCheck.php \Drupal\social_group_flexible_group\Access\FlexibleGroupJoinPermissionAccessCheck::calculateJoinPermission()
Calculates permissions for LU users also including administrative roles.
Parameters
string $permission: The permission we need to check access for.
\Drupal\group\Entity\Group $group: The Group we are on.
\Drupal\Core\Session\AccountInterface $account: The account to check access for.
\Drupal\Core\Routing\RouteMatchInterface $route_match: The parametrized route.
Return value
bool FALSE if its not allowed.
1 call to FlexibleGroupJoinPermissionAccessCheck::calculateJoinPermission()
- FlexibleGroupJoinPermissionAccessCheck::access in modules/
social_features/ social_group/ modules/ social_group_flexible_group/ src/ Access/ FlexibleGroupJoinPermissionAccessCheck.php - Checks access.
File
- modules/
social_features/ social_group/ modules/ social_group_flexible_group/ src/ Access/ FlexibleGroupJoinPermissionAccessCheck.php, line 113
Class
- FlexibleGroupJoinPermissionAccessCheck
- Determines access to routes based flexible_group membership and settings.
Namespace
Drupal\social_group_flexible_group\AccessCode
private function calculateJoinPermission($permission, Group $group, AccountInterface $account, RouteMatchInterface $route_match) {
$direct_option = social_group_flexible_group_can_join_directly($group);
$added_option = social_group_flexible_group_can_be_added($group);
// Users with this permission are always able to do so.
if ($account
->hasPermission('manage all groups')) {
return TRUE;
}
// LU Can only see members tabs for joining directly
// or when he is a GM/GA.
if (!$direct_option && $route_match
->getRouteName() === 'view.group_manage_members.page_group_manage_members' && $account
->isAuthenticated() && !$group
->getMember($account) && !$group
->hasPermission('administer members', $account)) {
return FALSE;
}
// There is no direct join method so it's not allowed to go to /join.
if ($permission === 'join direct' && !$direct_option && !$group
->getMember($account)) {
return FALSE;
}
if ($permission === 'join added' && !$added_option) {
return FALSE;
}
return TRUE;
}