You are here

private function SocialGroupSelectorWidget::checkGroupContentCreateAccess in Open Social 10.2.x

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_group/src/Plugin/Field/FieldWidget/SocialGroupSelectorWidget.php \Drupal\social_group\Plugin\Field\FieldWidget\SocialGroupSelectorWidget::checkGroupContentCreateAccess()
  2. 8 modules/social_features/social_group/src/Plugin/Field/FieldWidget/SocialGroupSelectorWidget.php \Drupal\social_group\Plugin\Field\FieldWidget\SocialGroupSelectorWidget::checkGroupContentCreateAccess()
  3. 8.2 modules/social_features/social_group/src/Plugin/Field/FieldWidget/SocialGroupSelectorWidget.php \Drupal\social_group\Plugin\Field\FieldWidget\SocialGroupSelectorWidget::checkGroupContentCreateAccess()
  4. 8.3 modules/social_features/social_group/src/Plugin/Field/FieldWidget/SocialGroupSelectorWidget.php \Drupal\social_group\Plugin\Field\FieldWidget\SocialGroupSelectorWidget::checkGroupContentCreateAccess()
  5. 8.4 modules/social_features/social_group/src/Plugin/Field/FieldWidget/SocialGroupSelectorWidget.php \Drupal\social_group\Plugin\Field\FieldWidget\SocialGroupSelectorWidget::checkGroupContentCreateAccess()
  6. 8.5 modules/social_features/social_group/src/Plugin/Field/FieldWidget/SocialGroupSelectorWidget.php \Drupal\social_group\Plugin\Field\FieldWidget\SocialGroupSelectorWidget::checkGroupContentCreateAccess()
  7. 8.6 modules/social_features/social_group/src/Plugin/Field/FieldWidget/SocialGroupSelectorWidget.php \Drupal\social_group\Plugin\Field\FieldWidget\SocialGroupSelectorWidget::checkGroupContentCreateAccess()
  8. 8.7 modules/social_features/social_group/src/Plugin/Field/FieldWidget/SocialGroupSelectorWidget.php \Drupal\social_group\Plugin\Field\FieldWidget\SocialGroupSelectorWidget::checkGroupContentCreateAccess()
  9. 8.8 modules/social_features/social_group/src/Plugin/Field/FieldWidget/SocialGroupSelectorWidget.php \Drupal\social_group\Plugin\Field\FieldWidget\SocialGroupSelectorWidget::checkGroupContentCreateAccess()
  10. 10.3.x modules/social_features/social_group/src/Plugin/Field/FieldWidget/SocialGroupSelectorWidget.php \Drupal\social_group\Plugin\Field\FieldWidget\SocialGroupSelectorWidget::checkGroupContentCreateAccess()
  11. 10.0.x modules/social_features/social_group/src/Plugin/Field/FieldWidget/SocialGroupSelectorWidget.php \Drupal\social_group\Plugin\Field\FieldWidget\SocialGroupSelectorWidget::checkGroupContentCreateAccess()
  12. 10.1.x modules/social_features/social_group/src/Plugin/Field/FieldWidget/SocialGroupSelectorWidget.php \Drupal\social_group\Plugin\Field\FieldWidget\SocialGroupSelectorWidget::checkGroupContentCreateAccess()

Check if user may create content of bundle in group.

Parameters

int $gid: Group id.

\Drupal\user\Entity\User $account: The user to check for.

\Drupal\Core\Entity\EntityInterface $entity: The node bundle to check for.

Return value

int Either TRUE or FALSE.

1 call to SocialGroupSelectorWidget::checkGroupContentCreateAccess()
SocialGroupSelectorWidget::removeGroupsWithoutCreateAccess in modules/social_features/social_group/src/Plugin/Field/FieldWidget/SocialGroupSelectorWidget.php
Remove options from the list.

File

modules/social_features/social_group/src/Plugin/Field/FieldWidget/SocialGroupSelectorWidget.php, line 322

Class

SocialGroupSelectorWidget
A widget to select a group when creating an entity in a group.

Namespace

Drupal\social_group\Plugin\Field\FieldWidget

Code

private function checkGroupContentCreateAccess($gid, User $account, EntityInterface $entity) {
  $group = Group::load($gid);
  if ($group
    ->hasPermission('create group_' . $entity
    ->getEntityTypeId() . ':' . $entity
    ->bundle() . ' entity', $account)) {
    if ($group
      ->getGroupType()
      ->id() === 'public_group') {
      $config = $this->configFactory
        ->get('entity_access_by_field.settings');
      if ($config
        ->get('disable_public_visibility') === 1 && !$account
        ->hasPermission('override disabled public visibility')) {
        return FALSE;
      }
    }
    return TRUE;
  }
  return FALSE;
}