Determine if the given user can view the tag.

@param UserPolicy $user
@param Tag $tag

@return bool
552036
public function view(UserPolicy $user, Tag $tag)
    {
        if ($user->canDo('news.tag.view') && $user->isAdmin()) {
            return true;
        }

        return $tag->user_id == user_id() && $tag->user_type == user_type();
    }
559283
public function view(User $user, Job $job)
    {
        return $this->allowOnTeam($user, $job->team_id);
    }
878393
private function isTagDisplayable(WorkspaceTag $tag, array $tagWorkspaces, array $hierarchy)
    {
        $displayable = false;
        $tagId = $tag->getId();

        if ((isset($tagWorkspaces[$tagId]) && count($tagWorkspaces[$tagId]) > 0)
            || !is_null($tag->getWorkspace())) {

            $displayable = true;
        } else {

            if (isset($hierarchy[$tagId]) && count($hierarchy[$tagId]) > 0) {
                $children = $hierarchy[$tagId];

                foreach ($children as $child) {

                    $displayable = $this->isTagDisplayable($child, $tagWorkspaces, $hierarchy);

                    if ($displayable) {
                        break;
                    }
                }
            }
        }

        return $displayable;
    }
632424
public function view(UserPolicy $user, Portfolio $portfolio)
    {
        if ($user->canDo('portfolio.portfolio.view') && $user->isAdmin()) {
            return true;
        }

        return $portfolio->user_id == user_id() && $portfolio->user_type == user_type();
    }
89307
public function can_view_participants(stdClass $user, discussion_entity $discussion) : bool {
        return course_can_view_participants($this->get_context()) &&
            !$this->must_post_before_viewing_discussion($user, $discussion);
    }
805803
public function view(UserPolicy $user, Job $job)
    {
        if ($user->canDo('career.job.view') && $user->isAdmin()) {
            return true;
        }

        return $job->user_id == user_id() && $job->user_type == user_type();
    }
1117157
public function update(User $user, MemberTag $memberTag)
    {
        return $this->allowForRoleOnTeam($user, 'Coach', $memberTag->team_id);
    }
543234
public function read(User $user, User $entity)
    {
        if ($entity->id === $user->id) {
            return true;
        }
        return $user->hasPermission('user-read');
    }
1028835
protected function _isAllowed($parent, $tag) {
        $filter = $this->getFilterByTag($tag);

        if (!$filter) {
            return false;
        }

        $child = $filter->getTag($tag);

        // Remove children after a certain nested depth
        if (isset($parent['currentDepth']) && $parent['maxChildDepth'] >= 0 && $parent['currentDepth'] > $parent['maxChildDepth']) {
            return false;

        // Children that can only be within a certain parent
        } else if ($child['parent'] && !in_array($parent['tag'], $child['parent'])) {
            return false;

        // Parents that can not have specific direct descendant children
        } else if ($parent['childrenBlacklist'] && in_array($child['tag'], $parent['childrenBlacklist'])) {
            return false;

        // Parents that can only have direct descendant children
        } else if ($parent['childrenWhitelist'] && !in_array($child['tag'], $parent['childrenWhitelist'])) {
            return false;
        }

        // Validate the type nesting
        switch ($parent['allowedTypes']) {
            case self::TYPE_INLINE:
                // Inline type only allowed
                if ($child['displayType'] === self::TYPE_INLINE) {
                    return true;
                }
            break;
            case self::TYPE_BLOCK:
                // Block types only allowed if the parent is also a block
                if ($parent['displayType'] === self::TYPE_BLOCK && $child['displayType'] === self::TYPE_BLOCK) {
                    return true;
                }
            break;
            case self::TYPE_BOTH:
                if ($parent['displayType'] === self::TYPE_INLINE) {
                    // Only allow inline if parent is inline
                    if ($child['displayType'] === self::TYPE_INLINE) {
                        return true;
                    }
                } else {
                    return true;
                }
            break;
        }

        // Log the error
        $this->_errors[] = array(
            'type' => self::ERROR_SCOPE,
            'parent' => $parent['tag'],
            'parentType' => $parent['displayType'],
            'parentAllowed' => $parent['allowedTypes'],
            'child' => $child['tag'],
            'childType' => $child['displayType']
        );

        return false;
    }
902316
public function canView(GroupableInterface $media, TokenInterface $token): bool
    {
        $user = $token->getUser();
        if (0 == count($media->getGroups())) {
            return true;
        }

        return parent::canView($media, $token);
    }
48843
public function getTags(
        User $user = null,
        $search = '',
        $withPlatform = false,
        $orderedBy = 'name',
        $order = 'ASC',
        $withPager = false,
        $page = 1,
        $max = 50,
        $strictSearch = false
    )
    {
        $tags = is_null($user) ?
            $this->getPlatformTags(
                $search,
                $orderedBy,
                $order,
                $withPager,
                $page,
                $max,
                $strictSearch
            ) :
            $this->getUserTags(
                $user,
                $search,
                $withPlatform,
                $orderedBy,
                $order,
                $withPager,
                $page,
                $max,
                $strictSearch
            );

        return $tags;
    }
443161
public boolean allowAccess(String user) {

        try {
            return m_cms.getPermissions(m_root, user).requiresViewPermission();
        } catch (CmsException e) {
            LOG.error(e.getLocalizedMessage(), e);
            return true;
        }
    }
905009
private function hasPermission(AuthenticatedUserInterface $user, string $uri) {

        // Collect permissions
        $permissions = $this->getParameterByKey("permissions");

        // Iterate over permission
        foreach ($permissions as $permissionPath => $acceptableRoles) {
            if($permissionPath[0] !== "/") {
                $permissionPath = "/".$permissionPath;
            }
            if(substr($permissionPath,-1) !== "/") {
                $permissionPath = $permissionPath."/";
            }
            $match = preg_match($permissionPath,$uri);
            if ($match == 1) {
                if(in_array(Role::ANON_USER,$acceptableRoles)) return true;
                foreach ($acceptableRoles as $permissionRole) {
                    if(in_array($permissionRole,$user->getRoles())) return true;
                }
                return false;
            }
        }
        return false;
    }
1322616
public function isOwner(User $user)
    {
        $owner = $this->getOwner();
        if ($owner !== null && $user->getId() === $owner->getUser()->getId()) {
            return true;
        }

        return false;
    }
1135462
public function update(User $user, User $entity)
    {
        if ($entity->id === $user->id) {
            return true;
        }
        return $user->hasPermission('user-update');
    }
953102
public static function isUserCan($model, $userId)
    {
        //if he try vote on its own question
        if (isset($model['user_id']) && $model['user_id'] == $userId) {
            return false;
        } else {
            return !self::find()->where([
                'user_id' => $userId,
                'entity' => self::modelEntityType($model),
                'entity_id' => $model['id']
            ])->exists();
        }
    }
655122
public function userIsParticipant( eZUser $user )
    {
        /** @var eZCollaborationItemParticipantLink $participantLink */
        foreach ( $this->participantList() as $participantLink )
        {
            $participant = $participantLink->participant();

            if ( $participant instanceof eZUser )
            {
                if ( $participant->attribute( 'contentobject_id' ) == $user->attribute( 'contentobject_id' ) )
                {
                    return true;
                }
            }
            // user group
            else if ( $participant instanceof eZContentObject )
            {
                foreach ( $user->groups() as $userGroup )
                {
                    if ( $participant->attribute( 'id' ) == $userGroup->attribute( 'id' ) )
                    {
                        return true;
                    }
                }
            }
        }
        return false;
    }