Is user member of the given group

@param AccountInterface $account
@param Group $group

@return bool
765058
public function userIsMember(AccountInterface $account, Group $group)
    {
        // @todo fix this, cache that
        return (bool)$this
            ->database
            ->query(
                "SELECT 1 FROM {ucms_group_access} WHERE group_id = :group AND user_id = :user",
                [':group' => $group->getId(), ':user' => $account->id()]
            )
            ->fetchField()
        ;
    }
986257
public function getAssignedPartyOfAccount(Account $account)
    {
        $accountIdentifier = $this->persistenceManager->getIdentifierByObject($account);

        // We need to prevent stale object references and therefore only cache the identifier.
        if (!array_key_exists($accountIdentifier, $this->accountsInPartyRuntimeCache)) {
            $party = $this->partyRepository->findOneHavingAccount($account);
            $this->accountsInPartyRuntimeCache[$accountIdentifier] = $party === null ? null : $this->persistenceManager->getIdentifierByObject($party);

            return $party;
        }

        if ($this->accountsInPartyRuntimeCache[$accountIdentifier] !== null) {
            $partyIdentifier = $this->accountsInPartyRuntimeCache[$accountIdentifier];

            return $this->persistenceManager->getObjectByIdentifier($partyIdentifier, AbstractParty::class);
        }

        return null;
    }
1335801
public function deleteAccount(array $account)
    {
        $result = $this->wechat->httpRaw(self::WECHAT_ACCOUNT_DELETE_PREFIX, $account, [
            'access_token' => $this->wechat->getAccessToken()
        ]);
        return isset($result['errmsg']) && $result['errmsg'] == 'ok';
    }
23762
def is_member_of(self, group_name):
        """"""
        group_dn = 'cn=%s,cn=groups,cn=accounts,%s' % (group_name, self._base_dn)
        if str(group_dn).lower() in [str(i).lower() for i in self.member_of]:
            return True
        else:
            return False
632439
public function isUserWebmaster(Menu $menu, AccountInterface $account)
    {
        if ($menu->hasSiteId()) {
            $site = $this->siteManager->getStorage()->findOne($menu->getSiteId());

            return $this->siteManager->getAccess()->userIsWebmaster($account, $site);
        }

        return false;
    }
373083
public function canEditAllLabels(AccountInterface $account = null)
    {
        if ($account === null) {
            global $user;
            $account = $user;
        }

        return (
            user_access(LabelAccess::PERM_EDIT_NON_LOCKED, $account) &&
            user_access(LabelAccess::PERM_EDIT_LOCKED, $account)
        );
    }
1199032
protected function isUserAssignedToGroup($groups)
    {
        $isValid = false;

        $user = $this->getUser();
        foreach ($groups as $group) {
            if ($user->inGroup($group->getId())) {
                $isValid = true;
                break;
            }
        }

        return $isValid;
    }
163690
public function isExecutable(int $user, int $group): bool
    {
        if ($this->user === $user) {
            $check = 0100;
        } elseif ($this->group === $group) {
            $check = 0010;
        } else {
            $check = 0001;
        }

        return (bool) ($this->permissions & $check);
    }
564211
public function canEditLockedLabels(AccountInterface $account = null)
    {
        if ($account === null) {
            global $user;
            $account = $user;
        }

        return user_access(LabelAccess::PERM_EDIT_LOCKED, $account);
    }
1023726
protected function findGroupsForAccountUsingAccountAttribute(Entity\AccountNode $account)
    {
        $accountAttrValues = $account->getRawLdapNode()->getAttribute($this->getConfiguration()->getAccountMembershipAttribute());

        $filterProperty = '';

        switch ($this->getConfiguration()->getAccountMembershipAttributeMappingType()) {
            case Enum\AccountMembershipMappingType::DN:
                return new Collection\GroupNodeCollection(new Collection\DnIterator($this->connection, $accountAttrValues));
                break;
            case Enum\AccountMembershipMappingType::NAME:
                $filterProperty = $this->getConfiguration()->getGroupNameAttribute();
                break;
        }

        $filters = array();

        foreach ($accountAttrValues as $accountAttrValue) {
            $filters[] = new Filter\StringFilter($filterProperty . '=' . Filter\AbstractFilter::escapeValue($accountAttrValue));
        }

        return $this->searchNodes(
            $this->buildFilter(
                new Filter\OrFilter($filters)
            )
        );
    }
1013481
public function enrollManageAccess(AccountInterface $account) {
    if (AccessResult::allowedIfHasPermission($account, 'manage all enrollments')->isAllowed()) {
      return AccessResult::allowed();
    }
    else {
      /** @var \Drupal\node\Entity\Node $node */
      $node = $this->routeMatch->getParameter('node');
      if (!is_null($node) && (!is_object($node))) {
        $node = $this->entityTypeManager
          ->getStorage('node')
          ->load($node);
      }
      if ($node instanceof NodeInterface) {
        return SocialEventManagersAccessHelper::getEntityAccessResult($node, 'update', $account);
      }
    }
    return AccessResult::forbidden();
  }
549985
public function canView(GroupableInterface $groupable, TokenInterface $token): bool
    {
        $user = $token->getUser();

        // Expirable entities can only be viewed by editors if expired.
        if ($groupable instanceof ExpirableInterface
            && $groupable->isExpired()) {
            $required_role = 'GROUP_ROLE_EDITOR';

        // Active entities can only be viewed by editors if not active.
        } elseif ($groupable instanceof ActiveInterface
            && !$groupable->isActive()) {
            $required_role = 'GROUP_ROLE_EDITOR';

        // Entity can be viewed by group users.
        } else {
            $required_role = 'GROUP_ROLE_USER';
        }

        // Iterate over groups and check access.
        foreach ($groupable->getGroups() as $group) {
            if ($this->decision_manager->decide($token, [$required_role], $group)) {
                return true;
            }
        }

        return false;
    }
1137863
public function getUserGroups(AccountInterface $account)
    {
        $userId = $account->id();

        if (!isset($this->accessCache[$userId])) {
            $this->accessCache[$userId] = [];

            $q = $this
                ->database
                ->select('ucms_group_access', 'gu')
                ->fields('gu', ['group_id', 'user_id', 'role'])
                ->condition('gu.user_id', $userId)
            ;

            // This will populate the PartialUserInterface information without
            // the need to join on the user table. Performance for the win.
            // This will always remain true as long as we have a foreign key
            // constraint on the user table, we are sure that the user actually
            // exists, and since we have the instance, it's all good!
            $q->addExpression(':name', 'name', [':name' => $account->getAccountName()]);
            $q->addExpression(':mail', 'mail', [':mail' => $account->getEmail()]);
            $q->addExpression(':status', 'status', [':status' => $account->status]);

            $r = $q->execute();
            $r->setFetchMode(\PDO::FETCH_CLASS, GroupMember::class);

            // Can't use fetchAllAssoc() because properties are private on the
            // objects built by PDO
            $this->accessCache[$userId] = [];

            foreach ($r as $record) {
                $this->accessCache[$userId][] = $record;
            }
        }

        return $this->accessCache[$userId];
    }
1139485
public function userCanReference(AccountInterface $account, NodeInterface $node)
    {
        return $node->access(Permission::VIEW, $account) && $this->manager->getAccess()->userIsWebmaster($account);
    }
931960
public function canAccessMenuAdmin(AccountInterface $account, Site $site = null)
    {
        if ($account->hasPermission(self::PERM_MANAGE_ALL_MENU)) {
            return true;
        }

        $site = $this->ensureSiteContext($site);

        if ($site) {
            return $this->siteManager->getAccess()->userIsWebmaster($account, $site);
        } else {
            return $this->siteManager->getAccess()->userIsWebmaster($account);
        }

        return  false;
    }
951554
protected function blockAccess(AccountInterface $account) {
    // If tagging is off, deny access always.
    if (!$this->tagService->active() || !$this->tagService->groupActive()) {
      return AccessResult::forbidden();
    }

    // Routes we don't want to display the tag block on.
    $ignore_routes = [
      'entity.group.join',
      'entity.group.leave',
      'entity.group.edit_form',
      'entity.group.delete_form',
      'entity.group_content.collection',
    ];

    // Don't display on group edit.
    if (in_array($this->routeMatch->getRouteName(), $ignore_routes)) {
      return AccessResult::forbidden();
    }

    // Get group from route.
    $group = $this->routeMatch->getParameter('group');

    if ($group instanceof Group) {
      if ($group->hasField('social_tagging')) {
        if (!empty(($group->get('social_tagging')->getValue()))) {
          // We only show the block if the field contains values.
          return AccessResult::allowed();
        }
      }
    }

    return AccessResult::forbidden();
  }
78855
public function isConnected(ClientInterface $provider)
    {
        return $this->accounts != null && isset($this->accounts[$provider->getId()]);
    }